File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,6 @@ data "aws_subnet_ids" "all" {
1313 vpc_id = " ${ data . aws_vpc . default . id } "
1414}
1515
16- data "aws_security_group" "default" {
17- vpc_id = " ${ data . aws_vpc . default . id } "
18- name = " default"
19- }
20-
2116data "aws_ami" "amazon_linux" {
2217 most_recent = true
2318
@@ -38,12 +33,23 @@ data "aws_ami" "amazon_linux" {
3833 }
3934}
4035
36+ module "security_group" {
37+ source = " terraform-aws-modules/security-group/aws"
38+
39+ name = " example"
40+ description = " Security group for example usage with EC2 instance"
41+ vpc_id = " ${ data . aws_vpc . default . id } "
42+
43+ ingress_cidr_blocks = [" 0.0.0.0/0" ]
44+ ingress_rules = [" http-80-tcp" ]
45+ }
46+
4147module "ec2" {
4248 source = " ../../"
4349
4450 name = " example"
4551 ami = " ${ data . aws_ami . amazon_linux . id } "
4652 instance_type = " t2.micro"
47- vpc_security_group_ids = [" ${ data . aws_security_group . default . id } " ]
53+ vpc_security_group_ids = [" ${ module . security_group . this_security_group_id } " ]
4854 associate_public_ip_address = true
4955}
You can’t perform that action at this time.
0 commit comments