Skip to content

Commit 0b227b0

Browse files
anton-kachurinAntoncloudpossebot
authored
Update service role policy (#175)
* Use recommended service policy * Make new service role optional * Document prefer_legacy_service_policy variable * Auto Format * Recommend to use new service policy in readme * Auto Format Co-authored-by: Anton <[email protected]> Co-authored-by: cloudpossebot <[email protected]>
1 parent 2d146af commit 0b227b0

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ For a complete example, see [examples/complete](examples/complete)
158158
application_subnets = module.subnets.private_subnet_ids
159159
allowed_security_groups = [module.vpc.vpc_default_security_group_id]
160160
161+
prefer_legacy_service_policy = false
162+
161163
// https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html
162164
// https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker
163165
solution_stack_name = "64bit Amazon Linux 2018.03 v2.12.17 running Docker 18.06.1-ce"
@@ -310,6 +312,7 @@ Available targets:
310312
| managed\_actions\_enabled | Enable managed platform updates. When you set this to true, you must also specify a `PreferredStartTime` and `UpdateLevel` | `bool` | `true` | no |
311313
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
312314
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
315+
| prefer\_legacy\_service\_policy | Whether to use AWSElasticBeanstalkService (deprecated) or AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy policy | `bool` | `true` | no |
313316
| prefer\_legacy\_ssm\_policy | Whether to use AmazonEC2RoleforSSM (will soon be deprecated) or AmazonSSMManagedInstanceCore policy | `bool` | `true` | no |
314317
| preferred\_start\_time | Configure a maintenance window for managed actions in UTC | `string` | `"Sun:10:00"` | no |
315318
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |

README.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ usage: |-
123123
application_subnets = module.subnets.private_subnet_ids
124124
allowed_security_groups = [module.vpc.vpc_default_security_group_id]
125125
126+
prefer_legacy_service_policy = false
127+
126128
// https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html
127129
// https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker
128130
solution_stack_name = "64bit Amazon Linux 2018.03 v2.12.17 running Docker 18.06.1-ce"

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
| managed\_actions\_enabled | Enable managed platform updates. When you set this to true, you must also specify a `PreferredStartTime` and `UpdateLevel` | `bool` | `true` | no |
104104
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
105105
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
106+
| prefer\_legacy\_service\_policy | Whether to use AWSElasticBeanstalkService (deprecated) or AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy policy | `bool` | `true` | no |
106107
| prefer\_legacy\_ssm\_policy | Whether to use AmazonEC2RoleforSSM (will soon be deprecated) or AmazonSSMManagedInstanceCore policy | `bool` | `true` | no |
107108
| preferred\_start\_time | Configure a maintenance window for managed actions in UTC | `string` | `"Sun:10:00"` | no |
108109
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |

examples/complete/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ module "elastic_beanstalk_environment" {
8383

8484
extended_ec2_policy_document = data.aws_iam_policy_document.minimal_s3_permissions.json
8585
prefer_legacy_ssm_policy = false
86+
prefer_legacy_service_policy = false
8687

8788
context = module.this.context
8889
}

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "aws_iam_role_policy_attachment" "enhanced_health" {
3030

3131
resource "aws_iam_role_policy_attachment" "service" {
3232
role = aws_iam_role.service.name
33-
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService"
33+
policy_arn = var.prefer_legacy_service_policy ? "arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService" : "arn:aws:iam::aws:policy/AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy"
3434
}
3535

3636
#

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,12 @@ variable "prefer_legacy_ssm_policy" {
471471
description = "Whether to use AmazonEC2RoleforSSM (will soon be deprecated) or AmazonSSMManagedInstanceCore policy"
472472
}
473473

474+
variable "prefer_legacy_service_policy" {
475+
type = bool
476+
default = true
477+
description = "Whether to use AWSElasticBeanstalkService (deprecated) or AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy policy"
478+
}
479+
474480
variable "s3_bucket_access_log_bucket_name" {
475481
type = string
476482
default = ""

0 commit comments

Comments
 (0)