无法将安全组添加到启动模板
Cant add security group to launch template
我正在编写 terraform infra,我的启动模板的安全组有问题。
image_id = aws_ami_from_instance.name12.id
network_interfaces {
vpc_security_group_ids = [aws_security_group.name32.id]
associate_public_ip_address = true
subnet_id = aws_subnet.name1.id
delete_on_termination = true
}
> terraform apply
Error: Unsupported
on LT.tf line 15, in resource "aws_launch_template" "LTforASG
15: vpc_security_group_ids = aws_security_group.pub_SG.
An argument named "vpc_security_group_ids" is not expected here.
如果我把它写在“network_interface”块之外,它会给出如下错误:
Error: Error creating Auto Scaling Group: InvalidQueryParameter: Invalid launch template: When a network interface is provided, the security groups must be a part of it
status code: 400, request id: 59d14734-6cde-4027-b245-f3269b7a8071
谢谢
根据文档,对于 network_interfaces,您应该使用 security_groups
,而不是 vpc_security_group_ids
:
network_interfaces {
security_groups = [aws_security_group.name32.id]
associate_public_ip_address = true
subnet_id = aws_subnet.name1.id
delete_on_termination = true
}
我正在编写 terraform infra,我的启动模板的安全组有问题。
image_id = aws_ami_from_instance.name12.id
network_interfaces {
vpc_security_group_ids = [aws_security_group.name32.id]
associate_public_ip_address = true
subnet_id = aws_subnet.name1.id
delete_on_termination = true
}
> terraform apply
Error: Unsupported
on LT.tf line 15, in resource "aws_launch_template" "LTforASG
15: vpc_security_group_ids = aws_security_group.pub_SG.
An argument named "vpc_security_group_ids" is not expected here.
如果我把它写在“network_interface”块之外,它会给出如下错误:
Error: Error creating Auto Scaling Group: InvalidQueryParameter: Invalid launch template: When a network interface is provided, the security groups must be a part of it
status code: 400, request id: 59d14734-6cde-4027-b245-f3269b7a8071
谢谢
根据文档,对于 network_interfaces,您应该使用 security_groups
,而不是 vpc_security_group_ids
:
network_interfaces {
security_groups = [aws_security_group.name32.id]
associate_public_ip_address = true
subnet_id = aws_subnet.name1.id
delete_on_termination = true
}