我正在尝试更新 terraform 模块以添加新的安全组,该安全组将具有填充有两个托管前缀列表的入站规则。使用 AWS Resource Access Manager 将前缀列表从其他账户共享到我的 AWS 账户,但是我尝试引用在我自己的 AWS 账户中创建的前缀列表,但看到了相同的错误。
以下是我正在使用的地形:
resource "aws_security_group" "akamai_sg" {
name = "akamai-pl-sg"
description = "Manage access from Akamai to ${var.environment} alb"
vpc_id = var.vpc_id
tags = merge(var.common_tags, tomap({ "Name" = "akamai-pl-sg" }))
revoke_rules_on_delete = true
}
resource "aws_security_group_rule" "akamai_to_internal_alb" {
for_each = toset(var.domains_inc_akamai)
type = "ingress"
description = "Allow Akamai into ${var.environment}${var.domain_name_suffix}-alb"
from_port = var.alb_listener_port
to_port = var.alb_listener_port
protocol = "tcp"
security_group_id = aws_security_group.akamai_sg.id
prefix_list_ids = [data.aws_prefix_list.akamai-site-shield.id, data.aws_prefix_list.akamai-staging.id]
}
data "aws_prefix_list" "akamai-site-shield" {
filter {
name = "prefix-list-id"
values = ["pl-xxxxxxxxxx"]
}
}
data "aws_prefix_list" "akamai-staging" {
filter {
name = "prefix-list-id"
values = ["pl-xxxxxxxxxx"]
}
}
我正在恢复的 terraform 错误如下: “错误:未找到匹配的前缀列表;前缀列表 ID 或名称可能无效或在当前区域中不存在”
有人可以帮忙,或者看看我哪里出了问题吗?
提前致谢。
以下情况不可能吗?
data "aws_vpc_endpoint" "s3" {
vpc_id = aws_vpc.foo.id
service_name = "com.amazonaws.us-west-2.s3"
}
data "aws_prefix_list" "s3" {
prefix_list_id = aws_vpc_endpoint.s3.prefix_list_id
}
看来解决方案是使用:
data "aws_ec2_managed_prefix_list" "example" {
filter {
name = "prefix-list-name"
values = ["my-prefix-list"]
}
}
不要使用
aws_prefix_list
,而使用 aws_ec2_managed_prefix_list
。根据文档,这是推荐的方法。
aws_prefix_list 提供有关当前区域中特定 AWS 前缀列表 (PL) 的详细信息。
这可以用来验证变量中给出的前缀列表 并获取关联的 CIDR 块(IP 地址范围) AWS 服务。后者可能很有用,例如,用于添加网络 ACL 规则。
aws_ec2_driven_prefix_list 数据源通常更多 适合使用,因为它可以返回客户管理的前缀列表 信息,以及附加属性。