반응형
테라포름: 문자열 목록
나는 테라폼 모듈을 사용하여 Security Group을 만들려고 한다. 데이터 소스에서 가져온 VPC가 필요합니다. VPC ID에는 문자열 값이 필요하지만 데이터 소스는 값이 하나인 목록을 반환합니다.
찾아주세요
data "aws_vpcs" "this" {
tags = {
"Name" = "example"
}
}
module "route53_sg" {
source = "terraform-aws-modules/security-group/aws"
name = "R53_health_checkers"
description = "Security group for Route53 health checkers"
vpc_id = element([data.aws_vpcs.this.ids], 0)
ingress_cidr_blocks = [
...
...
...
]
ingress_rules = ["https-443-tcp"]
}
$ terraform apply
data.aws_lb.ext_alb: Refreshing state...
data.aws_vpcs.this: Refreshing state...
Error: Invalid value for module argument
on main.tf line 75, in module "route53_sg":
75: vpc_id = element([data.aws_vpcs.this.ids], 0)
The given value is not suitable for child module variable "vpc_id" defined at
.terraform/modules/route53_sg/terraform-aws-modules-terraform-aws-security-group-d55e4de/variables.tf:10,1-18:
string required.
vpc_id is expecting a Single string. FOLLOWING is a result from Output.tf
$ terraform apply
data.aws_lb.ext_alb: Refreshing state...
data.aws_vpcs.this: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
vpc = [
"vpc-08067a598522a7b30",
]
이미 목록이므로 다른 목록에 추가할 필요가 없습니다.
시도:
vpc_id = element(data.aws_vpcs.this.ids, 0)
: 댓글의 질문에 대한 답변: 여기서 유사한 이슈에서 언급한 바와 같이 반환된 것은 목록이 아닌 세트인 것 같습니다.
를 사용하는 경우: 할 수 있습니다.
vpc_id = element(tolist(data.aws_vpcs.this.ids), 0)
를 사용하는 경우: 할 수 있습니다.
vpc_id = element(split(",", join(",", data.aws_vpcs.this.ids))), 0)
반응형
'개발하자' 카테고리의 다른 글
파이썬 시프트 + 주피터가 있는 VScode에서 작동하지 않음을 입력합니다. (0) | 2022.12.08 |
---|---|
VSCode Jupyter가 잘못된 버전의 python을 로드합니다. (0) | 2022.12.07 |
Floot MediaQuery.of(context.size)의 device_preview 플러그인을 사용합니다.너비는 에뮬레이트된 전화기의 위젯을 제공하지 않습니다. (0) | 2022.12.06 |
Fast 테스트 방법이미지를 소비하는 API 끝점? (0) | 2022.12.05 |
Excel 데이터에서 Python 사전 만들기 (0) | 2022.12.05 |