Skip to content

Commit e3d118c

Browse files
committed
upgraded module to 0.12 and got the example working again
1 parent 8de5933 commit e3d118c

6 files changed

+127
-93
lines changed
+82-72
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,111 @@
11

2-
locals
3-
{
4-
ecosystem_name = "sec-group-test"
2+
/*
3+
| --
4+
| -- If you are using an IAM role as the AWS access mechanism then
5+
| -- pass it as in_role_arn commonly through an environment variable
6+
| -- named TF_VAR_in_role_arn in addition to the usual AWS access
7+
| -- key, secret key and default region parameters.
8+
| --
9+
*/
10+
provider aws {
11+
dynamic assume_role {
12+
for_each = length( var.in_role_arn ) > 0 ? [ var.in_role_arn ] : []
13+
content {
14+
role_arn = assume_role.value
15+
}
16+
}
17+
}
18+
19+
20+
/*
21+
| --
22+
| -- Terraform will tag every significant resource allowing you to report and collate
23+
| --
24+
| -- [1] - all infrastructure in all environments dedicated to your app (ecosystem_name)
25+
| -- [2] - the infrastructure dedicated to this environment instance (timestamp)
26+
| --
27+
*/
28+
locals {
29+
ecosystem_name = "security-grp-ex"
30+
timestamp = formatdate( "YYMMDDhhmmss", timestamp() )
31+
date_time = formatdate( "EEEE DD-MMM-YY hh:mm:ss ZZZ", timestamp() )
32+
description = "was created by me on ${ local.date_time }."
533
}
634

7-
module virtual-private-cloud-1
8-
{
9-
source = "github.com/devops4me/terraform-aws-vpc-network"
35+
36+
### ############################## ###
37+
### Example Security Group Modules ###
38+
### ############################## ###
39+
40+
module virtual-private-cloud-1 {
41+
42+
source = "devops4me/vpc-network/aws"
43+
version = "~> 1.0.3"
44+
1045
in_vpc_cidr = "10.123.0.0/16"
1146
in_create_private_gateway = false
1247
in_create_public_gateway = false
1348

14-
in_ecosystem_name = "${ local.ecosystem_name }-01"
15-
in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }"
16-
in_tag_description = "${ module.resource-tags.out_tag_description }"
49+
in_ecosystem = "${ local.ecosystem_name }-01"
50+
in_timestamp = local.timestamp
51+
in_description = local.description
1752
}
1853

19-
module security-group-test-1a
20-
{
21-
source = ".."
22-
in_vpc_id = "${ module.virtual-private-cloud-1.out_vpc_id }"
23-
in_ingress = [ "elastic", "java" ]
54+
module security-group-test-1a {
2455

25-
in_ecosystem_name = "${ local.ecosystem_name }-1a"
26-
in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }"
27-
in_tag_description = "${ module.resource-tags.out_tag_description }"
56+
source = "./.."
57+
in_vpc_id = module.virtual-private-cloud-1.out_vpc_id
58+
in_ingress = [ "docker", "java" ]
59+
60+
in_ecosystem = "${ local.ecosystem_name }-1a"
61+
in_timestamp = local.timestamp
62+
in_description = local.description
2863
}
2964

30-
module security-group-test-1b
31-
{
32-
source = ".."
33-
in_vpc_id = "${ module.virtual-private-cloud-1.out_vpc_id }"
65+
module security-group-test-1b {
66+
67+
source = "./.."
68+
in_vpc_id = module.virtual-private-cloud-1.out_vpc_id
3469
in_ingress = [ "ssh", "http", "https" ]
3570

36-
in_ecosystem_name = "${ local.ecosystem_name }-1b"
37-
in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }"
38-
in_tag_description = "${ module.resource-tags.out_tag_description }"
71+
in_ecosystem = "${ local.ecosystem_name }-1b"
72+
in_timestamp = local.timestamp
73+
in_description = local.description
3974
}
4075

41-
module virtual-private-cloud-2
42-
{
43-
source = "github.com/devops4me/terraform-aws-vpc-network"
76+
module virtual-private-cloud-2 {
77+
78+
source = "devops4me/vpc-network/aws"
79+
version = "~> 1.0.3"
80+
4481
in_vpc_cidr = "10.124.0.0/16"
4582
in_create_private_gateway = false
4683
in_create_public_gateway = false
4784

48-
in_ecosystem_name = "${ local.ecosystem_name }-02"
49-
in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }"
50-
in_tag_description = "${ module.resource-tags.out_tag_description }"
85+
in_ecosystem = "${ local.ecosystem_name }-02"
86+
in_timestamp = local.timestamp
87+
in_description = local.description
5188
}
5289

53-
module security-group-test-2a
54-
{
55-
source = ".."
56-
in_ingress = [ "elastic", "ssh", "java" ]
90+
module security-group-test-2a {
91+
92+
source = "./.."
93+
in_ingress = [ "https", "ssh", "jenkins" ]
5794
in_egress = [ "all-traffic" ]
58-
in_vpc_id = "${ module.virtual-private-cloud-2.out_vpc_id }"
95+
in_vpc_id = module.virtual-private-cloud-2.out_vpc_id
5996

60-
in_ecosystem_name = "${ local.ecosystem_name }-2a"
61-
in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }"
62-
in_tag_description = "${ module.resource-tags.out_tag_description }"
97+
in_ecosystem = "${ local.ecosystem_name }-2a"
98+
in_timestamp = local.timestamp
99+
in_description = local.description
63100
}
64101

65-
module security-group-test-2b
66-
{
67-
source = "github.com/devops4me/terraform-aws-security-group"
68-
in_vpc_id = "${ module.virtual-private-cloud-2.out_vpc_id }"
69-
in_ingress = [ "etcd-client", "etcd-server", "epmd" ]
70-
71-
in_ecosystem_name = "${ local.ecosystem_name }-2b"
72-
in_tag_timestamp = "${ module.resource-tags.out_tag_timestamp }"
73-
in_tag_description = "${ module.resource-tags.out_tag_description }"
74-
}
102+
module security-group-test-2b {
75103

76-
/*
77-
| --
78-
| -- Remember the AWS resource tags! Using this module, every
79-
| -- infrastructure component is tagged to tell you 5 things.
80-
| --
81-
| -- a) who (which IAM user) created the component
82-
| -- b) which eco-system instance is this component a part of
83-
| -- c) when (timestamp) was this component created
84-
| -- d) where (in which AWS region) was this component created
85-
| -- e) which eco-system class is this component a part of
86-
| --
87-
*/
88-
module resource-tags
89-
{
90-
source = "github.com/devops4me/terraform-aws-resource-tags"
91-
}
92-
93-
output security_group_id_1a
94-
{
95-
value = "${module.security-group-test-1a.out_security_group_id}"
96-
}
104+
source = "./.."
105+
in_vpc_id = module.virtual-private-cloud-2.out_vpc_id
106+
in_ingress = [ "sonar", "postgres", "ecs" ]
97107

98-
output security_group_id_2b
99-
{
100-
value = "${module.security-group-test-2b.out_security_group_id}"
108+
in_ecosystem = "${ local.ecosystem_name }-2b"
109+
in_timestamp = local.timestamp
110+
in_description = local.description
101111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
output security_group_id_1a {
3+
value = module.security-group-test-1a.out_security_group_id
4+
}
5+
6+
output security_group_id_2b {
7+
value = module.security-group-test-2b.out_security_group_id
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
/*
3+
| --
4+
| -- If you are using an IAM role as the AWS access mechanism then
5+
| -- pass it as in_role_arn commonly through an environment variable
6+
| -- named TF_VAR_in_role_arn in addition to the usual AWS access
7+
| -- key, secret key and default region parameters.
8+
| --
9+
*/
10+
variable in_role_arn {
11+
description = "The optional role arn to use if your AWS access mechanism is via IAM roles."
12+
default = ""
13+
type = string
14+
}

security.group-main.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
locals {
33

44
security_group_tags = {
5-
Name = "security-group-${ var.in_ecosystem_name }-${ var.in_tag_timestamp }"
6-
Desc = "New security group for ${ var.in_ecosystem_name } ${ var.in_tag_description }"
5+
Name = "security-group-${ var.in_ecosystem }-${ var.in_timestamp }"
6+
Desc = "New security group for ${ var.in_ecosystem } ${ var.in_description }"
77
}
88

99
}
@@ -18,8 +18,8 @@ locals {
1818
resource aws_security_group new {
1919

2020
vpc_id = var.in_vpc_id
21-
name = "security-group-${ var.in_ecosystem_name }-${ var.in_tag_timestamp }-n"
22-
description = "This new security group ${ var.in_tag_description }"
21+
name = "security-group-${ var.in_ecosystem }-${ var.in_timestamp }-n"
22+
description = "This new security group ${ var.in_description }"
2323
tags = merge( local.security_group_tags, var.in_mandated_tags )
2424

2525
}

security.group-outputs.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
output out_security_group_id {
88

99
description = "The string ID of either the default security group or the just created new one."
10-
value = "${ aws_security_group.new.id }"
11-
type = string
10+
value = aws_security_group.new.id
1211
}

security.group-variables.tf

+18-15
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,34 @@ variable in_mandated_tags {
7474
}
7575

7676

77-
### ################# ###
78-
### in_ecosystem_name ###
79-
### ################# ###
80-
81-
variable in_ecosystem_name {
77+
### ############ ###
78+
### in_ecosystem ###
79+
### ############ ###
8280

81+
variable in_ecosystem {
8382
description = "Creational stamp binding all infrastructure components created on behalf of this ecosystem instance."
83+
default = "security-grp"
84+
type = string
8485
}
8586

8687

87-
### ################ ###
88-
### in_tag_timestamp ###
89-
### ################ ###
90-
91-
variable in_tag_timestamp {
88+
### ############ ###
89+
### in_timestamp ###
90+
### ############ ###
9291

92+
variable in_timestamp {
9393
description = "A timestamp for resource tags in the format ymmdd-hhmm like 80911-1435"
94+
default = "timestamp"
95+
type = string
9496
}
9597

9698

97-
### ################## ###
98-
### in_tag_description ###
99-
### ################## ###
100-
101-
variable in_tag_description {
99+
### ############## ###
100+
### in_description ###
101+
### ############## ###
102102

103+
variable in_description {
103104
description = "Ubiquitous note detailing who, when, where and why for every infrastructure component."
105+
default = "This VPC network was created for an ecosystem."
106+
type = string
104107
}

0 commit comments

Comments
 (0)