[英]How Do I Use A Terraform Data Source To Reference A Managed Prefix List?
I'm trying to update a terraform module to add a new security group, which will have an inbound rule populated with two managed prefix lists.我正在尝试更新 terraform 模块以添加一个新的安全组,该安全组将包含一个包含两个托管前缀列表的入站规则。 The prefix lists are shared to my AWS account from a different account using AWS Resource Access Manager, however I have tried referencing prefix lists created within my own AWS account and am seeing the same error.
前缀列表使用 AWS Resource Access Manager 从另一个账户共享到我的 AWS 账户,但是我尝试引用在我自己的 AWS 账户中创建的前缀列表并看到相同的错误。
Below is the terraform I am using:下面是我正在使用的 terraform:
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"]
}
}
The terraform error I am revieving reads: "Error: no matching prefix list found; the prefix list ID or name may be invalid or not exist in the current region"我正在修改的 terraform 错误显示为: “错误:未找到匹配的前缀列表;前缀列表 ID 或名称可能无效或当前区域不存在”
Is anyone able to help, or see where I am going wrong?有没有人可以提供帮助,或者看看我哪里出错了?
Thanks in advance.提前致谢。
Would not be the following possible?会不会以下可能?
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
}
It seems the solution is to use:似乎解决方案是使用:
data "aws_ec2_managed_prefix_list" "example" {
filter {
name = "prefix-list-name"
values = ["my-prefix-list"]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.