为什么在非默认 vpc 中创建 ec2 实例时总是出现此错误
错误:启动源实例时出错:InvalidGroup.NotFound:VPC 'vpc-013c7c9a647b7342b' 中不存在安全组'allow_rdp'│状态码:400,请求ID:f4e72233-4e3e-4133-9676-711ec61e36c2
variable "instance_count" {
default = "1"
}
provider "aws" {
region = "us-west-1"
}
resource "aws_instance" "example" {
ami = "ami-0f87a682fa9d0ff58"
instance_type = "t2.micro"
key_name = "t2micro-1"
subnet_id = "subnet-0d9d37440a2265163"
security_groups = ["${aws_security_group.allow_rdp.name}"]
}
resource "aws_security_group" "allow_rdp" {
name = "allow_rdp"
description = "Allow ssh traffic"
vpc_id = "vpc-013c7c9a647b7342b"
ingress {
from_port = 3389 # By default, the windows server listens on TCP port 3389 for RDP
to_port = 3389
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}