Skip to content

Commit c8c50bd

Browse files
authored
Groundwork new workflows (#232)
1 parent d4009cb commit c8c50bd

File tree

6 files changed

+40
-54
lines changed

6 files changed

+40
-54
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ Available targets:
409409
| <a name="input_spot_max_price"></a> [spot\_max\_price](#input\_spot\_max\_price) | The maximum price per unit hour, in US$, that you're willing to pay for a Spot Instance. This option is relevant only when enable\_spot\_instances is true. Valid values are between 0.001 and 20.0 | `number` | `-1` | no |
410410
| <a name="input_ssh_listener_enabled"></a> [ssh\_listener\_enabled](#input\_ssh\_listener\_enabled) | Enable SSH port | `bool` | `false` | no |
411411
| <a name="input_ssh_listener_port"></a> [ssh\_listener\_port](#input\_ssh\_listener\_port) | SSH port | `number` | `22` | no |
412-
| <a name="input_ssh_source_restriction"></a> [ssh\_source\_restriction](#input\_ssh\_source\_restriction) | Used to lock down SSH access to the EC2 instances | `string` | `"0.0.0.0/0"` | no |
413412
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
414413
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
415414
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |

docs/terraform.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@
164164
| <a name="input_spot_max_price"></a> [spot\_max\_price](#input\_spot\_max\_price) | The maximum price per unit hour, in US$, that you're willing to pay for a Spot Instance. This option is relevant only when enable\_spot\_instances is true. Valid values are between 0.001 and 20.0 | `number` | `-1` | no |
165165
| <a name="input_ssh_listener_enabled"></a> [ssh\_listener\_enabled](#input\_ssh\_listener\_enabled) | Enable SSH port | `bool` | `false` | no |
166166
| <a name="input_ssh_listener_port"></a> [ssh\_listener\_port](#input\_ssh\_listener\_port) | SSH port | `number` | `22` | no |
167-
| <a name="input_ssh_source_restriction"></a> [ssh\_source\_restriction](#input\_ssh\_source\_restriction) | Used to lock down SSH access to the EC2 instances | `string` | `"0.0.0.0/0"` | no |
168167
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
169168
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
170169
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |

examples/shared-alb/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ variable "loadbalancer_is_shared" {
2929
description = "Flag to create a shared application loadbalancer. Only when loadbalancer_type = \"application\" https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-alb-shared.html"
3030
}
3131

32-
variable "shared_loadbalancer_arn" {
33-
type = string
34-
default = ""
35-
description = "ARN of the shared application load balancer. Only when loadbalancer_type = \"application\"."
36-
}
37-
3832
variable "dns_zone_id" {
3933
type = string
4034
description = "Route53 parent zone ID. The module will create sub-domain DNS record in the parent zone for the EB environment"

main.tf

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
22
enabled = module.this.enabled
3-
partition = join("", data.aws_partition.current.*.partition)
3+
partition = join("", data.aws_partition.current[*].partition)
44
}
55

66
data "aws_partition" "current" {
@@ -31,21 +31,21 @@ resource "aws_iam_role" "service" {
3131
count = local.enabled ? 1 : 0
3232

3333
name = "${module.this.id}-eb-service"
34-
assume_role_policy = join("", data.aws_iam_policy_document.service.*.json)
34+
assume_role_policy = join("", data.aws_iam_policy_document.service[*].json)
3535
tags = module.this.tags
3636
}
3737

3838
resource "aws_iam_role_policy_attachment" "enhanced_health" {
3939
count = local.enabled && var.enhanced_reporting_enabled ? 1 : 0
4040

41-
role = join("", aws_iam_role.service.*.name)
41+
role = join("", aws_iam_role.service[*].name)
4242
policy_arn = "arn:${local.partition}:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth"
4343
}
4444

4545
resource "aws_iam_role_policy_attachment" "service" {
4646
count = local.enabled ? 1 : 0
4747

48-
role = join("", aws_iam_role.service.*.name)
48+
role = join("", aws_iam_role.service[*].name)
4949
policy_arn = var.prefer_legacy_service_policy ? "arn:${local.partition}:iam::aws:policy/service-role/AWSElasticBeanstalkService" : "arn:${local.partition}:iam::aws:policy/AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy"
5050
}
5151

@@ -89,44 +89,44 @@ data "aws_iam_policy_document" "ec2" {
8989
resource "aws_iam_role_policy_attachment" "elastic_beanstalk_multi_container_docker" {
9090
count = local.enabled ? 1 : 0
9191

92-
role = join("", aws_iam_role.ec2.*.name)
92+
role = join("", aws_iam_role.ec2[*].name)
9393
policy_arn = "arn:${local.partition}:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker"
9494
}
9595

9696
resource "aws_iam_role" "ec2" {
9797
count = local.enabled ? 1 : 0
9898

9999
name = "${module.this.id}-eb-ec2"
100-
assume_role_policy = join("", data.aws_iam_policy_document.ec2.*.json)
100+
assume_role_policy = join("", data.aws_iam_policy_document.ec2[*].json)
101101
tags = module.this.tags
102102
}
103103

104104
resource "aws_iam_role_policy" "default" {
105105
count = local.enabled ? 1 : 0
106106

107107
name = "${module.this.id}-eb-default"
108-
role = join("", aws_iam_role.ec2.*.id)
109-
policy = join("", data.aws_iam_policy_document.extended.*.json)
108+
role = join("", aws_iam_role.ec2[*].id)
109+
policy = join("", data.aws_iam_policy_document.extended[*].json)
110110
}
111111

112112
resource "aws_iam_role_policy_attachment" "web_tier" {
113113
count = local.enabled ? 1 : 0
114114

115-
role = join("", aws_iam_role.ec2.*.name)
115+
role = join("", aws_iam_role.ec2[*].name)
116116
policy_arn = "arn:${local.partition}:iam::aws:policy/AWSElasticBeanstalkWebTier"
117117
}
118118

119119
resource "aws_iam_role_policy_attachment" "worker_tier" {
120120
count = local.enabled ? 1 : 0
121121

122-
role = join("", aws_iam_role.ec2.*.name)
122+
role = join("", aws_iam_role.ec2[*].name)
123123
policy_arn = "arn:${local.partition}:iam::aws:policy/AWSElasticBeanstalkWorkerTier"
124124
}
125125

126126
resource "aws_iam_role_policy_attachment" "ssm_ec2" {
127127
count = local.enabled ? 1 : 0
128128

129-
role = join("", aws_iam_role.ec2.*.name)
129+
role = join("", aws_iam_role.ec2[*].name)
130130
policy_arn = var.prefer_legacy_ssm_policy ? "arn:${local.partition}:iam::aws:policy/service-role/AmazonEC2RoleforSSM" : "arn:${local.partition}:iam::aws:policy/AmazonSSMManagedInstanceCore"
131131

132132
lifecycle {
@@ -137,7 +137,7 @@ resource "aws_iam_role_policy_attachment" "ssm_ec2" {
137137
resource "aws_iam_role_policy_attachment" "ssm_automation" {
138138
count = local.enabled ? 1 : 0
139139

140-
role = join("", aws_iam_role.ec2.*.name)
140+
role = join("", aws_iam_role.ec2[*].name)
141141
policy_arn = "arn:${local.partition}:iam::aws:policy/service-role/AmazonSSMAutomationRole"
142142

143143
lifecycle {
@@ -150,15 +150,15 @@ resource "aws_iam_role_policy_attachment" "ssm_automation" {
150150
resource "aws_iam_role_policy_attachment" "ecr_readonly" {
151151
count = local.enabled ? 1 : 0
152152

153-
role = join("", aws_iam_role.ec2.*.name)
153+
role = join("", aws_iam_role.ec2[*].name)
154154
policy_arn = "arn:${local.partition}:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
155155
}
156156

157157
resource "aws_ssm_activation" "ec2" {
158158
count = local.enabled ? 1 : 0
159159

160160
name = module.this.id
161-
iam_role = join("", aws_iam_role.ec2.*.id)
161+
iam_role = join("", aws_iam_role.ec2[*].id)
162162
registration_limit = var.autoscale_max
163163
tags = module.this.tags
164164
depends_on = [aws_elastic_beanstalk_environment.default]
@@ -289,8 +289,8 @@ data "aws_iam_policy_document" "default" {
289289
]
290290

291291
resources = [
292-
join("", aws_iam_role.ec2.*.arn),
293-
join("", aws_iam_role.service.*.arn)
292+
join("", aws_iam_role.ec2[*].arn),
293+
join("", aws_iam_role.service[*].arn)
294294
]
295295

296296
effect = "Allow"
@@ -346,15 +346,15 @@ data "aws_iam_policy_document" "default" {
346346
data "aws_iam_policy_document" "extended" {
347347
count = local.enabled ? 1 : 0
348348

349-
source_json = join("", data.aws_iam_policy_document.default.*.json)
349+
source_json = join("", data.aws_iam_policy_document.default[*].json)
350350
override_policy_documents = [var.extended_ec2_policy_document]
351351
}
352352

353353
resource "aws_iam_instance_profile" "ec2" {
354354
count = local.enabled ? 1 : 0
355355

356356
name = "${module.this.id}-eb-ec2"
357-
role = join("", aws_iam_role.ec2.*.name)
357+
role = join("", aws_iam_role.ec2[*].name)
358358
tags = module.this.tags
359359
}
360360

@@ -469,7 +469,7 @@ locals {
469469
{
470470
namespace = "aws:elbv2:loadbalancer"
471471
name = "AccessLogsS3Bucket"
472-
value = !var.loadbalancer_is_shared ? join("", sort(aws_s3_bucket.elb_logs.*.id)) : ""
472+
value = !var.loadbalancer_is_shared ? join("", sort(aws_s3_bucket.elb_logs[*].id)) : ""
473473
},
474474
{
475475
namespace = "aws:elbv2:loadbalancer"
@@ -650,7 +650,7 @@ resource "aws_elastic_beanstalk_environment" "default" {
650650
setting {
651651
namespace = "aws:autoscaling:launchconfiguration"
652652
name = "IamInstanceProfile"
653-
value = join("", aws_iam_instance_profile.ec2.*.name)
653+
value = join("", aws_iam_instance_profile.ec2[*].name)
654654
resource = ""
655655
}
656656

@@ -671,7 +671,7 @@ resource "aws_elastic_beanstalk_environment" "default" {
671671
setting {
672672
namespace = "aws:elasticbeanstalk:environment"
673673
name = "ServiceRole"
674-
value = join("", aws_iam_role.service.*.name)
674+
value = join("", aws_iam_role.service[*].name)
675675
resource = ""
676676
}
677677

@@ -1111,7 +1111,7 @@ data "aws_iam_policy_document" "elb_logs" {
11111111

11121112
principals {
11131113
type = "AWS"
1114-
identifiers = [join("", data.aws_elb_service_account.main.*.arn)]
1114+
identifiers = [join("", data.aws_elb_service_account.main[*].arn)]
11151115
}
11161116

11171117
effect = "Allow"
@@ -1130,7 +1130,7 @@ resource "aws_s3_bucket" "elb_logs" {
11301130
bucket = "${module.this.id}-eb-loadbalancer-logs"
11311131
acl = "private"
11321132
force_destroy = var.force_destroy
1133-
policy = join("", data.aws_iam_policy_document.elb_logs.*.json)
1133+
policy = join("", data.aws_iam_policy_document.elb_logs[*].json)
11341134
tags = module.this.tags
11351135

11361136
dynamic "server_side_encryption_configuration" {
@@ -1166,20 +1166,20 @@ module "dns_hostname" {
11661166

11671167
dns_name = var.dns_subdomain != "" ? var.dns_subdomain : module.this.name
11681168
zone_id = var.dns_zone_id
1169-
records = [join("", aws_elastic_beanstalk_environment.default.*.cname)]
1169+
records = [join("", aws_elastic_beanstalk_environment.default[*].cname)]
11701170

11711171
context = module.this.context
11721172
}
11731173

11741174
data "aws_lb_listener" "http" {
11751175
count = local.enabled && var.loadbalancer_redirect_http_to_https ? 1 : 0
1176-
load_balancer_arn = var.loadbalancer_is_shared ? var.shared_loadbalancer_arn : one(aws_elastic_beanstalk_environment.default.0.load_balancers)
1176+
load_balancer_arn = var.loadbalancer_is_shared ? var.shared_loadbalancer_arn : one(aws_elastic_beanstalk_environment.default[0].load_balancers)
11771177
port = var.application_port
11781178
}
11791179

11801180
resource "aws_lb_listener_rule" "redirect_http_to_https" {
11811181
count = local.enabled && var.loadbalancer_redirect_http_to_https ? 1 : 0
1182-
listener_arn = one(data.aws_lb_listener.http.*.arn)
1182+
listener_arn = one(data.aws_lb_listener.http[*].arn)
11831183
priority = var.loadbalancer_redirect_http_to_https_priority
11841184

11851185
condition {

outputs.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ output "hostname" {
44
}
55

66
output "id" {
7-
value = join("", aws_elastic_beanstalk_environment.default.*.id)
7+
value = join("", aws_elastic_beanstalk_environment.default[*].id)
88
description = "ID of the Elastic Beanstalk environment"
99
}
1010

1111
output "name" {
12-
value = join("", aws_elastic_beanstalk_environment.default.*.name)
12+
value = join("", aws_elastic_beanstalk_environment.default[*].name)
1313
description = "Name of the Elastic Beanstalk environment"
1414
}
1515

@@ -34,61 +34,61 @@ output "elb_zone_id" {
3434
}
3535

3636
output "ec2_instance_profile_role_name" {
37-
value = join("", aws_iam_role.ec2.*.name)
37+
value = join("", aws_iam_role.ec2[*].name)
3838
description = "Instance IAM role name"
3939
}
4040

4141
output "tier" {
42-
value = join("", aws_elastic_beanstalk_environment.default.*.tier)
42+
value = join("", aws_elastic_beanstalk_environment.default[*].tier)
4343
description = "The environment tier"
4444
}
4545

4646
output "application" {
47-
value = join("", aws_elastic_beanstalk_environment.default.*.application)
47+
value = join("", aws_elastic_beanstalk_environment.default[*].application)
4848
description = "The Elastic Beanstalk Application for this environment"
4949
}
5050

5151
output "setting" {
52-
value = try(aws_elastic_beanstalk_environment.default.0.setting, [])
52+
value = try(aws_elastic_beanstalk_environment.default[0].setting, [])
5353
description = "Settings specifically set for this environment"
5454
}
5555

5656
output "all_settings" {
57-
value = try(aws_elastic_beanstalk_environment.default.0.all_settings, [])
57+
value = try(aws_elastic_beanstalk_environment.default[0].all_settings, [])
5858
description = "List of all option settings configured in the environment. These are a combination of default settings and their overrides from setting in the configuration"
5959
}
6060

6161
output "endpoint" {
62-
value = join("", aws_elastic_beanstalk_environment.default.*.cname)
62+
value = join("", aws_elastic_beanstalk_environment.default[*].cname)
6363
description = "Fully qualified DNS name for the environment"
6464
}
6565

6666
output "autoscaling_groups" {
67-
value = try(aws_elastic_beanstalk_environment.default.0.autoscaling_groups, [])
67+
value = try(aws_elastic_beanstalk_environment.default[0].autoscaling_groups, [])
6868
description = "The autoscaling groups used by this environment"
6969
}
7070

7171
output "instances" {
72-
value = try(aws_elastic_beanstalk_environment.default.*.instances, [])
72+
value = try(aws_elastic_beanstalk_environment.default[*].instances, [])
7373
description = "Instances used by this environment"
7474
}
7575

7676
output "launch_configurations" {
77-
value = try(aws_elastic_beanstalk_environment.default.*.launch_configurations, [])
77+
value = try(aws_elastic_beanstalk_environment.default[*].launch_configurations, [])
7878
description = "Launch configurations in use by this environment"
7979
}
8080

8181
output "load_balancers" {
82-
value = try(aws_elastic_beanstalk_environment.default.0.load_balancers, [])
82+
value = try(aws_elastic_beanstalk_environment.default[0].load_balancers, [])
8383
description = "Elastic Load Balancers in use by this environment"
8484
}
8585

8686
output "queues" {
87-
value = try(aws_elastic_beanstalk_environment.default.*.queues, [])
87+
value = try(aws_elastic_beanstalk_environment.default[*].queues, [])
8888
description = "SQS queues in use by this environment"
8989
}
9090

9191
output "triggers" {
92-
value = try(aws_elastic_beanstalk_environment.default.*.triggers, [])
92+
value = try(aws_elastic_beanstalk_environment.default[*].triggers, [])
9393
description = "Autoscaling triggers in use by this environment"
9494
}

variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ variable "elb_scheme" {
371371
description = "Specify `internal` if you want to create an internal load balancer in your Amazon VPC so that your Elastic Beanstalk application cannot be accessed from outside your Amazon VPC"
372372
}
373373

374-
variable "ssh_source_restriction" {
375-
type = string
376-
default = "0.0.0.0/0"
377-
description = "Used to lock down SSH access to the EC2 instances"
378-
}
379-
380374
variable "ssh_listener_enabled" {
381375
type = bool
382376
default = false

0 commit comments

Comments
 (0)