|
1 | 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 | +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 = "virtual-net" |
| 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 }." |
| 33 | +} |
| 34 | + |
| 35 | + |
| 36 | + |
2 | 37 | ### #################### ###
|
3 | 38 | ### Example VPC Networks ###
|
4 | 39 | ### #################### ###
|
@@ -40,68 +75,3 @@ module no-private-subnets {
|
40 | 75 | in_timestamp = local.timestamp
|
41 | 76 | in_description = local.description
|
42 | 77 | }
|
43 |
| - |
44 |
| - |
45 |
| -### ########################### ### |
46 |
| -### Example VPC Network Outputs ### |
47 |
| -### ########################### ### |
48 |
| - |
49 |
| -output subnet_ids_1{ value = module.vpc-net.out_subnet_ids } |
50 |
| -output private_subnet_ids_1{ value = module.vpc-net.out_private_subnet_ids } |
51 |
| -output public_subnet_ids_1{ value = module.vpc-net.out_public_subnet_ids } |
52 |
| - |
53 |
| -output subnet_ids_2{ value = module.two-pub-priv-subnets.out_subnet_ids } |
54 |
| -output private_subnet_ids_2{ value = module.two-pub-priv-subnets.out_private_subnet_ids } |
55 |
| -output public_subnet_ids_2{ value = module.two-pub-priv-subnets.out_public_subnet_ids } |
56 |
| - |
57 |
| -output subnet_ids_3{ value = module.no-private-subnets.out_subnet_ids } |
58 |
| -output private_subnet_ids_3{ value = module.no-private-subnets.out_private_subnet_ids } |
59 |
| -output public_subnet_ids_3{ value = module.no-private-subnets.out_public_subnet_ids } |
60 |
| - |
61 |
| - |
62 |
| -/* |
63 |
| - | -- |
64 |
| - | -- If you are using an IAM role as the AWS access mechanism then |
65 |
| - | -- pass it as in_role_arn commonly through an environment variable |
66 |
| - | -- named TF_VAR_in_role_arn in addition to the usual AWS access |
67 |
| - | -- key, secret key and default region parameters. |
68 |
| - | -- |
69 |
| - | -- Individuals and small businesses without hundreds of AWS accounts |
70 |
| - | -- can omit the in_role_arn variable. and thanks to dynamic assignment |
71 |
| - | -- |
72 |
| -*/ |
73 |
| -provider aws { |
74 |
| - dynamic assume_role { |
75 |
| - for_each = length( var.in_role_arn ) > 0 ? [ var.in_role_arn ] : [] |
76 |
| - content { |
77 |
| - role_arn = assume_role.value |
78 |
| - } |
79 |
| - } |
80 |
| -} |
81 |
| - |
82 |
| -variable in_role_arn { |
83 |
| - description = "The Role ARN to use when we assume role to implement the provisioning." |
84 |
| - default = "" |
85 |
| -} |
86 |
| - |
87 |
| - |
88 |
| -/* |
89 |
| - | -- |
90 |
| - | -- ### ############# ### |
91 |
| - | -- ### Resource Tags ### |
92 |
| - | -- ### ############# ### |
93 |
| - | -- |
94 |
| - | -- Terraform will tag every significant resource allowing you to report and collate |
95 |
| - | -- |
96 |
| - | -- [1] - all infrastructure in all environments dedicated to your app (ecosystem_name) |
97 |
| - | -- [2] - the infrastructure dedicated to this environment instance (timestamp) |
98 |
| - | -- |
99 |
| - | -- The human readable description reveals the when, where and what of the infrastructure. |
100 |
| - | -- |
101 |
| -*/ |
102 |
| -locals { |
103 |
| - ecosystem_name = "virtual-net" |
104 |
| - timestamp = formatdate( "YYMMDDhhmmss", timestamp() ) |
105 |
| - date_time = formatdate( "EEEE DD-MMM-YY hh:mm:ss ZZZ", timestamp() ) |
106 |
| - description = "was created by me on ${ local.date_time }." |
107 |
| -} |
0 commit comments