input
listlengths 2
2
| ideal
stringclasses 4
values |
|---|---|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nChange module source path to iam-role\r\n\r\n## Motivation and Context\r\nExample was misleading.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role/README.md\n@@ -10,7 +10,7 @@ The defaults provided by the module are suitable for GitHub Free, Pro, & Team, i\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n@@ -33,7 +33,7 @@ For GitHub Enterprise Server, users will need to provide value for the `oidc_aud\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role/README.md\n@@ -10,7 +10,7 @@ The defaults provided by the module are suitable for GitHub Free, Pro, & Team, i\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \n enable_github_oidc = true\n \n@@ -33,7 +33,7 @@ For GitHub Enterprise Server, users will need to provide value for the `oidc_aud\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role/README.md\n@@ -10,7 +10,7 @@ The defaults provided by the module enable_github_oidc suitable for GitHub Free, Pro, & Team, i\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n@@ -33,7 +33,7 @@ For GitHub Enterprise Server, users will need to provide value for the `oidc_aud\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role/README.md\n@@ -10,7 +10,7 @@ The defaults provided by the module are suitable for GitHub Free, Pro, & Team, i\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n@@ -33,7 +33,7 @@ For GitHub Enterprise Server, users will need to provide value for the `oidc_aud\n \n ```hcl\n module \"iam_oidc_role\" {\n- source = \"terraform-aws-modules/iam/aws//modules/iam-oidc-role\"\n+ source users \"terraform-aws-modules/iam/aws//modules/iam-role\"\n \n enable_github_oidc = true\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nAdds an example of an IAM role with an inline policy and demonstrates the need for a trust policy \r\n\r\n## Motivation and Context\r\n\r\nProvides a documented working sample for:\r\n- https://github.com/terraform-aws-modules/terraform-aws-iam/issues/611\r\n- https://github.com/terraform-aws-modules/terraform-aws-iam/issues/612\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nexamples/iam-role/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_iam_role_circleci_oidc\"></a> [iam\\_role\\_circleci\\_oidc](#module\\_iam\\_role\\_circleci\\_oidc) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_disabled\"></a> [iam\\_role\\_disabled](#module\\_iam\\_role\\_disabled) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_github_oidc\"></a> [iam\\_role\\_github\\_oidc](#module\\_iam\\_role\\_github\\_oidc) | ../../modules/iam-role | n/a |\n+| <a name=\"module_iam_role_inline_policy\"></a> [iam\\_role\\_inline\\_policy](#module\\_iam\\_role\\_inline\\_policy) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_instance_profile\"></a> [iam\\_role\\_instance\\_profile](#module\\_iam\\_role\\_instance\\_profile) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_saml\"></a> [iam\\_role\\_saml](#module\\_iam\\_role\\_saml) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_roles\"></a> [iam\\_roles](#module\\_iam\\_roles) | ../../modules/iam-role | n/a |\n@@ -69,6 +70,13 @@ No inputs.\n | <a name=\"output_github_oidc_iam_role_arn\"></a> [github\\_oidc\\_iam\\_role\\_arn](#output\\_github\\_oidc\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n | <a name=\"output_github_oidc_iam_role_name\"></a> [github\\_oidc\\_iam\\_role\\_name](#output\\_github\\_oidc\\_iam\\_role\\_name) | The name of the IAM role |\n | <a name=\"output_github_oidc_iam_role_unique_id\"></a> [github\\_oidc\\_iam\\_role\\_unique\\_id](#output\\_github\\_oidc\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n+| <a name=\"output_inline_policy_iam_instance_profile_arn\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_arn](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n+| <a name=\"output_inline_policy_iam_instance_profile_name\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_name](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_unique_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id) | Stable and unique string identifying the IAM instance profile |\n+| <a name=\"output_inline_policy_iam_role_arn\"></a> [inline\\_policy\\_iam\\_role\\_arn](#output\\_inline\\_policy\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n+| <a name=\"output_inline_policy_iam_role_name\"></a> [inline\\_policy\\_iam\\_role\\_name](#output\\_inline\\_policy\\_iam\\_role\\_name) | The name of the IAM role |\n+| <a name=\"output_inline_policy_iam_role_unique_id\"></a> [inline\\_policy\\_iam\\_role\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n | <a name=\"output_instance_profile_iam_instance_profile_arn\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_arn](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n | <a name=\"output_instance_profile_iam_instance_profile_id\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_id](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n | <a name=\"output_instance_profile_iam_instance_profile_name\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_name](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n---\nexamples/iam-role/main.tf\n@@ -187,6 +187,48 @@ module \"iam_role_saml\" {\n tags = local.tags\n }\n \n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+module \"iam_role_inline_policy\" {\n+ source = \"../../modules/iam-role\"\n+\n+ name = \"${local.name}-inline-policy\"\n+\n+ create_instance_profile = true\n+\n+ trust_policy_permissions = {\n+ ec2 = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+ principals = [{\n+ type = \"Service\"\n+ identifiers = [\"ec2.amazonaws.com\"]\n+ }]\n+ }\n+ }\n+\n+ create_inline_policy = true\n+ inline_policy_permissions = {\n+ S3ReadAccess = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"s3:GetObject\",\n+ \"s3:ListBucket\"\n+ ]\n+ resources = [\n+ \"arn:aws:s3:::example-bucket\",\n+ \"arn:aws:s3:::example-bucket/*\"\n+ ]\n+ }\n+ }\n+\n+ tags = local.tags\n+}\n+\n ################################################################################\n # Supporting resources\n ################################################################################\n---\nexamples/iam-role/outputs.tf\n@@ -153,3 +153,42 @@ output \"saml_iam_instance_profile_unique_id\" {\n description = \"Stable and unique string identifying the IAM instance profile\"\n value = module.iam_role_saml.instance_profile_unique_id\n }\n+\n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+output \"inline_policy_iam_role_name\" {\n+ description = \"The name of the IAM role\"\n+ value = module.iam_role_inline_policy.name\n+}\n+\n+output \"inline_policy_iam_role_arn\" {\n+ description = \"The Amazon Resource Name (ARN) specifying the IAM role\"\n+ value = module.iam_role_inline_policy.arn\n+}\n+\n+output \"inline_policy_iam_role_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM role\"\n+ value = module.iam_role_inline_policy.unique_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_arn\" {\n+ description = \"ARN assigned by AWS to the instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_arn\n+}\n+\n+output \"inline_policy_iam_instance_profile_id\" {\n+ description = \"Instance profile's ID\"\n+ value = module.iam_role_inline_policy.instance_profile_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_name\" {\n+ description = \"Name of IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_name\n+}\n+\n+output \"inline_policy_iam_instance_profile_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_unique_id\n+}\n---\n\n\n---\n\nChoice B:\nexamples/iam-role/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_iam_role_circleci_oidc\"></a> [iam\\_role\\_circleci\\_oidc](#module\\_iam\\_role\\_circleci\\_oidc) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_disabled\"></a> [iam\\_role\\_disabled](#module\\_iam\\_role\\_disabled) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_github_oidc\"></a> [iam\\_role\\_github\\_oidc](#module\\_iam\\_role\\_github\\_oidc) | ../../modules/iam-role | n/a |\n+| <a name=\"module_iam_role_inline_policy\"></a> [iam\\_role\\_inline\\_policy](#module\\_iam\\_role\\_inline\\_policy) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_instance_profile\"></a> [iam\\_role\\_instance\\_profile](#module\\_iam\\_role\\_instance\\_profile) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_saml\"></a> [iam\\_role\\_saml](#module\\_iam\\_role\\_saml) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_roles\"></a> [iam\\_roles](#module\\_iam\\_roles) | ../../modules/iam-role | n/a |\n@@ -69,6 +70,13 @@ No inputs.\n | <a name=\"output_github_oidc_iam_role_arn\"></a> [github\\_oidc\\_iam\\_role\\_arn](#output\\_github\\_oidc\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n | <a name=\"output_github_oidc_iam_role_name\"></a> [github\\_oidc\\_iam\\_role\\_name](#output\\_github\\_oidc\\_iam\\_role\\_name) | The name of the IAM role |\n | <a name=\"output_github_oidc_iam_role_unique_id\"></a> [github\\_oidc\\_iam\\_role\\_unique\\_id](#output\\_github\\_oidc\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n+| <a name=\"output_inline_policy_iam_instance_profile_arn\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_arn](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n+| <a name=\"output_inline_policy_iam_instance_profile_name\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_name](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_unique_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id) | Stable and unique string identifying the IAM instance profile |\n+| <a name=\"output_inline_policy_iam_role_arn\"></a> [inline\\_policy\\_iam\\_role\\_arn](#output\\_inline\\_policy\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n+| <a name=\"output_inline_policy_iam_role_name\"></a> [inline\\_policy\\_iam\\_role\\_name](#output\\_inline\\_policy\\_iam\\_role\\_name) | The name of the IAM role |\n+| <a name=\"output_inline_policy_iam_role_unique_id\"></a> [inline\\_policy\\_iam\\_role\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n | <a name=\"output_instance_profile_iam_instance_profile_arn\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_arn](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n | <a name=\"output_instance_profile_iam_instance_profile_id\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_id](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n | <a name=\"output_instance_profile_iam_instance_profile_name\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_name](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n---\nexamples/iam-role/main.tf\n@@ -187,6 +187,48 @@ module \"iam_role_saml\" {\n tags = local.tags\n }\n \n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+module \"iam_role_inline_policy\" {\n+ source = \"../../modules/iam-role\"\n+\n+ name = \"${local.name}-inline-policy\"\n+\n+ create_instance_profile = true\n+\n+ trust_policy_permissions = {\n+ ec2 = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+ principals = [{\n+ type = \"Service\"\n+ identifiers = [\"ec2.amazonaws.com\"]\n+ }]\n+ }\n+ }\n+\n+ create_inline_policy = true\n+ inline_policy_permissions = {\n+ S3ReadAccess = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"s3:GetObject\",\n+ \"s3:ListBucket\"\n+ ]\n+ resources = [\n+ \"arn:aws:s3:::example-bucket\",\n+ \"arn:aws:s3:::example-bucket/*\"\n+ ]\n+ }\n+ }\n+\n+ tags = local.tags\n+}\n+\n ################################################################################\n # Supporting resources\n ################################################################################\n---\nexamples/iam-role/outputs.tf\n@@ -153,3 +153,42 @@ output \"saml_iam_instance_profile_unique_id\" {\n description = \"Stable and unique string identifying the IAM instance profile\"\n value = module.iam_role_saml.instance_profile_unique_id\n }\n+\n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+output \"inline_policy_iam_role_name\" {\n+ description = \"The name of the IAM role\"\n+ value = module.iam_role_inline_policy.name\n+}\n+\n+output \"inline_policy_iam_role_arn\" {\n+ description = \"The Amazon Resource Name (ARN) specifying the IAM role\"\n+ value = module.iam_role_inline_policy.arn\n+}\n+\n+output \"inline_policy_iam_role_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM role\"\n+ value = module.iam_role_inline_policy.unique_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_arn\" {\n+ description = \"ARN assigned by AWS to the instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_arn\n+}\n+\n+output \"inline_policy_iam_instance_profile_id\" {\n+ description = \"Instance profile's ID\"\n+ value = module.iam_role_inline_policy.instance_profile_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_name\" {\n+ description = \"Name of IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_name\n+}\n+\n+output \"inline_policy_iam_instance_profile_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_unique_id\n+}\n---\n\n\n---\n\nChoice C:\nexamples/iam-role/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_iam_role_circleci_oidc\"></a> [iam\\_role\\_circleci\\_oidc](#module\\_iam\\_role\\_circleci\\_oidc) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_disabled\"></a> [iam\\_role\\_disabled](#module\\_iam\\_role\\_disabled) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_github_oidc\"></a> [iam\\_role\\_github\\_oidc](#module\\_iam\\_role\\_github\\_oidc) | ../../modules/iam-role | n/a |\n+| <a name=\"module_iam_role_inline_policy\"></a> [iam\\_role\\_inline\\_policy](#module\\_iam\\_role\\_inline\\_policy) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_instance_profile\"></a> [iam\\_role\\_instance\\_profile](#module\\_iam\\_role\\_instance\\_profile) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_saml\"></a> [iam\\_role\\_saml](#module\\_iam\\_role\\_saml) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_roles\"></a> [iam\\_roles](#module\\_iam\\_roles) | ../../modules/iam-role | n/a |\n@@ -69,6 +70,13 @@ No inputs.\n | <a name=\"output_github_oidc_iam_role_arn\"></a> [github\\_oidc\\_iam\\_role\\_arn](#output\\_github\\_oidc\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n | <a name=\"output_github_oidc_iam_role_name\"></a> [github\\_oidc\\_iam\\_role\\_name](#output\\_github\\_oidc\\_iam\\_role\\_name) | The name of the IAM role |\n | <a name=\"output_github_oidc_iam_role_unique_id\"></a> [github\\_oidc\\_iam\\_role\\_unique\\_id](#output\\_github\\_oidc\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n+| <a name=\"output_inline_policy_iam_instance_profile_arn\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_arn](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n+| <a name=\"output_inline_policy_iam_instance_profile_name\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_name](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_unique_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id) | Stable and unique string identifying the IAM instance profile |\n+| <a name=\"output_inline_policy_iam_role_arn\"></a> [inline\\_policy\\_iam\\_role\\_arn](#output\\_inline\\_policy\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n+| <a name=\"output_inline_policy_iam_role_name\"></a> [inline\\_policy\\_iam\\_role\\_name](#output\\_inline\\_policy\\_iam\\_role\\_name) | The name of the IAM role |\n+| <a name=\"output_inline_policy_iam_role_unique_id\"></a> [inline\\_policy\\_iam\\_role\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n | <a name=\"output_instance_profile_iam_instance_profile_arn\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_arn](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n | <a name=\"output_instance_profile_iam_instance_profile_id\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_id](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n | <a name=\"output_instance_profile_iam_instance_profile_name\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_name](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n---\nexamples/iam-role/main.tf\n@@ -187,6 +187,48 @@ module \"iam_role_saml\" {\n tags = local.tags\n }\n \n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+module \"iam_role_inline_policy\" {\n+ source = \"../../modules/iam-role\"\n+\n+ name = \"${local.name}-inline-policy\"\n+\n+ | create_instance_profile = true\n+\n+ trust_policy_permissions = {\n+ ec2 = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+ principals = [{\n+ type = \"Service\"\n+ identifiers = [\"ec2.amazonaws.com\"]\n+ }]\n+ }\n+ }\n+\n+ create_inline_policy = true\n+ inline_policy_permissions = {\n+ S3ReadAccess = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"s3:GetObject\",\n+ \"s3:ListBucket\"\n+ ]\n+ resources = [\n+ \"arn:aws:s3:::example-bucket\",\n+ \"arn:aws:s3:::example-bucket/*\"\n+ ]\n+ }\n+ }\n+\n+ tags = local.tags\n+}\n+\n ################################################################################\n # Supporting resources\n ################################################################################\n---\nexamples/iam-role/outputs.tf\n@@ -153,3 +153,42 @@ output \"saml_iam_instance_profile_unique_id\" {\n description = \"Stable and unique string identifying the IAM instance profile\"\n value = module.iam_role_saml.instance_profile_unique_id\n }\n+\n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+output \"inline_policy_iam_role_name\" {\n+ description = \"The name of the IAM role\"\n+ value = module.iam_role_inline_policy.name\n+}\n+\n+output \"inline_policy_iam_role_arn\" {\n+ description = \"The Amazon Resource Name (ARN) specifying the IAM role\"\n+ value = module.iam_role_inline_policy.arn\n+}\n+\n+output \"inline_policy_iam_role_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM role\"\n+ value = module.iam_role_inline_policy.unique_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_arn\" {\n+ description = \"ARN assigned by AWS to the instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_arn\n+}\n+\n+output \"inline_policy_iam_instance_profile_id\" {\n+ description = \"Instance profile's ID\"\n+ value = module.iam_role_inline_policy.instance_profile_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_name\" {\n+ description = \"Name of IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_name\n+}\n+\n+output \"inline_policy_iam_instance_profile_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_unique_id\n+}\n---\n\n\n---\n\nChoice D:\nexamples/iam-role/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_iam_role_circleci_oidc\"></a> [iam\\_role\\_circleci\\_oidc](#module\\_iam\\_role\\_circleci\\_oidc) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_disabled\"></a> [iam\\_role\\_disabled](#module\\_iam\\_role\\_disabled) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_github_oidc\"></a> [iam\\_role\\_github\\_oidc](#module\\_iam\\_role\\_github\\_oidc) | ../../modules/iam-role | n/a |\n+| <a name=\"module_iam_role_inline_policy\"></a> [iam\\_role\\_inline\\_policy](#module\\_iam\\_role\\_inline\\_policy) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_instance_profile\"></a> [iam\\_role\\_instance\\_profile](#module\\_iam\\_role\\_instance\\_profile) | ../../modules/iam-role | n/a |\n | <a name=\"module_iam_role_saml\"></a> [iam\\_role\\_saml](#module\\_iam\\_role\\_saml) | ../../modules/iam-role | n/a | <a name=\"module_iam_roles\"></a> [iam\\_roles](#module\\_iam\\_roles) | ../../modules/iam-role | n/a |\n@@ -69,6 +70,13 @@ No inputs.\n | <a name=\"output_github_oidc_iam_role_arn\"></a> [github\\_oidc\\_iam\\_role\\_arn](#output\\_github\\_oidc\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n | <a name=\"output_github_oidc_iam_role_name\"></a> [github\\_oidc\\_iam\\_role\\_name](#output\\_github\\_oidc\\_iam\\_role\\_name) | The name of the IAM role |\n | <a name=\"output_github_oidc_iam_role_unique_id\"></a> [github\\_oidc\\_iam\\_role\\_unique\\_id](#output\\_github\\_oidc\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n+| <a name=\"output_inline_policy_iam_instance_profile_arn\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_arn](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n+| <a name=\"output_inline_policy_iam_instance_profile_name\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_name](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n+| <a name=\"output_inline_policy_iam_instance_profile_unique_id\"></a> [inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_instance\\_profile\\_unique\\_id) | Stable and unique string identifying the IAM instance profile |\n+| <a name=\"output_inline_policy_iam_role_arn\"></a> [inline\\_policy\\_iam\\_role\\_arn](#output\\_inline\\_policy\\_iam\\_role\\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |\n+| <a name=\"output_inline_policy_iam_role_name\"></a> [inline\\_policy\\_iam\\_role\\_name](#output\\_inline\\_policy\\_iam\\_role\\_name) | The name of the IAM role |\n+| <a name=\"output_inline_policy_iam_role_unique_id\"></a> [inline\\_policy\\_iam\\_role\\_unique\\_id](#output\\_inline\\_policy\\_iam\\_role\\_unique\\_id) | Stable and unique string identifying the IAM role |\n | <a name=\"output_instance_profile_iam_instance_profile_arn\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_arn](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_arn) | ARN assigned by AWS to the instance profile |\n | <a name=\"output_instance_profile_iam_instance_profile_id\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_id](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_id) | Instance profile's ID |\n | <a name=\"output_instance_profile_iam_instance_profile_name\"></a> [instance\\_profile\\_iam\\_instance\\_profile\\_name](#output\\_instance\\_profile\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n---\nexamples/iam-role/main.tf\n@@ -187,6 +187,48 @@ module \"iam_role_saml\" {\n tags = local.tags\n }\n \n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+module \"iam_role_inline_policy\" {\n+ source = \"../../modules/iam-role\"\n+\n+ name = \"${local.name}-inline-policy\"\n+\n+ create_instance_profile = true\n+\n+ trust_policy_permissions = {\n+ ec2 = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+ principals = [{\n+ type = \"Service\"\n+ identifiers = [\"ec2.amazonaws.com\"]\n+ }]\n+ }\n+ }\n+\n+ create_inline_policy = true\n+ inline_policy_permissions = {\n+ S3ReadAccess = {\n+ effect = \"Allow\"\n+ actions = [\n+ \"s3:GetObject\",\n+ \"s3:ListBucket\"\n+ ]\n+ resources = [\n+ \"arn:aws:s3:::example-bucket\",\n+ \"arn:aws:s3:::example-bucket/*\"\n+ ]\n+ }\n+ }\n+\n+ tags = local.tags\n+}\n+\n ################################################################################\n # Supporting resources\n ################################################################################\n---\nexamples/iam-role/outputs.tf\n@@ -153,3 +153,42 @@ output \"saml_iam_instance_profile_unique_id\" {\n description = \"Stable and unique string identifying the IAM instance profile\"\n value = module.iam_role_saml.instance_profile_unique_id\n }\n+\n+################################################################################\n+# IAM Role - Inline Policy\n+################################################################################\n+\n+output \"inline_policy_iam_role_name\" {\n+ description = \"The name of the IAM role\"\n+ value = module.iam_role_inline_policy.name\n+}\n+\n+output \"inline_policy_iam_role_arn\" {\n+ description = \"The Amazon Resource Name (ARN) specifying the IAM role\"\n+ value = module.iam_role_inline_policy.arn\n+}\n+\n+output \"inline_policy_iam_role_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM role\"\n+ value = module.iam_role_inline_policy.unique_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_arn\" {\n+ description = \"ARN assigned by AWS to the instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_arn\n+}\n+\n+output \"inline_policy_iam_instance_profile_id\" {\n+ description = \"Instance profile's ID\"\n+ value = module.iam_role_inline_policy.instance_profile_id\n+}\n+\n+output \"inline_policy_iam_instance_profile_name\" {\n+ description = \"Name of IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_name\n+}\n+\n+output \"inline_policy_iam_instance_profile_unique_id\" {\n+ description = \"Stable and unique string identifying the IAM instance profile\"\n+ value = module.iam_role_inline_policy.instance_profile_unique_id\n+}\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nChanges the IAM User example to use camel case \r\n\r\n## Motivation and Context\r\nfor this observed Malformed Document error\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/612\r\n\r\n## Breaking Changes\r\nNo, only modifies examples\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n \"iam_user2\" actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\n\n\n---\n\nChoice B:\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\n\n\n---\n\nChoice C:\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\n\n\n---\n\nChoice D:\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n- Correct examples\r\n\r\n## Motivation and Context\r\n- Resolves #612\r\n- Closes #614\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nREADME.md\n@@ -150,6 +150,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\nexamples/iam-role/main.tf\n@@ -46,6 +46,10 @@ module \"iam_roles\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = each.value.trusted_arns\n@@ -90,6 +94,10 @@ module \"iam_role_instance_profile\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [\n {\n type = \"AWS\"\n---\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\nmodules/iam-role/README.md\n@@ -63,6 +63,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -150,6 +150,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\nexamples/iam-role/main.tf\n@@ -46,6 +46,10 @@ module \"iam_roles\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = each.value.trusted_arns\n@@ -90,6 +94,10 @@ \"iam_role_instance_profile\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [\n {\n type = \"AWS\"\n---\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\nmodules/iam-role/README.md\n@@ -63,6 +63,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -150,6 +150,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\nexamples/iam-role/main.tf\n@@ -46,6 +46,10 module \"iam_roles\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = each.value.trusted_arns\n@@ -90,6 +94,10 @@ module \"iam_role_instance_profile\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [\n {\n type = \"AWS\"\n---\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\nmodules/iam-role/README.md\n@@ -63,6 +63,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -150,6 +150,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\nexamples/iam-role/main.tf\n@@ -46,6 +46,10 @@ module \"iam_roles\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = each.value.trusted_arns\n@@ -90,6 +94,10 @@ module \"iam_role_instance_profile\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [\n {\n type = \"AWS\"\n---\nexamples/iam-user/main.tf\n@@ -47,7 +47,7 @@ module \"iam_user2\" {\n \n create_inline_policy = true\n inline_policy_permissions = {\n- s3_read_access = {\n+ S3ReadAccess = {\n effect = \"Allow\"\n actions = [\n \"s3:GetObject\",\n@@ -58,7 +58,7 @@ module \"iam_user2\" {\n \"arn:aws:s3:::example-bucket/*\"\n ]\n }\n- cloudwatch_logs = {\n+ CloudwatchLogs = {\n effect = \"Allow\"\n actions = [\n \"logs:CreateLogGroup\",\n---\nmodules/iam-role/README.md\n@@ -63,6 +63,10 @@ module \"iam_role\" {\n \n trust_policy_permissions = {\n TrustRoleAndServiceToAssume = {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ \"sts:TagSession\",\n+ ]\n principals = [{\n type = \"AWS\"\n identifiers = [\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n- Correct `iam-group` variable name mis-spelling\r\n\r\n## Motivation and Context\r\n- Resolves #608\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\ndocs/UPGRADE-6.0.md\n@@ -134,7 +134,7 @@ stateDiagram\n - None\n - `iam-group`\n - `create_group` -> `create`\n- - `group_users` -> `group`\n+ - `group_users` -> `users`\n - `custom_group_policy_arns` -> `policies`\n - `attach_iam_self_management_policy` -> `create_policy`\n - `iam_self_management_policy_name_prefix` -> `policy_name_prefix`\n---\nmodules/iam-group/README.md\n@@ -72,7 +72,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create IAM policy for IAM group | `bool` | `true` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_enable_self_management_permissions\"></a> [enable\\_self\\_management\\_permissions](#input\\_enable\\_self\\_management\\_permissions) | Determines whether permissions are added to the policy which allow the groups IAM users to manage their credentials and MFA | `bool` | `true` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: `=,.@-_.` | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path in which to create the group | `string` | `null` | no |\n---\nmodules/iam-group/main.tf\n@@ -171,7 +171,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_self_management_permissions && var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_self_management_permissions && var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group/variables.tf\n@@ -48,7 +48,7 @@ variable \"enable_self_management_permissions\" {\n default = true\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group/main.tf\n@@ -5,7 +5,7 @@ module \"wrapper\" {\n \n create = try(each.value.create, var.defaults.create, true)\n create_policy = try(each.value.create_policy, var.defaults.create_policy, true)\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n enable_self_management_permissions = try(each.value.enable_self_management_permissions, var.defaults.enable_self_management_permissions, true)\n name = try(each.value.name, var.defaults.name, \"\")\n path = try(each.value.path, var.defaults.path, null)\n---\n\n\n---\n\nChoice B:\ndocs/UPGRADE-6.0.md\n@@ -134,7 +134,7 @@ stateDiagram\n - None\n - `iam-group`\n - `create_group` -> `create`\n- - `group_users` -> `group`\n+ - `group_users` -> `users`\n - `custom_group_policy_arns` -> `policies`\n - `attach_iam_self_management_policy` -> `create_policy`\n - `iam_self_management_policy_name_prefix` -> `policy_name_prefix`\n---\nmodules/iam-group/README.md\n@@ -72,7 +72,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create IAM policy for IAM group | `bool` | `true` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_enable_self_management_permissions\"></a> [enable\\_self\\_management\\_permissions](#input\\_enable\\_self\\_management\\_permissions) | Determines whether permissions are added to the policy which allow the groups IAM users to manage their credentials and MFA | `bool` | `true` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: `=,.@-_.` | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path in which to create the group | `string` | `null` | no |\n---\nmodules/iam-group/main.tf\n@@ -171,7 +171,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_self_management_permissions && var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_self_management_permissions && var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group/variables.tf\n@@ -48,7 +48,7 @@ variable \"enable_self_management_permissions\" {\n default = true\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group/main.tf\n@@ -5,7 +5,7 @@ module \"wrapper\" {\n \n create = try(each.value.create, var.defaults.create, true)\n create_policy = try(each.value.create_policy, var.defaults.create_policy, true)\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n enable_self_management_permissions = try(each.value.enable_self_management_permissions, var.defaults.enable_self_management_permissions, true)\n name = try(each.value.name, var.defaults.name, \"\")\n path = try(each.value.path, var.defaults.path, null)\n---\n\n\n---\n\nChoice C:\ndocs/UPGRADE-6.0.md\n@@ -134,7 +134,7 @@ stateDiagram\n - None\n - `iam-group`\n - `create_group` -> `create`\n- - `group_users` -> `group`\n+ - `group_users` -> `users`\n - `custom_group_policy_arns` -> `policies`\n - `attach_iam_self_management_policy` -> `create_policy`\n - `iam_self_management_policy_name_prefix` -> `policy_name_prefix`\n---\nmodules/iam-group/README.md\n@@ -72,7 +72,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create IAM policy for IAM group | `bool` | `true` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_enable_self_management_permissions\"></a> [enable\\_self\\_management\\_permissions](#input\\_enable\\_self\\_management\\_permissions) | Determines whether permissions are added to the policy which allow the groups IAM users to manage their credentials and MFA | `bool` | `true` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: `=,.@-_.` | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path in which to create the group | `string` | `null` | no |\n---\nmodules/iam-group/main.tf\n@@ -171,7 +171,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_self_management_permissions && var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_self_management_permissions && var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group/variables.tf\n@@ -48,7 +48,7 @@ variable \"enable_self_management_permissions\" {\n default = true\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group/main.tf\n@@ -5,7 +5,7 @@ module \"wrapper\" {\n \n create = \n var.defaults.create, true)\n create_policy = try(each.value.create_policy, var.defaults.create_policy, true)\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n enable_self_management_permissions = try(each.value.enable_self_management_permissions, var.defaults.enable_self_management_permissions, true)\n name = try(each.value.name, var.defaults.name, \"\")\n path = try(each.value.path, var.defaults.path, null)\n---\n\n\n---\n\nChoice D:\ndocs/UPGRADE-6.0.md\n@@ -134,7 +134,7 @@ stateDiagram\n - None\n - `iam-group`\n - `create_group` -> `create`\n- - `group_users` -> `group`\n+ - `group_users` -> `users`\n - `custom_group_policy_arns` -> `policies`\n - `attach_iam_self_management_policy` -> `create_policy`\n - `iam_self_management_policy_name_prefix` -> `policy_name_prefix`\n---\nmodules/iam-group/README.md\n@@ -72,7 +72,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create IAM policy for IAM group | `bool` | `true` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_enable_self_management_permissions\"></a> [enable\\_self\\_management\\_permissions](#input\\_enable\\_self\\_management\\_permissions) | Determines whether permissions are added to the policy which allow the groups IAM users to manage their credentials and MFA | `bool` | `true` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: `=,.@-_.` | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path in which to create the group | `string` | `null` | no |\n---\nmodules/iam-group/main.tf\n@@ -171,7 +171,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_self_management_permissions && var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_self_management_permissions && var.enable_mfa_enforcement ? [1] : []\n \n content {\n @@ sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group/variables.tf\n@@ -48,7 +48,7 @@ variable \"enable_self_management_permissions\" {\n default = true\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group/main.tf\n@@ -5,7 +5,7 @@ module \"wrapper\" {\n \n create = try(each.value.create, var.defaults.create, true)\n create_policy = try(each.value.create_policy, var.defaults.create_policy, true)\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n enable_self_management_permissions = try(each.value.enable_self_management_permissions, var.defaults.enable_self_management_permissions, true)\n name = try(each.value.name, var.defaults.name, \"\")\n path = try(each.value.path, var.defaults.path, null)\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\n- Adding a check for local.bitbucket_provider to check for provider url only when enable_bitbucket_oidc is enabled.\r\n- Fix for issue https://github.com/terraform-aws-modules/terraform-aws-iam/issues/604\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nIn the 6.x version of the module, when oidc_provider_urls has multiple provider urls a bitbucket check fails and prevents plan for other generic providers as well.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n= -10,7 +10,7 @@ locals {\n partition = try(data.aws_partition.current[0].partition, \"\")\n \n oidc_providers = [for url in var.oidc_provider_urls : replace(url, \"https://\", \"\")]\n- bitbucket_provider = one(local.oidc_providers)\n+ bitbucket_provider = try(element(local.oidc_providers, 0), null)\n }\n \n ################################################################################\n---\n\n\n---\n\nChoice B:\nmodules/iam-role/main.tf\n@@ -10,7 +10,7 @@ locals {\n partition = try(data.aws_partition.current[0].partition, \"\")\n \n oidc_providers = [for url in : replace(url, \"https://\", \"\")]\n- bitbucket_provider = one(local.oidc_providers)\n+ bitbucket_provider = try(element(local.oidc_providers, 0), null)\n }\n \n ################################################################################\n---\n\n\n---\n\nChoice C:\nmodules/iam-role/main.tf\n@@ -10,7 +10,7 @@ locals {\n partition = try(data.aws_partition.current[0].partition, \"\")\n \n oidc_providers = [for url in var.oidc_provider_urls : replace(url, \"https://\", [for bitbucket_provider = one(local.oidc_providers)\n+ bitbucket_provider = try(element(local.oidc_providers, 0), null)\n }\n \n ################################################################################\n---\n\n\n---\n\nChoice D:\nmodules/iam-role/main.tf\n@@ -10,7 +10,7 @@ locals {\n partition = try(data.aws_partition.current[0].partition, \"\")\n \n oidc_providers = [for url in var.oidc_provider_urls : replace(url, \"https://\", \"\")]\n- bitbucket_provider = one(local.oidc_providers)\n+ bitbucket_provider = try(element(local.oidc_providers, 0), null)\n }\n \n ################################################################################\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nSmall fix to the `iam-role-for-service-accounts` module README to account for v6 changes.\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts/README.md\n@@ -89,7 +89,7 @@ module \"eks\" {\n addons = {\n = coredns = {}\n aws-ebs-csi-driver = {\n- service_account_role_arn = module.ebs_csi_driver_irsa.iam_role_arn\n+ service_account_role_arn = module.ebs_csi_driver_irsa.arn\n }\n kube-proxy = {}\n vpc-cni = {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts/README.md\n@@ -89,7 +89,7 @@ module \"eks\" {\n addons = {\n coredns = {}\n aws-ebs-csi-driver = {\n- service_account_role_arn = module.ebs_csi_driver_irsa.iam_role_arn\n+ service_account_role_arn = module.ebs_csi_driver_irsa.arn\n }\n = kube-proxy = {}\n vpc-cni = {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts/README.md\n@@ -89,7 +89,7 @@ module \"eks\" {\n addons = {\n coredns = {}\n aws-ebs-csi-driver = {\n- service_account_role_arn = module.ebs_csi_driver_irsa.iam_role_arn\n+ service_account_role_arn = module.ebs_csi_driver_irsa.arn\n }\n kube-proxy = {}\n vpc-cni = {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts/README.md\n@@ -89,7 +89,7 module \"eks\" {\n addons = {\n coredns = {}\n aws-ebs-csi-driver = {\n- service_account_role_arn = module.ebs_csi_driver_irsa.iam_role_arn\n+ service_account_role_arn = module.ebs_csi_driver_irsa.arn\n }\n kube-proxy = {}\n vpc-cni = {\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nApplies the same dynamic trick to the secretsmanager part of the external secrets role policy, so that if we don't grant access to any secrets we don't end up with an apply error.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nWithout supplying any values for `var.external_secrets_secrets_manager_arns` we end up with a policy statement like this:\r\n```\r\n + {\r\n + Action = [\r\n + \"secretsmanager:ListSecretVersionIds\",\r\n + \"secretsmanager:GetSecretValue\",\r\n + \"secretsmanager:GetResourcePolicy\",\r\n + \"secretsmanager:DescribeSecret\",\r\n ]\r\n + Effect = \"Allow\"\r\n },\r\n```\r\nThis is invalid since it lacks resources and cannot be applied.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNo breaking change.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\nIt's such a trivial change I don't believe these are necessary but can circle back to these if you like.\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts/policies.tf\n@@ -483,14 +483,19 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"secretsmanager:GetResourcePolicy\",\n- \"secretsmanager:GetSecretValue\",\n- \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\"\n- ]\n- resources = var.external_secrets_secrets_manager_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_secrets_manager_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"secretsmanager:GetResourcePolicy\",\n+ \"secretsmanager:GetSecretValue\",\n+ \"secretsmanager:DescribeSecret\",\n+ \"secretsmanager:ListSecretVersionIds\"\n+ ]\n+\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n }\n \n dynamic \"statement\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts/policies.tf\n@@ -483,14 +483,19 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"secretsmanager:GetResourcePolicy\",\n- \"secretsmanager:GetSecretValue\",\n- \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\"\n- ]\n- resources = var.external_secrets_secrets_manager_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_secrets_manager_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"secretsmanager:GetResourcePolicy\",\n+ \"secretsmanager:GetSecretValue\",\n+ > \"secretsmanager:DescribeSecret\",\n+ \"secretsmanager:ListSecretVersionIds\"\n+ ]\n+\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n }\n \n dynamic \"statement\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts/policies.tf\n@@ -483,14 +483,19 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"secretsmanager:GetResourcePolicy\",\n- \"secretsmanager:GetSecretValue\",\n- \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\"\n- ]\n- resources = var.external_secrets_secrets_manager_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_secrets_manager_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"secretsmanager:GetResourcePolicy\",\n+ \"secretsmanager:GetSecretValue\",\n+ \"secretsmanager:DescribeSecret\",\n+ \"secretsmanager:ListSecretVersionIds\"\n+ ]\n+\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n }\n \n dynamic \"statement\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts/policies.tf\n@@ -483,14 +483,19 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"secretsmanager:GetResourcePolicy\",\n- \"secretsmanager:GetSecretValue\",\n- \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\"\n- ]\n- resources = var.external_secrets_secrets_manager_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_secrets_manager_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"secretsmanager:GetResourcePolicy\",\n+ \"secretsmanager:GetSecretValue\",\n+ \"secretsmanager:DescribeSecret\",\n+ \"secretsmanager:ListSecretVersionIds\"\n+ ]\n+\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n }\n \n dynamic \"statement\" {\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-oidc-provider/README.md\n@@ -70,7 +70,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n+| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n---\nmodules/iam-oidc-provider/variables.tf\n@@ -15,7 +15,7 @@ variable \"tags\" {\n ################################################################################\n \n variable \"client_id_list\" {\n- description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided\"\n+ (also description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided\"\n type = list(string)\n default = []\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-oidc-provider/README.md\n@@ -70,7 +70,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n+| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC | Defaults to STS service if no values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n---\nmodules/iam-oidc-provider/variables.tf\n@@ -15,7 +15,7 @@ variable \"tags\" {\n ################################################################################\n \n variable \"client_id_list\" {\n- description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided\"\n+ description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided\"\n type = list(string)\n default = []\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-oidc-provider/README.md\n@@ -70,7 +70,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n+| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n---\nmodules/iam-oidc-provider/variables.tf\n@@ -15,7 +15,7 @@ variable \"tags\" {\n ################################################################################\n \n variable \"client_id_list\" {\n- description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided\"\n+ description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided\"\n type for = list(string)\n default = []\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-oidc-provider/README.md\n@@ -70,7 +70,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n+| <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n---\nmodules/iam-oidc-provider/variables.tf\n@@ -15,7 +15,7 @@ variable \"tags\" {\n ################################################################################\n \n variable \"client_id_list\" {\n- description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided\"\n+ description = \"List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if no values are provided\"\n type = list(string)\n default = []\n }\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nReplace the incorrect resource type aws_iam_role_policy_attachment with aws_iam_user_policy_attachment.\r\n\r\nUpdate arguments accordingly (role -> user) so attachments target the created IAM user (aws_iam_user.this[0].name).\r\n\r\nNo changes to input variables: var.policies remains a map and the for_each logic is unchanged.\r\n\r\n## Motivation and Context\r\nThe previous implementation attempted to attach policies using the role attachment resource for an IAM user, which is invalid.\r\n\r\n## Breaking Changes\r\nResource address change: from aws_iam_role_policy_attachment.additional to aws_iam_user_policy_attachment.additional.\r\nTerraform will plan to replace these attachment resources on the next apply (destroy old, create new).\r\n\r\nImpact: Brief re‑creation of policy attachments during apply. No persistent permission loss is expected.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k resource v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource Type | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | v | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n- Add default IRSA policy name for canned policies if a more specific name is not provided\r\n- Fix incorrect policy attachment for `iam-user`\r\n\r\n## Motivation and Context\r\n- Resolves #593\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts/main.tf\n@@ -25,6 +25,28 @@ locals {\n var.attach_velero_policy ? \"Provides Velero permissions to backup and restore cluster resources\" : null,\n var.attach_vpc_cni_policy ? \"Provides the Amazon VPC CNI Plugin (amazon-vpc-cni-k8s) the each.value\n it requires to modify the IPv4/IPv6 address configuration on your EKS worker nodes\" : null,\n ), null)\n+\n+ policy_name = try(coalesce(\n+ var.policy_name,\n+ var.attach_aws_gateway_controller_policy ? \"AWS_Gateway_Controller\" : null,\n+ var.attach_cert_manager_policy ? \"Cert_Manager\" : null,\n+ var.attach_cluster_autoscaler_policy ? \"Cluster_Autoscaler\" : null,\n+ var.attach_ebs_csi_policy ? \"EBS_CSI\" : null,\n+ var.attach_efs_csi_policy ? \"EFS_CSI\" : null,\n+ var.attach_mountpoint_s3_csi_policy ? \"Mountpoint_S3_CSI\" : null,\n+ var.attach_external_dns_policy ? \"External_DNS\" : null,\n+ var.attach_external_secrets_policy ? \"External_Secrets\" : null,\n+ var.attach_fsx_lustre_csi_policy ? \"FSX_Lustre_CSI\" : null,\n+ var.attach_fsx_openzfs_csi_policy ? \"FSX_OpenZFS_CSI\" : null,\n+ var.attach_load_balancer_controller_policy ? \"AWS_Load_Balancer_Controller\" : null,\n+ var.attach_load_balancer_controller_targetgroup_binding_only_policy ? \"AWS_LBC_TargetGroup_Binding_Only\" : null,\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Amazon_Managed_Service_Prometheus\" : null,\n+ var.attach_node_termination_handler_policy ? \"Node_Termination_Handler\" : null,\n+ var.attach_velero_policy ? \"Velero\" : null,\n+ var.attach_vpc_cni_policy ? \"VPC_CNI_${var.vpc_cni_enable_ipv4 ? \"IPv4\" : \"IPv6\"}\" : null,\n+ var.name,\n+ \"default\"\n+ ))\n }\n \n ################################################################################\n@@ -161,10 +183,6 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n }\n \n-locals {\n- policy_name = try(coalesce(var.policy_name, var.name), \"\")\n-}\n-\n resource \"aws_iam_policy\" \"this\" {\n count = local.create_policy ? 1 : 0\n \n---\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts/main.tf\n@@ -25,6 +25,28 @@ locals {\n var.attach_velero_policy ? \"Provides Velero permissions to backup and restore cluster resources\" : null,\n var.attach_vpc_cni_policy ? \"Provides the Amazon VPC CNI Plugin (amazon-vpc-cni-k8s) the permissions it requires to modify the IPv4/IPv6 address configuration on your EKS worker nodes\" : null,\n ), null)\n+\n+ policy_name = try(coalesce(\n+ var.policy_name,\n+ var.attach_aws_gateway_controller_policy ? \"AWS_Gateway_Controller\" : null,\n+ var.attach_cert_manager_policy ? \"Cert_Manager\" : null,\n+ var.attach_cluster_autoscaler_policy ? \"Cluster_Autoscaler\" : null,\n+ var.attach_ebs_csi_policy ? \"EBS_CSI\" : null,\n+ var.attach_efs_csi_policy ? \"EFS_CSI\" : null,\n+ var.attach_mountpoint_s3_csi_policy ? \"Mountpoint_S3_CSI\" : null,\n+ var.attach_external_dns_policy ? \"External_DNS\" : null,\n+ var.attach_external_secrets_policy ? \"External_Secrets\" : null,\n+ var.attach_fsx_lustre_csi_policy ? \"FSX_Lustre_CSI\" : null,\n+ var.attach_fsx_openzfs_csi_policy ? \"FSX_OpenZFS_CSI\" : null,\n+ var.attach_load_balancer_controller_policy ? \"AWS_Load_Balancer_Controller\" : null,\n+ var.attach_load_balancer_controller_targetgroup_binding_only_policy ? \"AWS_LBC_TargetGroup_Binding_Only\" : null,\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Amazon_Managed_Service_Prometheus\" : null,\n+ var.attach_node_termination_handler_policy ? \"Node_Termination_Handler\" : null,\n+ var.attach_velero_policy ? \"Velero\" : null,\n+ var.attach_vpc_cni_policy ? \"VPC_CNI_${var.vpc_cni_enable_ipv4 ? \"IPv4\" : \"IPv6\"}\" : null,\n+ var.name,\n+ \"default\"\n+ ))\n }\n \n ################################################################################\n@@ -161,10 +183,6 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n }\n \n-locals {\n- policy_name = try(coalesce(var.policy_name, var.name), \"\")\n-}\n-\n resource \"aws_iam_policy\" \"this\" {\n count = local.create_policy ? 1 : 0\n \n---\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts/main.tf\n@@ -25,6 +25,28 @@ locals {\n var.attach_velero_policy ? \"Provides Velero permissions to backup and restore cluster resources\" : null,\n var.attach_vpc_cni_policy ? \"Provides the Amazon VPC CNI Plugin (amazon-vpc-cni-k8s) the permissions it requires to modify the IPv4/IPv6 address configuration on your EKS worker nodes\" : null,\n ), null)\n+\n+ policy_name = try(coalesce(\n+ var.policy_name,\n+ var.attach_aws_gateway_controller_policy ? \"AWS_Gateway_Controller\" : null,\n+ var.attach_cert_manager_policy ? \"Cert_Manager\" : null,\n+ var.attach_cluster_autoscaler_policy ? \"Cluster_Autoscaler\" : null,\n+ var.attach_ebs_csi_policy ? \"EBS_CSI\" : null,\n+ var.attach_efs_csi_policy ? \"EFS_CSI\" : null,\n+ user var.attach_mountpoint_s3_csi_policy ? \"Mountpoint_S3_CSI\" : null,\n+ var.attach_external_dns_policy ? \"External_DNS\" : null,\n+ var.attach_external_secrets_policy ? \"External_Secrets\" : null,\n+ var.attach_fsx_lustre_csi_policy ? \"FSX_Lustre_CSI\" : null,\n+ var.attach_fsx_openzfs_csi_policy ? \"FSX_OpenZFS_CSI\" : null,\n+ var.attach_load_balancer_controller_policy ? \"AWS_Load_Balancer_Controller\" : null,\n+ var.attach_load_balancer_controller_targetgroup_binding_only_policy ? \"AWS_LBC_TargetGroup_Binding_Only\" : null,\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Amazon_Managed_Service_Prometheus\" : null,\n+ var.attach_node_termination_handler_policy ? \"Node_Termination_Handler\" : null,\n+ var.attach_velero_policy ? \"Velero\" : null,\n+ var.attach_vpc_cni_policy ? \"VPC_CNI_${var.vpc_cni_enable_ipv4 ? \"IPv4\" : \"IPv6\"}\" : null,\n+ var.name,\n+ \"default\"\n+ ))\n }\n \n ################################################################################\n@@ -161,10 +183,6 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n }\n \n-locals {\n- policy_name = try(coalesce(var.policy_name, var.name), \"\")\n-}\n-\n resource \"aws_iam_policy\" \"this\" {\n count = local.create_policy ? 1 : 0\n \n---\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts/main.tf\n@@ -25,6 +25,28 @@ locals {\n var.attach_velero_policy ? \"Provides Velero permissions to backup and restore cluster resources\" : null,\n var.attach_vpc_cni_policy ? \"Provides the Amazon VPC CNI Plugin (amazon-vpc-cni-k8s) the permissions it requires to modify the IPv4/IPv6 address configuration on your EKS worker nodes\" : null,\n ), null)\n+\n+ policy_name = try(coalesce(\n+ var.policy_name,\n+ var.attach_aws_gateway_controller_policy ? \"AWS_Gateway_Controller\" : null,\n+ var.attach_cert_manager_policy ? \"Cert_Manager\" : null,\n+ var.attach_cluster_autoscaler_policy ? \"Cluster_Autoscaler\" : null,\n+ var.attach_ebs_csi_policy ? \"EBS_CSI\" : null,\n+ var.attach_efs_csi_policy ? \"EFS_CSI\" : null,\n+ var.attach_mountpoint_s3_csi_policy ? \"Mountpoint_S3_CSI\" : null,\n+ var.attach_external_dns_policy ? \"External_DNS\" : null,\n+ var.attach_external_secrets_policy ? \"External_Secrets\" : null,\n+ var.attach_fsx_lustre_csi_policy ? \"FSX_Lustre_CSI\" : null,\n+ var.attach_fsx_openzfs_csi_policy ? \"FSX_OpenZFS_CSI\" : null,\n+ var.attach_load_balancer_controller_policy ? \"AWS_Load_Balancer_Controller\" : null,\n+ var.attach_load_balancer_controller_targetgroup_binding_only_policy ? \"AWS_LBC_TargetGroup_Binding_Only\" : null,\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Amazon_Managed_Service_Prometheus\" : null,\n+ var.attach_node_termination_handler_policy ? \"Node_Termination_Handler\" : null,\n+ var.attach_velero_policy ? \"Velero\" : null,\n+ var.attach_vpc_cni_policy ? \"VPC_CNI_${var.vpc_cni_enable_ipv4 ? \"IPv4\" : \"IPv6\"}\" : null,\n+ var.name,\n+ \"default\"\n+ ))\n }\n \n ################################################################################\n@@ -161,10 +183,6 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n }\n \n-locals {\n- policy_name = try(coalesce(var.policy_name, var.name), \"\")\n-}\n-\n resource \"aws_iam_policy\" \"this\" {\n count = local.create_policy ? 1 : 0\n \n---\nmodules/iam-user/README.md\n@@ -50,9 +50,9 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n-| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n---\nmodules/iam-user/main.tf\n@@ -13,10 +13,10 @@ resource \"aws_iam_user\" \"this\" {\n tags = var.tags\n }\n \n-resource \"aws_iam_role_policy_attachment\" \"additional\" {\n+resource \"aws_iam_user_policy_attachment\" \"additional\" {\n for_each = { for k, v in var.policies : k => v if var.create }\n \n- role = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n policy_arn = each.value\n }\n \n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nThere seems to have been a copy-paste mistake in the migrations where `aws_iam_policy` type has been used as the \"to\" for `aws_iam_role_policy_attachment` resources.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nWe are seeing the following error:\r\n```\r\n│ Error: Move Resource State Not Supported\r\n│ \r\n│ The \"aws_iam_policy\" resource type does not support moving resource state\r\n│ across resource types.\r\n```\r\nEdit: This does not solve #586 as that is related to the change of merging all the policies into a single resource being a breaking change\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = \n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # \n -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nFix migration moved blocks\r\n\r\n## Motivation and Context\r\nIt should fix https://github.com/terraform-aws-modules/terraform-aws-iam/issues/586\r\n\r\n## Breaking Changes\r\nYes because the current major version will lead to https://github.com/terraform-aws-modules/terraform-aws-iam/issues/586 for users who upgrade from v5 to v6.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to # = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts/migrations.tf\n@@ -10,7 +10,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.aws_gateway_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cert Manager\n@@ -21,7 +21,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cert_manager\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Cluster Autoscaler\n@@ -32,7 +32,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.cluster_autoscaler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EBS CSI\n@@ -43,7 +43,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.ebs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # EFS CSI\n@@ -54,7 +54,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.efs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Mountpoint S3 CSI\n@@ -65,7 +65,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.mountpoint_s3_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External DNS\n@@ -76,7 +76,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_dns\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # External Secrets\n@@ -87,7 +87,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.external_secrets\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # FSx OpenZFS CSI\n@@ -98,7 +98,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.fsx_openzfs_csi\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller\n@@ -109,7 +109,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # AWS Load Balancer Controller - Target Group Binding Only\n@@ -120,7 +120,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.load_balancer_controller_targetgroup_only\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Amazon Managed Service for Prometheus\n@@ -131,7 +131,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.amazon_managed_service_prometheus\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Node Termination Handler\n@@ -142,7 +142,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.node_termination_handler\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # Velero\n@@ -153,7 +153,7 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.velero\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n \n # VPC CNI\n@@ -164,5 +164,5 @@ moved {\n \n moved {\n from = aws_iam_role_policy_attachment.vpc_cni\n- to = aws_iam_policy.this\n+ to = aws_iam_role_policy_attachment.this\n }\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nSee https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-6-upgrade#data-source-aws_region\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n data.aws_partition.current.partition\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nAdds GetParametersByPath for external-secrets\r\n\r\n## Motivation and Context\r\nFrom the logs of external-secrets \r\n> :\"GetParametersByPath: access denied. using fallback to describe parameters. It is recommended to add ssm:GetParametersByPath permissions\"\r\n\r\n## Breaking Changes\r\nNo breaking changes\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -598,6 +598,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:GetParametersByPath\"\n ]\n \n resources = var.external_secrets_ssm_parameter_arns\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -598,6 +598,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:GetParametersByPath\"\n ]\n \n resources = var.external_secrets_ssm_parameter_arns\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -598,6 +598,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:GetParametersByPath\"\n \"ssm:GetParametersByPath\"\n ]\n \n resources = var.external_secrets_ssm_parameter_arns\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -598,6 +598,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:GetParametersByPath\"\n ]\n \n resources = var.external_secrets_ssm_parameter_arns\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR fixes several typos found across the codebase\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/main.tf\n@@ -18,7 +18,7 @@ resource \"aws_iam_group_membership\" \"this\" {\n }\n \n ################################\n-# IAM group policy attachements\n+# IAM group policy attachments\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n count = var.attach_iam_self_management_policy ? 1 : 0\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -225,7 +225,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br/> \"arn:aws:route53:::hostedzone/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:kms:*:*:key/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:secretsmanager:*:*:secret:*\"<br/>]</pre> | no |\n-| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determines whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using ? Secrets | `list(string)` | <pre>[<br/> \"arn:aws:ssm:*:*:parameter/*\"<br/>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br/> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br/>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -209,7 +209,7 @@ variable \"external_secrets_kms_key_arns\" {\n }\n \n variable \"external_secrets_secrets_manager_create_permission\" {\n- description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ description = \"Determines whether External Secrets may use secretsmanager:CreateSecret\"\n type = bool\n default = false\n }\n---\nmodules/iam-user/README.md\n@@ -6,7 +6,7 @@ Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user pub\n \n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+### Keybase pre-requisites\n \n When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/main.tf\n@@ -18,7 +18,7 @@ resource \"aws_iam_group_membership\" \"this\" {\n }\n \n ################################\n-# IAM group policy attachements\n+# IAM group policy attachments\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n count = var.attach_iam_self_management_policy ? 1 : 0\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -225,7 +225,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br/> \"arn:aws:route53:::hostedzone/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:kms:*:*:key/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:secretsmanager:*:*:secret:*\"<br/>]</pre> | no |\n-| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether to Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determines whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:ssm:*:*:parameter/*\"<br/>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br/> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br/>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -209,7 +209,7 @@ variable \"external_secrets_kms_key_arns\" {\n }\n \n variable \"external_secrets_secrets_manager_create_permission\" {\n- description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ description = \"Determines whether External Secrets may use secretsmanager:CreateSecret\"\n type = bool\n default = false\n }\n---\nmodules/iam-user/README.md\n@@ -6,7 +6,7 @@ Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user pub\n \n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+### Keybase pre-requisites\n \n When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/main.tf\n@@ -18,7 +18,7 @@ resource \"aws_iam_group_membership\" \"this\" {\n }\n \n ################################\n-# IAM group policy attachements\n+# IAM group policy attachments\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n count = var.attach_iam_self_management_policy ? 1 : 0\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -225,7 +225,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br/> \"arn:aws:route53:::hostedzone/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:kms:*:*:key/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:secretsmanager:*:*:secret:*\"<br/>]</pre> | no |\n-| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determines whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` use <pre>[<br/> \"arn:aws:ssm:*:*:parameter/*\"<br/>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br/> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br/>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -209,7 +209,7 @@ variable \"external_secrets_kms_key_arns\" {\n }\n \n variable \"external_secrets_secrets_manager_create_permission\" {\n- description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ description = \"Determines whether External Secrets may use secretsmanager:CreateSecret\"\n type = bool\n default = false\n }\n---\nmodules/iam-user/README.md\n@@ -6,7 +6,7 @@ Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user pub\n \n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+### Keybase pre-requisites\n \n When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/main.tf\n@@ -18,7 +18,7 @@ resource \"aws_iam_group_membership\" \"this\" {\n }\n \n ################################\n-# IAM group policy attachements\n+# IAM group policy attachments\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n count = var.attach_iam_self_management_policy ? 1 : 0\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -225,7 +225,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br/> \"arn:aws:route53:::hostedzone/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:kms:*:*:key/*\"<br/>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:secretsmanager:*:*:secret:*\"<br/>]</pre> | no |\n-| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determines whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> \"arn:aws:ssm:*:*:parameter/*\"<br/>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br/> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br/>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -209,7 +209,7 @@ variable \"external_secrets_kms_key_arns\" {\n }\n \n variable \"external_secrets_secrets_manager_create_permission\" {\n- description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ description = \"Determines whether External Secrets may use secretsmanager:CreateSecret\"\n type = bool\n default = false\n }\n---\nmodules/iam-user/README.md\n@@ -6,7 +6,7 @@ Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user pub\n \n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+### Keybase pre-requisites\n \n When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nReplaces the deprecated `data.aws_region.current.name` with `data.aws_region.current.region` in the IAM Role for Service Accounts EKS module.\r\n\r\n## Description\r\n- Updated `modules/iam-role-for-service-accounts-eks/main.tf` to use the non-deprecated `region` attribute instead of `name`\r\n\r\n## Motivation and Context\r\nThe `name` attribute of the `aws_region` data source has been deprecated by the AWS provider. This change ensures compatibility with current and future versions of the AWS provider.\r\n\r\nhttps://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region#name-1\r\n\r\nfix: https://github.com/terraform-aws-modules/terraform-aws-iam/issues/574\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -19,14 +19,14 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.5.7 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n@@ -42,7 +42,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_disabled\"></a> [disabled](#module\\_disabled) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_ebs_csi_irsa_role\"></a> [ebs\\_csi\\_irsa\\_role](#module\\_ebs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_efs_csi_irsa_role\"></a> [efs\\_csi\\_irsa\\_role](#module\\_efs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 19.21 |\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 21.0 |\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -56,7 +56,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_mountpoint_s3_csi_irsa_role\"></a> [mountpoint\\_s3\\_csi\\_irsa\\_role](#module\\_mountpoint\\_s3\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_node_termination_handler_irsa_role\"></a> [node\\_termination\\_handler\\_irsa\\_role](#module\\_node\\_termination\\_handler\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_velero_irsa_role\"></a> [velero\\_irsa\\_role](#module\\_velero\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |\n+| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |\n | <a name=\"module_vpc_cni_ipv4_irsa_role\"></a> [vpc\\_cni\\_ipv4\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv4\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_vpc_cni_ipv6_irsa_role\"></a> [vpc\\_cni\\_ipv6\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv6\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -455,7 +455,7 @@ module \"iam_eks_role\" {\n \n module \"vpc\" {\n source = \"terraform-aws-modules/vpc/aws\"\n- version = \"~> 5.0\"\n+ version = \"~> 6.0\"\n \n name = local.name\n cidr = local.vpc_cidr\n@@ -480,10 +480,10 @@ module \"vpc\" {\n \n module \"eks\" {\n source = \"terraform-aws-modules/eks/aws\"\n- version = \"~> 19.21\"\n+ version = \"~> 21.0\"\n \n- cluster_name = local.name\n- cluster_version = \"1.28\"\n+ name = local.name\n+ kubernetes_version = \"1.31\"\n \n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -1,10 +1,10 @@\n terraform {\n- required_version = \">= 1.0\"\n+ required_version = \">= 1.5.7\"\n \n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0, < 6.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -108,13 +108,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name 21.0\"\n null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nwrappers/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -19,14 +19,14 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.5.7 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n@@ -42,7 +42,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_disabled\"></a> [disabled](#module\\_disabled) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_ebs_csi_irsa_role\"></a> [ebs\\_csi\\_irsa\\_role](#module\\_ebs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_efs_csi_irsa_role\"></a> [efs\\_csi\\_irsa\\_role](#module\\_efs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 19.21 |\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 21.0 |\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -56,7 +56,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_mountpoint_s3_csi_irsa_role\"></a> [mountpoint\\_s3\\_csi\\_irsa\\_role](#module\\_mountpoint\\_s3\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_node_termination_handler_irsa_role\"></a> [node\\_termination\\_handler\\_irsa\\_role](#module\\_node\\_termination\\_handler\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_velero_irsa_role\"></a> [velero\\_irsa\\_role](#module\\_velero\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |\n+| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |\n | <a name=\"module_vpc_cni_ipv4_irsa_role\"></a> [vpc\\_cni\\_ipv4\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv4\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_vpc_cni_ipv6_irsa_role\"></a> [vpc\\_cni\\_ipv6\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv6\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -455,7 +455,7 @@ module \"iam_eks_role\" {\n \n module \"vpc\" {\n source = \"terraform-aws-modules/vpc/aws\"\n- version = \"~> 5.0\"\n+ version = \"~> 6.0\"\n \n name = local.name\n cidr = local.vpc_cidr\n@@ -480,10 +480,10 @@ module \"vpc\" {\n \n module \"eks\" {\n source = \"terraform-aws-modules/eks/aws\"\n- version = \"~> 19.21\"\n+ version = \"~> 21.0\"\n \n- cluster_name = local.name\n- cluster_version = \"1.28\"\n+ name = local.name\n+ kubernetes_version = \"1.31\"\n \n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -1,10 +1,10 @@\n terraform {\n- required_version = \">= 1.0\"\n+ required_version = \">= 1.5.7\"\n \n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0, < 6.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -108,13 +108,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nwrappers/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -19,14 +19,14 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.5.7 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n@@ -42,7 +42,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_disabled\"></a> [disabled](#module\\_disabled) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_ebs_csi_irsa_role\"></a> [ebs\\_csi\\_irsa\\_role](#module\\_ebs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_efs_csi_irsa_role\"></a> [efs\\_csi\\_irsa\\_role](#module\\_efs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 19.21 |\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 21.0 |\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -56,7 +56,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_mountpoint_s3_csi_irsa_role\"></a> [mountpoint\\_s3\\_csi\\_irsa\\_role](#module\\_mountpoint\\_s3\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_node_termination_handler_irsa_role\"></a> [node\\_termination\\_handler\\_irsa\\_role](#module\\_node\\_termination\\_handler\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_velero_irsa_role\"></a> [velero\\_irsa\\_role](#module\\_velero\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |\n+| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |\n | <a name=\"module_vpc_cni_ipv4_irsa_role\"></a> [vpc\\_cni\\_ipv4\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv4\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_vpc_cni_ipv6_irsa_role\"></a> [vpc\\_cni\\_ipv6\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv6\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -455,7 +455,7 @@ module \"iam_eks_role\" {\n \n module \"vpc\" {\n source = \"terraform-aws-modules/vpc/aws\"\n- version = \"~> 5.0\"\n+ version = \"~> 6.0\"\n \n name = local.name\n cidr = local.vpc_cidr\n@@ -480,10 +480,10 @@ module \"vpc\" {\n \n module \"eks\" {\n source = \"terraform-aws-modules/eks/aws\"\n- version = \"~> 19.21\"\n+ version = \"~> 21.0\"\n \n- cluster_name = local.name\n- cluster_version = \"1.28\"\n+ name = local.name\n+ kubernetes_version = \"1.31\"\n \n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -1,10 +1,10 @@\n terraform {\n- required_version = \">= 1.0\"\n+ required_version = \">= 1.5.7\"\n \n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0, < 6.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -108,13 +108,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nwrappers/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -19,14 +19,14 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.5.7 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n@@ -42,7 +42,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_disabled\"></a> [disabled](#module\\_disabled) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_ebs_csi_irsa_role\"></a> [ebs\\_csi\\_irsa\\_role](#module\\_ebs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_efs_csi_irsa_role\"></a> [efs\\_csi\\_irsa\\_role](#module\\_efs\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 19.21 |\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 21.0 |\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -56,7 +56,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_mountpoint_s3_csi_irsa_role\"></a> [mountpoint\\_s3\\_csi\\_irsa\\_role](#module\\_mountpoint\\_s3\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_node_termination_handler_irsa_role\"></a> [node\\_termination\\_handler\\_irsa\\_role](#module\\_node\\_termination\\_handler\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_velero_irsa_role\"></a> [velero\\_irsa\\_role](#module\\_velero\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n-| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |\n+| <a name=\"module_vpc\"></a> [vpc](#module\\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |\n | <a name=\"module_vpc_cni_ipv4_irsa_role\"></a> [vpc\\_cni\\_ipv4\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv4\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_vpc_cni_ipv6_irsa_role\"></a> [vpc\\_cni\\_ipv6\\_irsa\\_role](#module\\_vpc\\_cni\\_ipv6\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -455,7 +455,7 @@ module \"iam_eks_role\" {\n \n module \"vpc\" {\n source = \"terraform-aws-modules/vpc/aws\"\n- version = \"~> 5.0\"\n+ account_id = \"~> 6.0\"\n \n name = local.name\n cidr = local.vpc_cidr\n@@ -480,10 +480,10 @@ module \"vpc\" {\n \n module \"eks\" {\n source = \"terraform-aws-modules/eks/aws\"\n- version = \"~> 19.21\"\n+ version = \"~> 21.0\"\n \n- cluster_name = local.name\n- cluster_version = \"1.28\"\n+ name = local.name\n+ kubernetes_version = \"1.31\"\n \n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -1,10 +1,10 @@\n terraform {\n- required_version = \">= 1.0\"\n+ required_version = \">= 1.5.7\"\n \n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0, < 6.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -108,13 +108,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\nwrappers/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 6.0\"\n }\n }\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\ndata.aws_region.current.name is deprecated, now we need to reference data.aws_region.current.region.\r\n\r\nSee https://registry.terraform.io/providers/hashicorp/aws/6.5.0/docs/data-sources/region\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nAdds and option to specify ARNs of KMS keys, for which additional policy blocks will be created containing actions to operate with these keys.\r\n\r\n## Motivation and Context\r\nUsing this module, if the `var.velero_s3_kms_key_arns` is set to an S3 bucket with default encryption set to customer managed KMS key (CMK), the backup will fail since the policy doesn't include statement with policies allowing operating this KMS keys (such as `kms:Encrypt`, `kms:Decrypt` etc.).\r\n\r\nThis is similar to the cases of EBS (`var.ebs_csi_kms_cmk_ids`) and S3 mountpoint (`var.mountpoint_s3_csi_kms_arns`) controllers IAM policies created by this module that contain similar blocks for the same reason.\r\n\r\n## Breaking Changes\r\nNo breaking changes, the newly introduced `var.velero_s3_kms_key_arns` variable has default of `[]` which doesn't change the behaviour of the current configuration. \r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -337,9 +337,10 @@ module \"node_termination_handler_irsa_role\" {\n module \"velero_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"velero\"\n- attach_velero_policy = true\n- velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ role_name = \"velero\"\n+ attach_velero_policy = true\n+ velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ velero_s3_kms_key_arns = [\"arn:aws:kms:eu-west-1:123456789012:key/abcd1234-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -253,6 +253,7 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br/> \"*\"<br/>]</pre> | no |\n+| <a name=\"input_velero_s3_kms_key_arns\"></a> [velero\\_s3\\_kms\\_key\\_arns](#input\\_velero\\_s3\\_kms\\_key\\_arns) | List of KMS Key ARNs that Velero needs access to in order to encrypt backups | `list(string)` | `[]` | no |\n | <a name=\"input_vpc_cni_enable_cloudwatch_logs\"></a> [vpc\\_cni\\_enable\\_cloudwatch\\_logs](#input\\_vpc\\_cni\\_enable\\_cloudwatch\\_logs) | Determines whether to enable VPC CNI permission to create CloudWatch Log groups and publish network policy events | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1565,6 +1565,21 @@ data \"aws_iam_policy_document\" \"velero\" {\n ]\n resources = var.velero_s3_bucket_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.velero_s3_kms_key_arns\n+\n+ content {\n+ actions = [\n+ \"kms:Encrypt\",\n+ \"kms:Decrypt\",\n+ \"kms:ReEncrypt*\",\n+ \"kms:GenerateDataKey*\",\n+ \"kms:DescribeKey\"\n+ ]\n+ resources = [statement.value]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"velero\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -357,6 +357,12 @@ variable \"velero_s3_bucket_arns\" {\n default = [\"*\"]\n }\n \n+variable \"velero_s3_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that Velero needs access to in order to encrypt backups\"\n+ type = list(string)\n+ default = []\n+}\n+\n # VPC CNI\n variable \"attach_vpc_cni_policy\" {\n description = \"Determines whether to attach the VPC CNI IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -63,6 +63,7 @@ module \"wrapper\" {\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, {})\n tags = try(each.value.tags, var.defaults.tags, {})\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n+ velero_s3_kms_key_arns = try(each.value.velero_s3_kms_key_arns, var.defaults.velero_s3_kms_key_arns, [])\n vpc_cni_enable_cloudwatch_logs KMS = try(each.value.vpc_cni_enable_cloudwatch_logs, var.defaults.vpc_cni_enable_cloudwatch_logs, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -337,9 +337,10 @@ module \"node_termination_handler_irsa_role\" {\n module \"velero_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"velero\"\n- attach_velero_policy = true\n- velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ role_name = \"velero\"\n+ attach_velero_policy = true\n+ velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ velero_s3_kms_key_arns = [\"arn:aws:kms:eu-west-1:123456789012:key/abcd1234-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -253,6 +253,7 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br/> \"*\"<br/>]</pre> | no |\n+| <a name=\"input_velero_s3_kms_key_arns\"></a> [velero\\_s3\\_kms\\_key\\_arns](#input\\_velero\\_s3\\_kms\\_key\\_arns) | List of KMS Key ARNs that Velero needs access to in order to encrypt backups | `list(string)` | `[]` | no |\n | <a name=\"input_vpc_cni_enable_cloudwatch_logs\"></a> [vpc\\_cni\\_enable\\_cloudwatch\\_logs](#input\\_vpc\\_cni\\_enable\\_cloudwatch\\_logs) | Determines whether to enable VPC CNI permission to create CloudWatch Log groups and publish network policy events | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1565,6 +1565,21 @@ data \"aws_iam_policy_document\" \"velero\" {\n ]\n resources = var.velero_s3_bucket_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.velero_s3_kms_key_arns\n+\n+ content {\n+ actions = [\n+ \"kms:Encrypt\",\n+ \"kms:Decrypt\",\n+ \"kms:ReEncrypt*\",\n+ \"kms:GenerateDataKey*\",\n+ \"kms:DescribeKey\"\n+ ]\n+ resources = [statement.value]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"velero\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -357,6 +357,12 @@ variable \"velero_s3_bucket_arns\" {\n default = [\"*\"]\n }\n \n+variable \"velero_s3_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that Velero needs access to in order to encrypt backups\"\n+ type = list(string)\n+ default = []\n+}\n+\n # VPC CNI\n variable \"attach_vpc_cni_policy\" {\n description = \"Determines whether to attach the VPC CNI IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -63,6 +63,7 @@ module \"wrapper\" {\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, {})\n tags = try(each.value.tags, var.defaults.tags, {})\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n+ velero_s3_kms_key_arns = try(each.value.velero_s3_kms_key_arns, var.defaults.velero_s3_kms_key_arns, [])\n vpc_cni_enable_cloudwatch_logs = try(each.value.vpc_cni_enable_cloudwatch_logs, var.defaults.vpc_cni_enable_cloudwatch_logs, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -337,9 +337,10 @@ module \"node_termination_handler_irsa_role\" {\n module \"velero_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"velero\"\n- attach_velero_policy = true\n- velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ role_name = \"velero\"\n+ attach_velero_policy = true\n+ velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ velero_s3_kms_key_arns = [\"arn:aws:kms:eu-west-1:123456789012:key/abcd1234-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -253,6 +253,7 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br/> \"*\"<br/>]</pre> | no |\n+| <a name=\"input_velero_s3_kms_key_arns\"></a> [velero\\_s3\\_kms\\_key\\_arns](#input\\_velero\\_s3\\_kms\\_key\\_arns) | List of KMS Key ARNs that Velero needs access to in order to encrypt backups | `list(string)` | `[]` | no |\n | <a name=\"input_vpc_cni_enable_cloudwatch_logs\"></a> [vpc\\_cni\\_enable\\_cloudwatch\\_logs](#input\\_vpc\\_cni\\_enable\\_cloudwatch\\_logs) | Determines whether to enable VPC CNI permission to create CloudWatch Log groups and publish network policy events | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1565,6 +1565,21 @@ data \"aws_iam_policy_document\" \"velero\" {\n ]\n resources = var.velero_s3_bucket_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.velero_s3_kms_key_arns\n+\n+ content {\n+ actions = [\n+ \"kms:Encrypt\",\n+ \"kms:Decrypt\",\n+ \"kms:ReEncrypt*\",\n+ \"kms:GenerateDataKey*\",\n+ \"kms:DescribeKey\"\n+ ]\n+ resources = [statement.value]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"velero\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -357,6 +357,12 @@ variable \"velero_s3_bucket_arns\" {\n default = [\"*\"]\n }\n \n+variable \"velero_s3_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that Velero needs access to in order to encrypt backups\"\n+ type = list(string)\n+ default = []\n+}\n+\n # VPC CNI\n variable \"attach_vpc_cni_policy\" {\n description = \"Determines whether to attach the VPC CNI IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -63,6 +63,7 @@ module \"wrapper\" {\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, {})\n tags = try(each.value.tags, var.defaults.tags, {})\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n+ velero_s3_kms_key_arns = try(each.value.velero_s3_kms_key_arns, var.defaults.velero_s3_kms_key_arns, [])\n vpc_cni_enable_cloudwatch_logs = try(each.value.vpc_cni_enable_cloudwatch_logs, var.defaults.vpc_cni_enable_cloudwatch_logs, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -337,9 +337,10 @@ module \"node_termination_handler_irsa_role\" {\n module \"velero_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"velero\"\n- attach_velero_policy = true\n- velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ role_name = \"velero\"\n+ attach_velero_policy = true\n+ velero_s3_bucket_arns = [\"arn:aws:s3:::velero-backups\"]\n+ velero_s3_kms_key_arns = [\"arn:aws:kms:eu-west-1:123456789012:key/abcd1234-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -253,6 +253,7 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br/> \"*\"<br/>]</pre> | no |\n+| <a name=\"input_velero_s3_kms_key_arns\"></a> [velero\\_s3\\_kms\\_key\\_arns](#input\\_velero\\_s3\\_kms\\_key\\_arns) | List of KMS Key ARNs that Velero needs access to in order to encrypt backups | `list(string)` | `[]` | no |\n | <a name=\"input_vpc_cni_enable_cloudwatch_logs\"></a> [vpc\\_cni\\_enable\\_cloudwatch\\_logs](#input\\_vpc\\_cni\\_enable\\_cloudwatch\\_logs) | Determines whether to enable VPC CNI permission to create CloudWatch Log groups and publish network policy events | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1565,6 +1565,21 @@ data \"aws_iam_policy_document\" \"velero\" {\n ]\n resources = var.velero_s3_bucket_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.velero_s3_kms_key_arns\n+\n+ content {\n+ actions = [\n+ \"kms:Encrypt\",\n+ \"kms:Decrypt\",\n+ \"kms:ReEncrypt*\",\n+ \"kms:GenerateDataKey*\",\n+ \"kms:DescribeKey\"\n+ ]\n+ resources = [statement.value]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"velero\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -357,6 +357,12 @@ variable \"velero_s3_bucket_arns\" {\n default = [\"*\"]\n @@ \n+variable \"velero_s3_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that Velero needs access to in order to encrypt backups\"\n+ type = list(string)\n+ default = []\n+}\n+\n # VPC CNI\n variable \"attach_vpc_cni_policy\" {\n description = \"Determines whether to attach the VPC CNI IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -63,6 +63,7 @@ module \"wrapper\" {\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, {})\n tags = try(each.value.tags, var.defaults.tags, {})\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n+ velero_s3_kms_key_arns = try(each.value.velero_s3_kms_key_arns, var.defaults.velero_s3_kms_key_arns, [])\n vpc_cni_enable_cloudwatch_logs = try(each.value.vpc_cni_enable_cloudwatch_logs, var.defaults.vpc_cni_enable_cloudwatch_logs, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nUpdates the `iam-role-for-service-accounts-eks` module to address the deprecated attribute warning mentioned in #574. This requires removing the version restrictions on the AWS provider for this module.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nSee above\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition != = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region {\n = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n data.aws_region.current.name\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -6,7 +6,7 @@ locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n- region = data.aws_region.current.name\n+ region = data.aws_region.current.region\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Overview\r\n- Pinned Terraform version to `v1.12.2` for stability.\r\n- Removed dynamic version extraction using `terraform-min-max`.\r\n- Simplified the workflow by eliminating unnecessary matrix and condition logic.\r\n- Improved maintainability and reliability of the pre-commit workflow.\r\n\r\n## Background\r\nThe previous setup dynamically determined the min/max Terraform versions, which introduced instability when new versions were released. \r\nBy explicitly setting the version to `v1.12.2` (the latest stable release as of July 2025), we ensure consistent CI behavior.\r\n\r\n## Affected Areas\r\n- Only `.github/workflows/pre-commit.yml` is modified.\r\n- No changes to Terraform code itself.\r\n\r\n## Test Plan\r\n- Confirm that the GitHub Actions workflow passes with the pinned Terraform version.\r\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -7,6 +7,7 @@ on:\n - master\n \n env:\n+ TERRAFORM_VERSION: 1.12.2\n TERRAFORM_DOCS_VERSION: v0.19.0\n TFLINT_VERSION: v0.53.0\n \n@@ -24,15 +25,14 @@ jobs:\n id: dirs\n uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n- preCommitMinVersions:\n- name: Min TF pre-commit\n+ preCommit:\n+ name: TF pre-commit (Terraform 1.12.2)\n needs: collectInputs\n runs-on: ubuntu-latest\n strategy:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n rm -rf /opt/hostedtoolcache/CodeQL\n@@ -43,44 +43,38 @@ jobs:\n - name: Checkout\n uses: actions/checkout@v4\n \n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n- with:\n- directory: ${{ matrix.directory }}\n-\n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory != '.' }}\n+ - name: Pre-commit Terraform (non-root)\n+ if: ${{ matrix.directory != '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory == '.' }}\n+ - name: Pre-commit Terraform (root dir)\n+ if: ${{ matrix.directory == '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n- name: Max TF pre-commit\n+ name: TF pre-commit (Terraform 1.12.2 - max check)\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n df -h\n rm -rf /opt/hostedtoolcache/CodeQL\n rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n rm -rf /opt/hostedtoolcache/Ruby\n rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n sudo apt-get -qq remove -y 'azure-.*'\n sudo apt-get -qq remove -y 'cpp-.*'\n sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n@@ -101,16 +95,12 @@ jobs:\n uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n- repository: ${{github.event.pull_request.head.repo.full_name}}\n-\n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ repository: ${{ github.event.pull_request.head.repo.full_name }}\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n+ - name: Pre-commit Terraform (max version)\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n install-hcledit: true\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -211,15 +211,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n ]\n-\n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:CreateAction\"\n- values = [\n- \"CreateVolume\",\n- \"CreateSnapshot\",\n- ]\n- }\n }\n \n statement {\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -7,6 +7,7 @@ on:\n - master\n \n env:\n+ TERRAFORM_VERSION: 1.12.2\n TERRAFORM_DOCS_VERSION: v0.19.0\n TFLINT_VERSION: v0.53.0\n \n@@ -24,15 +25,14 @@ jobs:\n id: dirs\n uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n- preCommitMinVersions:\n- name: Min TF pre-commit\n+ preCommit:\n+ name: TF pre-commit (Terraform 1.12.2)\n needs: collectInputs\n runs-on: ubuntu-latest\n strategy:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n rm -rf /opt/hostedtoolcache/CodeQL\n@@ -43,44 +43,38 @@ jobs:\n - name: Checkout\n uses: actions/checkout@v4\n \n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n- with:\n- directory: ${{ matrix.directory }}\n-\n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory != '.' }}\n+ - name: Pre-commit Terraform (non-root)\n+ if: ${{ matrix.directory != '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory == '.' }}\n+ - name: Pre-commit Terraform (root dir)\n+ if: ${{ matrix.directory == '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n- name: Max TF pre-commit\n+ name: TF pre-commit (Terraform 1.12.2 - max check)\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n df -h\n rm -rf /opt/hostedtoolcache/CodeQL\n rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n rm -rf /opt/hostedtoolcache/Ruby\n rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n sudo apt-get -qq remove -y 'azure-.*'\n sudo apt-get -qq remove -y 'cpp-.*'\n sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n@@ -101,16 +95,12 @@ jobs:\n uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n- repository: ${{github.event.pull_request.head.repo.full_name}}\n-\n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ repository: ${{ github.event.pull_request.head.repo.full_name }}\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n+ - name: Pre-commit Terraform (max version)\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n install-hcledit: true\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -211,15 +211,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n ]\n-\n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:CreateAction\"\n- values = [\n- \"CreateVolume\",\n- \"CreateSnapshot\",\n- ]\n- }\n }\n \n statement {\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -7,6 +7,7 @@ on:\n - master\n \n env:\n+ TERRAFORM_VERSION: 1.12.2\n TERRAFORM_DOCS_VERSION: v0.19.0\n TFLINT_VERSION: v0.53.0\n \n@@ -24,15 +25,14 @@ jobs:\n id: dirs\n uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n- preCommitMinVersions:\n- name: Min TF pre-commit\n+ preCommit:\n+ name: TF pre-commit (Terraform 1.12.2)\n needs: collectInputs\n runs-on: ubuntu-latest\n strategy:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n rm -rf /opt/hostedtoolcache/CodeQL\n@@ -43,44 +43,38 @@ jobs:\n - name: Checkout\n uses: actions/checkout@v4\n \n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n- with:\n- directory: ${{ matrix.directory }}\n-\n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory != '.' }}\n+ - name: Pre-commit Terraform (non-root)\n+ if: ${{ matrix.directory != '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory == '.' }}\n+ - name: Pre-commit Terraform (root dir)\n+ if: ${{ matrix.directory == '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n- name: Max TF pre-commit\n+ name: TF pre-commit (Terraform 1.12.2 - max check)\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n df -h\n rm -rf /opt/hostedtoolcache/CodeQL\n rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n rm -rf /opt/hostedtoolcache/Ruby\n rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n sudo apt-get -qq remove -y 'azure-.*'\n sudo apt-get -qq remove -y 'cpp-.*'\n sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n@@ -101,16 +95,12 @@ jobs:\n uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n- repository: ${{github.event.pull_request.head.repo.full_name}}\n-\n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ repository: ${{ github.event.pull_request.head.repo.full_name }}\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n+ - name: Pre-commit Terraform (max version)\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n install-hcledit: true\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -211,15 +211,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n ]\n-\n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:CreateAction\"\n- values = [\n- \"CreateVolume\",\n- \"CreateSnapshot\",\n- ]\n- }\n }\n \n statement {\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -7,6 +7,7 @@ on:\n - master\n \n env:\n+ TERRAFORM_VERSION: 1.12.2\n TERRAFORM_DOCS_VERSION: v0.19.0\n TFLINT_VERSION: v0.53.0\n \n@@ -24,15 +25,14 @@ jobs:\n id: dirs\n uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n- preCommitMinVersions:\n- name: Min TF pre-commit\n+ preCommit:\n+ name: TF pre-commit (Terraform 1.12.2)\n needs: collectInputs\n runs-on: ubuntu-latest\n strategy:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n rm -rf /opt/hostedtoolcache/CodeQL\n@@ -43,44 +43,38 @@ jobs:\n - name: Checkout\n uses: actions/checkout@v4\n \n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n- with:\n- directory: ${{ matrix.directory }}\n-\n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory != '.' }}\n+ - name: Pre-commit Terraform (non-root)\n+ if: ${{ matrix.directory != '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.directory == '.' }}\n+ - name: Pre-commit Terraform (root dir)\n+ if: ${{ matrix.directory == '.' }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n+ terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n- name: Max TF pre-commit\n+ name: TF pre-commit (Terraform 1.12.2 - max check)\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n - name: Delete huge unnecessary tools folder\n run: |\n df -h\n rm -rf /opt/hostedtoolcache/CodeQL\n rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n rm -rf /opt/hostedtoolcache/Ruby\n rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n sudo apt-get -qq remove -y 'azure-.*'\n sudo apt-get -qq remove -y 'cpp-.*'\n sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n@@ -101,16 +95,12 @@ jobs:\n uses: actions/checkout@v4\n with:\n ref: ${{ }}\n- repository: ${{github.event.pull_request.head.repo.full_name}}\n-\n- - name: Terraform min/max versions\n- id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ repository: ${{ github.event.pull_request.head.repo.full_name }}\n \n- - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n+ - name: Pre-commit Terraform (max version)\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n- terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ terraform-version: ${{ env.TERRAFORM_VERSION }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n install-hcledit: true\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -211,15 +211,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n ]\n-\n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:CreateAction\"\n- values = [\n- \"CreateVolume\",\n- \"CreateSnapshot\",\n- ]\n- }\n }\n \n statement {\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n### Description\r\n\r\nThis PR removes the unnecessary `condition` block from the `ebs_csi` IAM policy document.\r\nAccording to AWS documentation, this `condition` is not required and may cause permission issues when using the EBS CSI driver with IRSA.\r\n\r\nCloses #562\r\n\r\n### Reference\r\n- AWS Docs: [EBS CSI IAM Policy](https://docs.aws.amazon.com/...)\r\n\r\n### Impact\r\nNo impact on functionality. Simplifies the policy and aligns with AWS recommendations.\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.1\n+ rev: v1.99.4\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-eks-role/README.md\n@@ -20,14 +20,14 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/iam-eks-role/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n \n ## Modules\n \n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -188,25 +188,49 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\n- \"ec2:CreateSnapshot\",\n- \"ec2:AttachVolume\",\n- \"ec2:DetachVolume\",\n- \"ec2:ModifyVolume\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSnapshots\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n- \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n }\n \n statement {\n- actions = [\"ec2:CreateTags\"]\n+ actions = [\n+ \"ec2:CreateSnapshot\",\n+ \"ec2:ModifyVolume\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:AttachVolume\",\n+ \"ec2:DetachVolume\",\n+ ]\n \n+ resources = [\n+ \"arn:${local.partition}:ec2:*:*:volume/*\",\n+ \"arn:${local.partition}:ec2:*:*:instance/*\",\n+ ]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:CreateVolume\",\n+ \"ec2:EnableFastSnapshotRestores\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n+ }\n+\n+ statement {\n+ actions = [\"ec2:CreateTags\"]\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -224,7 +248,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:DeleteTags\"]\n-\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -238,9 +261,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n- values = [\n- true\n- ]\n+ values = [\"true\"]\n }\n }\n \n@@ -256,84 +277,79 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n \n statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n- }\n-\n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:RequestTag/CSIVolumeSnapshotName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n- | values = [\"*\"]\n+ variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n+ variable = \"aws:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.1\n+ rev: v1.99.4\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-eks-role/README.md\n@@ -20,14 +20,14 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/iam-eks-role/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n \n ## Modules\n \n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -188,25 +188,49 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\n- \"ec2:CreateSnapshot\",\n- \"ec2:AttachVolume\",\n- \"ec2:DetachVolume\",\n- \"ec2:ModifyVolume\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSnapshots\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n- \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n }\n \n statement {\n- actions = [\"ec2:CreateTags\"]\n+ actions = [\n+ \"ec2:CreateSnapshot\",\n+ \"ec2:ModifyVolume\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:AttachVolume\",\n+ \"ec2:DetachVolume\",\n+ ]\n \n+ resources = [\n+ \"arn:${local.partition}:ec2:*:*:volume/*\",\n+ \"arn:${local.partition}:ec2:*:*:instance/*\",\n+ ]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:CreateVolume\",\n+ \"ec2:EnableFastSnapshotRestores\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n+ }\n+\n+ statement {\n+ actions = [\"ec2:CreateTags\"]\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -224,7 +248,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:DeleteTags\"]\n-\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -238,9 +261,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n- values = [\n- true\n- ]\n+ values = [\"true\"]\n }\n }\n \n@@ -256,84 +277,79 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n \n statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n- }\n-\n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:RequestTag/CSIVolumeSnapshotName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n- values = [\"*\"]\n+ variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n+ variable = \"aws:ResourceTag/CSIVolumeSnapshotName\"\n actions values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.1\n+ rev: v1.99.4\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-eks-role/README.md\n@@ -20,14 +20,14 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/iam-eks-role/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n \n ## Modules\n \n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -188,25 +188,49 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\n- \"ec2:CreateSnapshot\",\n- \"ec2:AttachVolume\",\n- \"ec2:DetachVolume\",\n- \"ec2:ModifyVolume\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSnapshots\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n- \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n }\n \n statement {\n- actions = [\"ec2:CreateTags\"]\n+ actions = [\n+ \"ec2:CreateSnapshot\",\n+ \"ec2:ModifyVolume\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:AttachVolume\",\n+ \"ec2:DetachVolume\",\n+ ]\n \n+ resources = [\n+ \"arn:${local.partition}:ec2:*:*:volume/*\",\n+ \"arn:${local.partition}:ec2:*:*:instance/*\",\n+ ]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:CreateVolume\",\n+ \"ec2:EnableFastSnapshotRestores\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n+ }\n+\n+ statement {\n+ actions = [\"ec2:CreateTags\"]\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -224,7 +248,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:DeleteTags\"]\n-\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -238,9 +261,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n- values = [\n- true\n- ]\n+ values = [\"true\"]\n }\n }\n \n@@ -256,84 +277,79 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n \n statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n+ values = [\"true\"]\n }\n }\n \n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n- }\n-\n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:RequestTag/CSIVolumeSnapshotName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n- values = [\"*\"]\n+ variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n+ variable = \"aws:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.1\n+ rev: v1.99.4\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-eks-role/README.md\n@@ -20,14 +20,14 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/iam-eks-role/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0, < 6.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0, < 6.0 |\n \n ## Modules\n \n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 4.0, < 6.0\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -188,25 +188,49 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\n- \"ec2:CreateSnapshot\",\n- \"ec2:AttachVolume\",\n- \"ec2:DetachVolume\",\n- \"ec2:ModifyVolume\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSnapshots\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n- \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n }\n \n statement {\n- actions = [\"ec2:CreateTags\"]\n+ actions = [\n+ \"ec2:CreateSnapshot\",\n+ \"ec2:ModifyVolume\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:AttachVolume\",\n+ \"ec2:DetachVolume\",\n+ ]\n \n+ resources = [\n+ \"arn:${local.partition}:ec2:*:*:volume/*\",\n+ \"arn:${local.partition}:ec2:*:*:instance/*\",\n+ ]\n+ }\n+\n+ statement {\n+ actions = [\n+ \"ec2:CreateVolume\",\n+ \"ec2:EnableFastSnapshotRestores\",\n+ ]\n+\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n+ }\n+\n+ statement {\n+ actions = [\"ec2:CreateTags\"]\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -224,7 +248,6 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:DeleteTags\"]\n-\n resources = [\n \"arn:${local.partition}:ec2:*:*:volume/*\",\n \"arn:${local.partition}:ec2:*:*:snapshot/*\",\n@@ -238,9 +261,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n- values = [\n- true\n- ]\n+ values = [\"true\"]\n }\n }\n \n@@ -256,84 +277,79 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n \n statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n- }\n-\n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n- values = [\"owned\"]\n+ variable = \"aws:RequestTag/CSIVolumeSnapshotName\"\n+ values = [\"*\"]\n }\n }\n \n statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n+ actions = [\"ec2:CreateSnapshot\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n- values = [\"*\"]\n+ variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n+ variable = \"aws:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n }\n \n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"aws:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n }\n }\n \n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nLatest release of AWS LBC (v2.13.x) adds this permission `ec2:DescribeRouteTables`\r\n\r\n## Motivation and Context\r\nlatest IAM Policy for AWS LBC: https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## Testing\r\n- Tested using my fork:\r\n\r\n```\r\nmodule \"aws_load_balancer_controller_irsa\" {\r\n source = \"git::https://github.com/RafiGreenberg/terraform-aws-iam//modules/iam-role-for-service-accounts-eks\"\r\n\r\n role_name = \"aws-load-balancer-controller\"\r\n\r\n attach_load_balancer_controller_policy = true\r\n oidc_providers = {\r\n main = {\r\n provider_arn = module.eks.oidc_provider_arn\r\n namespace_service_accounts = [\"kube-system:aws-load-balancer-controller\"]\r\n }\r\n }\r\n}\r\n```\r\n\r\n- Plan:\r\n```\r\n$ tf plan\r\n~ resource \"aws_iam_policy\" \"load_balancer_controller\" {\r\n id = \"arn:aws:iam::xxxxx:policy/AmazonEKS_AWS_Load_Balancer_Controller-20250603185119521400000001\"\r\n name = \"AmazonEKS_AWS_Load_Balancer_Controller-20250603185119521400000001\"\r\n ~ policy = jsonencode(\r\n ~ {\r\n ~ Statement = [\r\n {\r\n Action = \"iam:CreateServiceLinkedRole\"\r\n Condition = {\r\n StringEquals = {\r\n \"iam:AWSServiceName\" = \"elasticloadbalancing.amazonaws.com\"\r\n }\r\n }\r\n Effect = \"Allow\"\r\n Resource = \"*\"\r\n },\r\n ~ {\r\n ~ Action = [\r\n # (19 unchanged elements hidden)\r\n \"ec2:DescribeSecurityGroups\",\r\n + \"ec2:DescribeRouteTables\",\r\n \"ec2:DescribeNetworkInterfaces\",\r\n # (7 unchanged elements hidden)\r\n ]\r\n # (2 unchanged attributes hidden)\r\n },\r\n {\r\n Action = [\r\n \"wafv2:GetWebACLForResource\",\r\n \"wafv2:GetWebACL\",\r\n \"wafv2:DisassociateWebACL\",\r\n \"wafv2:AssociateWebACL\",\r\n \"waf-regional:GetWebACLForResource\",\r\n \"waf-regional:GetWebACL\",\r\n \"waf-regional:DisassociateWebACL\",\r\n \"waf-regional:AssociateWebACL\",\r\n \"shield:GetSubscriptionState\",\r\n \"shield:DescribeProtection\",\r\n \"shield:DeleteProtection\",\r\n \"shield:CreateProtection\",\r\n \"iam:ListServerCertificates\",\r\n \"iam:GetServerCertificate\",\r\n \"cognito-idp:DescribeUserPoolClient\",\r\n \"acm:ListCertificates\",\r\n \"acm:DescribeCertificate\",\r\n ]\r\n Effect = \"Allow\"\r\n Resource = \"*\"\r\n },\r\n # (12 unchanged elements hidden)\r\n ]\r\n # (1 unchanged attribute hidden)\r\n }\r\n )\r\n tags = {}\r\n # (7 unchanged attributes hidden)\r\n }\r\nPlan: 0 to add, 1 to change, 0 to destroy.\r\n```\r\n\r\nTested successfully - ingress using ALB works now\r\n```\r\nEvents:\r\n Type Reason Age From Message\r\n ---- ------ ---- ---- -------\r\n Normal SuccessfullyReconciled 4m45s ingress Successfully reconciled\r\n```\r\nCloses: https://github.com/terraform-aws-modules/terraform-aws-iam/issues/568\r\n\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.0\n+ rev: v1.99.1\n hooks:\n repo: - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n@@ -859,6 +858,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n \"ec2:DescribeIpamPools\",\n+ \"ec2:DescribeRouteTables\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -903,6 +903,12 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n@@ -962,7 +968,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -977,7 +982,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.0\n+ rev: v1.99.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n@@ -859,6 +858,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n \"ec2:DescribeIpamPools\",\n+ \"ec2:DescribeRouteTables\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -903,6 +903,12 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n@@ -962,7 +968,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -977,7 +982,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- +1,6 \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.0\n+ rev: v1.99.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n@@ -859,6 +858,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n \"ec2:DescribeIpamPools\",\n+ \"ec2:DescribeRouteTables\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -903,6 +903,12 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n@@ -962,7 +968,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -977,7 +982,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.99.0\n+ rev: v1.99.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n@@ -859,6 +858,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n \"ec2:DescribeIpamPools\",\n+ \"ec2:DescribeRouteTables\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -903,6 +903,12 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n@@ -962,7 +968,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -977,7 +982,6 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n- \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n- Use optimized action to purge unnecessary CI files for disk space\r\n\r\n## Motivation and Context\r\n- Faster than prior method - see https://xd009642.github.io/2024/10/26/debloating-github-actions-with-rust.html\r\n\r\n### Before - `39GB` available\r\n\r\n[Took 2m39s](https://github.com/terraform-aws-modules/terraform-aws-iam/actions/runs/14959202136/job/42018920152?pr=565)\r\n\r\n<img width=\"440\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b1165de7-c7bb-4021-b69b-b92c9d088d4b\" />\r\n\r\n### After - :fire: `53.8GB` available\r\n\r\nTook 14-16s\r\n\r\n<img width=\"411\" alt=\"image\" src=\"https://github.com/user-attachments/assets/ba3e790e-6ff5-45f2-ab65-f6e433048641\" />\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -7,8 +7,8 @@ on:\n - master\n \n env:\n- TERRAFORM_DOCS_VERSION: v0.19.0\n- TFLINT_VERSION: v0.53.0\n+ TERRAFORM_DOCS_VERSION: v0.20.0\n+ TFLINT_VERSION: v0.57.0\n \n jobs:\n collectInputs:\n@@ -22,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: uses: clowdhaus/terraform-composite-actions/directories@v1.11.1\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,20 +32,15 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n with:\n directory: ${{ matrix.directory }}\n \n@@ -72,30 +67,8 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- df -h\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n- sudo apt-get -qq remove -y 'azure-.*'\n- sudo apt-get -qq remove -y 'cpp-.*'\n- sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n- sudo apt-get -qq remove -y 'google-.*'\n- sudo apt-get -qq remove -y 'libclang-.*'\n- sudo apt-get -qq remove -y 'libllvm.*'\n- sudo apt-get -qq remove -y 'llvm-.*'\n- sudo apt-get -qq remove -y 'mysql-.*'\n- sudo apt-get -qq remove -y 'postgresql-.*'\n- sudo apt-get -qq remove -y 'php.*'\n- sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox mono-devel\n- sudo apt-get -qq autoremove -y\n- sudo apt-get -qq clean\n- df -h\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n@@ -105,7 +78,7 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -7,8 +7,8 @@ on:\n - master\n \n env:\n- TERRAFORM_DOCS_VERSION: v0.19.0\n- TFLINT_VERSION: v0.53.0\n+ TERRAFORM_DOCS_VERSION: v0.20.0\n+ TFLINT_VERSION: v0.57.0\n \n jobs:\n collectInputs:\n@@ -22,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.11.1\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,20 +32,15 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n with:\n directory: ${{ matrix.directory }}\n \n@@ -72,30 +67,8 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- df -h\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n- sudo apt-get -qq remove -y 'azure-.*'\n- sudo apt-get -qq remove -y 'cpp-.*'\n- sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n- sudo apt-get -qq remove -y 'google-.*'\n- sudo apt-get -qq remove -y 'libclang-.*'\n- sudo apt-get -qq remove -y 'libllvm.*'\n- sudo apt-get -qq remove -y 'llvm-.*'\n- sudo apt-get -qq remove -y 'mysql-.*'\n- sudo apt-get -qq remove -y 'postgresql-.*'\n- sudo apt-get -qq remove -y 'php.*'\n- sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox mono-devel\n- sudo apt-get -qq autoremove -y\n- sudo apt-get -qq clean\n- df -h\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n -rf uses: actions/checkout@v4\n@@ -105,7 +78,7 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -7,8 +7,8 @@ on:\n - master\n \n env:\n- TERRAFORM_DOCS_VERSION: v0.19.0\n- TFLINT_VERSION: v0.53.0\n+ TERRAFORM_DOCS_VERSION: v0.20.0\n+ TFLINT_VERSION: v0.57.0\n \n jobs:\n collectInputs:\n@@ -22,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.11.1\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,20 +32,15 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n with:\n directory: ${{ matrix.directory }}\n \n@@ -72,30 +67,8 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- df -h\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n- sudo apt-get -qq remove -y 'azure-.*'\n- sudo apt-get -qq remove -y 'cpp-.*'\n- sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n- sudo apt-get -qq remove -y 'google-.*'\n- sudo apt-get -qq remove -y 'libclang-.*'\n- sudo apt-get -qq remove -y 'libllvm.*'\n- sudo apt-get -qq remove -y 'llvm-.*'\n- sudo apt-get -qq remove -y 'mysql-.*'\n- sudo apt-get -qq remove -y 'postgresql-.*'\n- sudo apt-get -qq remove -y 'php.*'\n- sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox mono-devel\n- sudo apt-get -qq autoremove -y\n- sudo apt-get -qq clean\n- df -h\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n@@ -105,7 +78,7 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -7,8 +7,8 @@ on:\n - master\n \n env:\n- TERRAFORM_DOCS_VERSION: v0.19.0\n- TFLINT_VERSION: v0.53.0\n+ TERRAFORM_DOCS_VERSION: v0.20.0\n+ TFLINT_VERSION: v0.57.0\n \n jobs:\n collectInputs:\n@@ -22,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.11.1\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,20 +32,15 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ uses: clowdhaus/terraform-min-max@v1.3.2\n with:\n directory: ${{ matrix.directory }}\n \n@@ -72,30 +67,8 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n- # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n- - name: Delete huge unnecessary tools folder\n- run: |\n- df -h\n- rm -rf /opt/hostedtoolcache/CodeQL\n- rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n- rm -rf /opt/hostedtoolcache/Ruby\n- rm -rf /opt/hostedtoolcache/go\n- # And a little bit more\n- sudo apt-get -qq remove -y 'azure-.*'\n- sudo apt-get -qq remove -y 'cpp-.*'\n- sudo apt-get -qq remove -y 'dotnet-runtime-.*'\n- sudo apt-get -qq remove -y 'google-.*'\n- sudo apt-get -qq remove -y 'libclang-.*'\n- sudo apt-get -qq remove -y 'libllvm.*'\n- sudo apt-get -qq remove -y 'llvm-.*'\n- sudo apt-get -qq remove -y 'mysql-.*'\n- sudo apt-get -qq remove -y 'postgresql-.*'\n- sudo apt-get -qq remove -y 'php.*'\n- sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox mono-devel\n- sudo apt-get -qq autoremove -y\n- sudo apt-get -qq clean\n- df -h\n+ - name: Delete unnecessary files\n+ uses: xd009642/ci-hoover@0.1.1\n \n - name: Checkout\n uses: actions/checkout@v4\n@@ -105,7 +78,7 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.1\n+ -y uses: clowdhaus/terraform-min-max@v1.3.2\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nUpdate IAM policy for AWS Gateway Controller\r\n\r\n## Motivation and Context\r\nCurrent policy is outdated\r\n\r\n## Breaking Changes\r\n\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -5,16 +5,49 @@\n data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n- # https://github.com/aws/aws-application-networking-k8s/blob/v0.0.11/examples/recommended-inline-policy.json\n+ # https://github.com/aws/aws-application-networking-k8s/blob/v1.1.0/files/controller-installation/recommended-inline-policy.json\n statement {\n actions = [\n \"vpc-lattice:*\",\n- \"iam:CreateServiceLinkedRole\",\n \"ec2:DescribeVpcs\",\n \"ec2:DescribeSubnets\",\n+ \"ec2:DescribeTags\",\n+ \"ec2:DescribeSecurityGroups\",\n+ \"logs:CreateLogDelivery\",\n+ \"logs:GetLogDelivery\",\n+ \"logs:DescribeLogGroups\",\n+ \"logs:PutResourcePolicy\",\n+ \"logs:DescribeResourcePolicies\",\n+ \"logs:UpdateLogDelivery\",\n+ \"logs:DeleteLogDelivery\",\n+ \"logs:ListLogDeliveries\",\n+ \"tag:GetResources\",\n+ \"firehose:TagDeliveryStream\",\n+ \"s3:GetBucketPolicy\",\n+ \"s3:PutBucketPolicy\",\n ]\n resources = [\"*\"]\n }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/vpc-lattice.${local.dns_suffix}/AWSServiceRoleForVpcLattice\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = values = [\"vpc-lattice.${local.dns_suffix}\"]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/delivery.logs.${local.dns_suffix}/AWSServiceRoleForLogDelivery\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"delivery.logs.${local.dns_suffix}\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -5,16 +5,49 @@\n data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n- # https://github.com/aws/aws-application-networking-k8s/blob/v0.0.11/examples/recommended-inline-policy.json\n+ # https://github.com/aws/aws-application-networking-k8s/blob/v1.1.0/files/controller-installation/recommended-inline-policy.json\n statement {\n actions = [\n \"vpc-lattice:*\",\n- \"iam:CreateServiceLinkedRole\",\n \"ec2:DescribeVpcs\",\n \"ec2:DescribeSubnets\",\n+ \"ec2:DescribeTags\",\n+ \"ec2:DescribeSecurityGroups\",\n+ \"logs:CreateLogDelivery\",\n+ \"logs:GetLogDelivery\",\n+ \"logs:DescribeLogGroups\",\n+ \"logs:PutResourcePolicy\",\n+ \"logs:DescribeResourcePolicies\",\n+ \"logs:UpdateLogDelivery\",\n+ \"logs:DeleteLogDelivery\",\n+ \"logs:ListLogDeliveries\",\n+ \"tag:GetResources\",\n+ \"firehose:TagDeliveryStream\",\n+ \"s3:GetBucketPolicy\",\n+ \"s3:PutBucketPolicy\",\n ]\n resources = [\"*\"]\n }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/vpc-lattice.${local.dns_suffix}/AWSServiceRoleForVpcLattice\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"vpc-lattice.${local.dns_suffix}\"]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/delivery.logs.${local.dns_suffix}/AWSServiceRoleForLogDelivery\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"delivery.logs.${local.dns_suffix}\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -5,16 +5,49 @@\n data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n- # https://github.com/aws/aws-application-networking-k8s/blob/v0.0.11/examples/recommended-inline-policy.json\n+ # https://github.com/aws/aws-application-networking-k8s/blob/v1.1.0/files/controller-installation/recommended-inline-policy.json\n statement {\n actions = [\n \"vpc-lattice:*\",\n- \"iam:CreateServiceLinkedRole\",\n \"ec2:DescribeVpcs\",\n \"ec2:DescribeSubnets\",\n+ \"ec2:DescribeTags\",\n+ \"ec2:DescribeSecurityGroups\",\n+ \"logs:CreateLogDelivery\",\n+ \"logs:GetLogDelivery\",\n+ \"logs:DescribeLogGroups\",\n+ \"logs:PutResourcePolicy\",\n+ \"logs:DescribeResourcePolicies\",\n+ \"logs:UpdateLogDelivery\",\n+ \"logs:DeleteLogDelivery\",\n+ \"logs:ListLogDeliveries\",\n+ \"tag:GetResources\",\n+ \"firehose:TagDeliveryStream\",\n+ \"s3:GetBucketPolicy\",\n+ \"s3:PutBucketPolicy\",\n ]\n resources = [\"*\"]\n }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/vpc-lattice.${local.dns_suffix}/AWSServiceRoleForVpcLattice\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"vpc-lattice.${local.dns_suffix}\"]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/delivery.logs.${local.dns_suffix}/AWSServiceRoleForLogDelivery\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"delivery.logs.${local.dns_suffix}\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -5,16 +5,49 @@\n data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n- # https://github.com/aws/aws-application-networking-k8s/blob/v0.0.11/examples/recommended-inline-policy.json\n+ # https://github.com/aws/aws-application-networking-k8s/blob/v1.1.0/files/controller-installation/recommended-inline-policy.json\n statement {\n actions = [\n \"vpc-lattice:*\",\n- \"iam:CreateServiceLinkedRole\",\n \"ec2:DescribeVpcs\",\n \"ec2:DescribeSubnets\",\n+ \"ec2:DescribeTags\",\n+ \"ec2:DescribeSecurityGroups\",\n+ \"logs:CreateLogDelivery\",\n+ \"logs:GetLogDelivery\",\n+ \"logs:DescribeLogGroups\",\n+ \"logs:PutResourcePolicy\",\n+ \"logs:DescribeResourcePolicies\",\n+ \"logs:UpdateLogDelivery\",\n+ \"logs:DeleteLogDelivery\",\n+ \"logs:ListLogDeliveries\",\n+ \"tag:GetResources\",\n+ \"firehose:TagDeliveryStream\",\n+ \"s3:GetBucketPolicy\",\n+ \"s3:PutBucketPolicy\",\n ]\n resources = [\"*\"]\n }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/vpc-lattice.${local.dns_suffix}/AWSServiceRoleForVpcLattice\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"vpc-lattice.${local.dns_suffix}\"]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"iam:CreateServiceLinkedRole\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/delivery.logs.${local.dns_suffix}/AWSServiceRoleForLogDelivery\"]\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"iam:AWSServiceName\"\n+ values = [\"delivery.logs.${local.dns_suffix}\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nIAM policy for External-DNS has changed.\r\n\r\n`route53:ListTagsForResource` => `route53:ListTagsForResource`**s**\r\n\r\nSee https://github.com/kubernetes-sigs/external-dns/commit/658d1efb76d7ce1f454cec9e8e92192c6c19d6fb\r\n\r\n\r\n## Motivation and Context\r\nThe policy does not work with recent external-dns version. It aligns the policy with the doc\r\n\r\n## Breaking Changes\r\nThe policy will not work with older version. We could provide backward compatibility by either providing both actions `ListTagsForResources` and `ListTagsForResource`, or a toggle.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,7 +501,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n resources \"route53:ListResourceRecordSets\",\n- \"route53:ListTagsForResource\",\n+ \"route53:ListTagsForResources\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,7 +501,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n- \"route53:ListTagsForResource\",\n+ \"route53:ListTagsForResources\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,7 +501,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n- \"route53:ListTagsForResource\",\n+ \"route53:ListTagsForResources\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,7 +501,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n- \"route53:ListTagsForResource\",\n+ \"route53:ListTagsForResources\",\n data ]\n \n resources = [\"*\"]\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nLatest release of AWS LBC (v2.12.x) adds support of intergrating AWS VPC IPAM\r\nhttps://github.com/kubernetes-sigs/aws-load-balancer-controller/releases/tag/v2.12.0\r\n\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nlatest IAM Policy for AWS LBC: https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json\r\n\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -841,6 +841,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n+ \"ec2:DescribeIpamPools\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -1017,6 +1018,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n \"elasticloadbalancing:ModifyCapacityReservation\",\n+ \"elasticloadbalancing:ModifyIpPools\"\n ]\n resources = [\"*\"]\n \n@@ -1068,6 +1070,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:AddListenerCertificates\",\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n+ \"elasticloadbalancing:SetRulePriorities\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -841,6 +841,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n+ \"ec2:DescribeIpamPools\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -1017,6 +1018,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n \"aws_iam_policy_document\" \"elasticloadbalancing:ModifyCapacityReservation\",\n+ \"elasticloadbalancing:ModifyIpPools\"\n ]\n resources = [\"*\"]\n \n@@ -1068,6 +1070,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:AddListenerCertificates\",\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n+ \"elasticloadbalancing:SetRulePriorities\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -841,6 +841,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n+ \"ec2:DescribeIpamPools\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -1017,6 +1018,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n \"elasticloadbalancing:ModifyCapacityReservation\",\n+ \"elasticloadbalancing:ModifyIpPools\"\n ]\n resources = [\"*\"]\n \n@@ -1068,6 +1070,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:AddListenerCertificates\",\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n+ \"elasticloadbalancing:SetRulePriorities\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -841,6 +841,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n \"ec2:GetSecurityGroupsForVpc\",\n+ \"ec2:DescribeIpamPools\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n@@ -1017,6 +1018,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n \"elasticloadbalancing:ModifyCapacityReservation\",\n+ \"elasticloadbalancing:ModifyIpPools\"\n ]\n resources = [\"*\"]\n \n@@ -1068,6 +1070,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:AddListenerCertificates\",\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n+ \"elasticloadbalancing:SetRulePriorities\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nThis PR addresses the issue of outdated links in the documentation for the iam-role-for-service-accounts-eks module. The current links point to the deprecated GitHub repository https://github.com/external-secrets/kubernetes-external-secrets, which was archived on July 26, 2022. The project has been superseded by the External Secrets Operator, which is now hosted at https://github.com/external-secrets/external-secrets.\r\n\r\n### Changes:\r\n\r\n- Updated the README.md file in modules/iam-role-for-service-accounts-eks to point to the new repository.\r\n\r\n- Updated the policies.tf file in modules/iam-role-for-service-accounts-eks to point to the new repository.\r\n\r\n### Files Modified:\r\n\r\n- modules/iam-role-for-service-accounts-eks/README.md:10\r\n- modules/iam-role-for-service-accounts-eks/policies.tf:533\r\n\r\n### Steps to Reproduce:\r\n\r\nClick on the outdated links in the documentation.\r\nVerify that they point to the deprecated repository.\r\n\r\n### Expected Behavior: \r\nThe links should now point to the active project repository at https://github.com/external-secrets/external-secrets.\r\n\r\n### Actual Behavior: \r\nThe links currently point to the deprecated repository at https://github.com/external-secrets/kubernetes-external-secrets.\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -7,7 +7,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n-- [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n+- [External Secrets](https://github.com/external-secrets/external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -530,7 +530,7 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n # External Secrets Policy\n ################################################################################\n \n-# https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret\n+# https://github.com/external-secrets/external-secrets#add-a-secret\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n -\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -7,7 +7,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n-- [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n+- [External Secrets](https://github.com/external-secrets/external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -530,7 +530,7 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n # External Secrets Policy\n ################################################################################\n \n-# var.attach_external_secrets_policy https://github.com/external-secrets/external-secrets#add-a-secret\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -7,7 +7,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n-- [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n+- [External Secrets](https://github.com/external-secrets/external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -530,7 +530,7 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n # External Secrets Policy\n ################################################################################\n \n-# https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret\n+# https://github.com/external-secrets/external-secrets#add-a-secret\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -7,7 +7,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n-- [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n+- [External Secrets](https://github.com/external-secrets/external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n [External [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -530,7 +530,7 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n # External Secrets Policy\n ################################################################################\n \n-# https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret\n+# https://github.com/external-secrets/external-secrets#add-a-secret\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nI'd like the option to remove access to KMS and SSM permissions on my IRSA roles while still providing the ability to use this module with the default encryption key provided by AWS. When I attempt to provide an empty list, the IAM policy is invalid because a resource definition is required.\r\n\r\n```\r\nError: updating IAM Policy (arn:aws:iam:::policy/role-External_Secrets_Policy-20190815225516998100000001): MalformedPolicyDocument: Policy statement must contain resources.\r\n\tstatus code: 400, request id: <id>\r\n```\r\n\r\n## Motivation and Context\r\nMost of the secrets in my environment have been created with the default encryption key, so they don't need any special access to KMS or SSM. When attempting to remove this permission I ran into an error applying the configuration because the policy document was malformed.\r\n\r\nResolves #557 \r\n\r\n## Breaking Changes\r\nNo, this is not a breaking change as the existing default remains intact.\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.96.3\n+ rev: v1.99.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -110,6 +110,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n dynamic \"statement\" {\n # TODO - remove *_ids at next breaking change\n for_each = toset(coalescelist(var.cluster_autoscaler_cluster_ids, var.cluster_autoscaler_cluster_names))\n+\n \"autoscaling:SetDesiredCapacity\",\n@@ content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n@@ -306,6 +307,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:CreateGrant\",\n@@ -325,6 +327,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:Encrypt\",\n@@ -455,6 +458,7 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:GenerateDataKey\",\n@@ -539,12 +543,17 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"ssm:GetParameter\",\n- \"ssm:GetParameters\",\n- ]\n- resources = var.external_secrets_ssm_parameter_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_ssm_parameter_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n+\n+ resources = var.external_secrets_ssm_parameter_arns\n+ }\n }\n \n statement {\n@@ -562,13 +571,18 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\"kms:Decrypt\"]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\"kms:Decrypt\"]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\n \"secretsmanager:CreateSecret\",\n@@ -581,9 +595,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\"secretsmanager:DeleteSecret\"]\n resources = var.external_secrets_secrets_manager_arns\n+\n condition {\n test = \"StringEquals\"\n variable = \"secretsmanager:ResourceTag/managed-by\"\n@@ -631,6 +647,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n statement {\n actions = [\"iam:CreateServiceLinkedRole\"]\n resources = [\"*\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1201,6 +1218,7 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \"iam:CreateServiceLinkedRole\"\n ]\n resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1459,6 +1477,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+\n content {\n sid = \"IPV4\"\n actions = [\n@@ -1482,6 +1501,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv6 ? [1] : []\n+\n content {\n sid = \"IPV6\"\n actions = [\n@@ -1498,6 +1518,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-network-policy.html#cni-network-policy-setup\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_cloudwatch_logs ? [1] : []\n+\n content {\n sid = \"CloudWatchLogs\"\n actions = [\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.96.3\n+ rev: v1.99.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -110,6 +110,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n dynamic \"statement\" {\n # TODO - remove *_ids at next breaking change\n for_each = toset(coalescelist(var.cluster_autoscaler_cluster_ids, var.cluster_autoscaler_cluster_names))\n+\n content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n@@ -306,6 +307,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:CreateGrant\",\n@@ -325,6 +327,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:Encrypt\",\n@@ -455,6 +458,7 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:GenerateDataKey\",\n@@ -539,12 +543,17 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"ssm:GetParameter\",\n- \"ssm:GetParameters\",\n- ]\n- resources = var.external_secrets_ssm_parameter_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_ssm_parameter_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n+\n+ resources = var.external_secrets_ssm_parameter_arns\n+ }\n }\n \n statement {\n@@ -562,13 +571,18 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\"kms:Decrypt\"]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\"kms:Decrypt\"]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\n \"secretsmanager:CreateSecret\",\n@@ -581,9 +595,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\"secretsmanager:DeleteSecret\"]\n resources = var.external_secrets_secrets_manager_arns\n+\n condition {\n test = \"StringEquals\"\n variable = \"secretsmanager:ResourceTag/managed-by\"\n@@ -631,6 +647,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n statement {\n actions = [\"iam:CreateServiceLinkedRole\"]\n resources = [\"*\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1201,6 +1218,7 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \"iam:CreateServiceLinkedRole\"\n ]\n resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1459,6 +1477,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+\n content {\n sid = \"IPV4\"\n actions = [\n@@ -1482,6 +1501,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv6 ? [1] : []\n+\n content {\n sid = \"IPV6\"\n actions = [\n@@ -1498,6 +1518,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-network-policy.html#cni-network-policy-setup\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_cloudwatch_logs ? [1] : []\n+\n content {\n sid = \"CloudWatchLogs\"\n actions = [\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.96.3\n+ rev: v1.99.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -110,6 +110,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n dynamic \"statement\" {\n # TODO - remove *_ids at next breaking change\n for_each = toset(coalescelist(var.cluster_autoscaler_cluster_ids, var.cluster_autoscaler_cluster_names))\n+\n content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n@@ -306,6 +307,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:CreateGrant\",\n@@ -325,6 +327,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:Encrypt\",\n@@ -455,6 +458,7 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:GenerateDataKey\",\n@@ -539,12 +543,17 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"ssm:GetParameter\",\n- \"ssm:GetParameters\",\n- ]\n- resources = var.external_secrets_ssm_parameter_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_ssm_parameter_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n+\n+ resources = var.external_secrets_ssm_parameter_arns\n+ }\n }\n \n statement {\n@@ -562,13 +571,18 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\"kms:Decrypt\"]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\"kms:Decrypt\"]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\n \"secretsmanager:CreateSecret\",\n@@ -581,9 +595,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\"secretsmanager:DeleteSecret\"]\n resources = var.external_secrets_secrets_manager_arns\n+\n condition {\n test = \"StringEquals\"\n variable = \"secretsmanager:ResourceTag/managed-by\"\n@@ -631,6 +647,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n statement {\n actions = [\"iam:CreateServiceLinkedRole\"]\n resources = [\"*\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1201,6 +1218,7 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \"iam:CreateServiceLinkedRole\"\n ]\n resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1459,6 +1477,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+\n content {\n sid = \"IPV4\"\n actions = [\n@@ -1482,6 +1501,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv6 ? [1] : []\n+\n content {\n sid = \"IPV6\"\n actions = [\n@@ -1498,6 +1518,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-network-policy.html#cni-network-policy-setup\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_cloudwatch_logs ? [1] : []\n+\n content {\n sid = \"CloudWatchLogs\"\n actions actions = [\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.96.3\n+ rev: v1.99.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -110,6 +110,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n dynamic \"statement\" {\n # TODO - remove *_ids at next breaking change\n for_each = toset(coalescelist(var.cluster_autoscaler_cluster_ids, var.cluster_autoscaler_cluster_names))\n+\n content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n@@ -306,6 +307,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:CreateGrant\",\n@@ -325,6 +327,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.ebs_csi_kms_cmk_ids) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:Encrypt\",\n@@ -455,6 +458,7 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n \n dynamic \"statement\" {\n for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+\n content {\n actions = [\n \"kms:GenerateDataKey\",\n@@ -539,12 +543,17 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = [\"*\"]\n }\n \n- statement {\n- actions = [\n- \"ssm:GetParameter\",\n- \"ssm:GetParameters\",\n- ]\n- resources = var.external_secrets_ssm_parameter_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_ssm_parameter_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n+\n+ resources = var.external_secrets_ssm_parameter_arns\n+ }\n }\n \n statement {\n@@ -562,13 +571,18 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\"kms:Decrypt\"]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+\n+ content {\n+ actions = [\"kms:Decrypt\"]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\n \"secretsmanager:CreateSecret\",\n@@ -581,9 +595,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+\n content {\n actions = [\"secretsmanager:DeleteSecret\"]\n resources = var.external_secrets_secrets_manager_arns\n+\n condition {\n test = \"StringEquals\"\n variable = \"secretsmanager:ResourceTag/managed-by\"\n@@ -631,6 +647,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n statement {\n actions = [\"iam:CreateServiceLinkedRole\"]\n resources = [\"*\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1201,6 +1218,7 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \"iam:CreateServiceLinkedRole\"\n ]\n resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n+\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n@@ -1459,6 +1477,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+\n content {\n sid = \"IPV4\"\n actions = [\n@@ -1482,6 +1501,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv6 ? [1] : []\n+\n content {\n sid = \"IPV6\"\n actions = [\n@@ -1498,6 +1518,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n # https://docs.aws.amazon.com/eks/latest/userguide/cni-network-policy.html#cni-network-policy-setup\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_cloudwatch_logs ? [1] : []\n+\n content {\n sid = \"CloudWatchLogs\"\n = = [\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nRemoved the need for number_of_custom_role_policy_arns variable.\r\n\r\n## Motivation and Context\r\nThe extra variable did not make sense and now when new policies are added you only need to update the list.\r\n## Breaking Changes\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role/main.tf\n@@ -186,10 +186,10 @@ type \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n+ for_each = var.custom_role_policy_arns != null ? toset(var.custom_role_policy_arns) : toset([])\n \n role = aws_iam_role.this[0].name\n- policy_arn = element(var.custom_role_policy_arns, count.index)\n+ policy_arn = each.value\n }\n \n resource \"aws_iam_role_policy_attachment\" \"admin\" {\n---\nmodules/iam-assumable-role/variables.tf\n@@ -104,12 +104,6 @@ variable \"create_custom_role_trust_policy\" {\n default = false\n }\n \n-variable \"number_of_custom_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = null\n-}\n-\n variable \"inline_policy_statements\" {\n description = \"List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy\"\n type = any\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/main.tf\n@@ -186,10 +186,10 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n+ for_each = var.custom_role_policy_arns != null ? toset(var.custom_role_policy_arns) : toset([])\n \n role = aws_iam_role.this[0].name\n- policy_arn = element(var.custom_role_policy_arns, count.index)\n+ policy_arn = each.value\n }\n \n resource \"aws_iam_role_policy_attachment\" \"admin\" {\n---\nmodules/iam-assumable-role/variables.tf\n@@ -104,12 +104,6 @@ variable \"create_custom_role_trust_policy\" {\n default = false\n }\n \n-variable \"number_of_custom_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = null\n-}\n-\n variable \"inline_policy_statements\" {\n description = \"List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy\"\n type \"aws_iam_role\" any\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/main.tf\n@@ -186,10 +186,10 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n+ for_each = var.custom_role_policy_arns != null ? toset(var.custom_role_policy_arns) : toset([])\n \n role = aws_iam_role.this[0].name\n- policy_arn = element(var.custom_role_policy_arns, count.index)\n+ policy_arn = each.value\n }\n \n resource \"aws_iam_role_policy_attachment\" {\n---\nmodules/iam-assumable-role/variables.tf\n@@ -104,12 +104,6 @@ variable \"create_custom_role_trust_policy\" {\n default = false\n }\n \n-variable \"number_of_custom_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = null\n-}\n-\n variable \"inline_policy_statements\" {\n description = \"List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy\"\n type = any\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/main.tf\n@@ -186,10 +186,10 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n+ for_each = var.custom_role_policy_arns != null ? toset(var.custom_role_policy_arns) : toset([])\n \n role = aws_iam_role.this[0].name\n- policy_arn = element(var.custom_role_policy_arns, count.index)\n+ policy_arn = each.value\n }\n \n resource \"aws_iam_role_policy_attachment\" \"admin\" {\n---\nmodules/iam-assumable-role/variables.tf\n@@ -104,12 +104,6 @@ variable \"create_custom_role_trust_policy\" {\n default = false\n }\n \n-variable \"number_of_custom_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = null\n-}\n-\n variable \"inline_policy_statements\" {\n description = \"List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy\"\n type = any\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis adds support for custom trust policy conditions to the `iam-github-oidc-role` module.\r\n\r\n## Motivation and Context\r\nThe GitHub documentation on [security hardening with OpenID connect] (https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect) specifies that:\r\n\r\n> You can define granular OIDC policies by using additional OIDC token claims, such as repository_id and repository_visibility. See [Understanding the OIDC token](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#understanding-the-oidc-token). \r\n\r\nHowever, this module currently only supports validation of `iss`, `aud` and `sub`. I have a use case where I also want to validate `actor` and `workflow` but without this change, the module doesn't support that.\r\n\r\n## Breaking Changes\r\nI do not believe this breaks any backwards compatibility. The added variable defaults to an empty array of entries, much like in the `iam-assumable-role-with-oidc` modules and the dynamic configuration will not add anything if no values are provided.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n> caveat: I don't have a space where I can deploy the examples but I have successfully tested the updated module against corporate accounts where I am employed.\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n> ~~caveat: terraform-docs also affected 8 other REAMDE files (for modules I have not touched in this PR) but I have not checked those changes in. I can if you'd like. All other pre-commmit checks passed.~~ this was due to using an outdated version of TF (1.5.5, I updated to 1.10.5 and it resolved this)\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-github-oidc/main.tf\n@@ -46,6 +46,24 @@ module \"iam_github_oidc_role\" {\n \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n ]\n \n+ # As per the Github documentation for security hardening with OpenID Connect\n+ # (https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect)\n+ # This document makes many references to the fact that you can leverage any of the available\n+ # OIDC claims to when configuring the cloud providers trust relation. For example in\n+ # https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#customizing-the-token-claims\n+ # it is specified that granular OIDC policies can be defined using additional OIDC token claims.\n+ # In this example, we ensure that the OIDC token GitHub uses to assume the AWS IAM role has the correct\n+ # `actor` scope.\n+ additional_trust_policy_conditions = [\n+ {\n+ test = \"StringEquals\"\n+ variable = \"${module.iam_github_oidc_provider.url}:actor\"\n+ # This should be the list of GitHub usernames for which you want to restrict\n+ # access to the role.\n+ values = [\"username\"]\n+ }\n+ ]\n+\n policies = {\n additional = aws_iam_policy.additional.arn\n S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n---\nmodules/iam-github-oidc-role/README.md\n@@ -82,6 +82,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_trust_policy_conditions\"></a> [additional\\_trust\\_policy\\_conditions](#input\\_additional\\_trust\\_policy\\_conditions) | Additional conditions for the constraint to apply to the trust policy | <pre>list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> }))</pre> | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,16 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.additional_trust_policy_conditions\n+\n+ content {\n+ test = condition.value.test\n+ values = condition.value.values\n+ variable = condition.value.variable\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -85,3 +85,13 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_trust_policy_conditions\" {\n+ description = \"Additional conditions for the constraint to apply to the trust policy\"\n+ type = list(object({\n+ test = string\n+ variable = string\n+ values = list(string)\n+ }))\n+ default = []\n+}\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -3,18 +3,19 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n- create = try(each.value.create, var.defaults.create, true)\n- description = try(each.value.description, var.defaults.description, null)\n- force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n- max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n- name = try(each.value.name, var.defaults.name, null)\n- name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n- policies = try(each.value.policies, var.defaults.policies, {})\n- provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n- subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n- subjects = try(each.value.subjects, var.defaults.subjects, [])\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ additional_trust_policy_conditions = try(each.value.additional_trust_policy_conditions, var.defaults.additional_trust_policy_conditions, [])\n+ audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n+ create = try(each.value.create, var.defaults.create, true)\n+ description = try(each.value.description, var.defaults.description, null)\n+ force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n+ name = try(each.value.name, var.defaults.name, null)\n+ name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n+ policies = try(each.value.policies, var.defaults.policies, {})\n+ provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n+ subjects = try(each.value.subjects, var.defaults.subjects, [])\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-github-oidc/main.tf\n@@ -46,6 +46,24 @@ module \"iam_github_oidc_role\" {\n \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n ]\n \n+ # As per the Github documentation for security hardening with OpenID Connect\n+ # (https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect)\n+ # This document makes many references to the fact that you can leverage any of the available\n+ # OIDC claims to when configuring the cloud providers trust relation. For example in\n+ # https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#customizing-the-token-claims\n+ # it is specified that granular OIDC policies can be defined using additional OIDC token claims.\n+ # In this example, we ensure that the OIDC token GitHub uses to assume the AWS IAM role has the correct\n+ # `actor` var.defaults.description, additional_trust_policy_conditions = [\n+ {\n+ test = \"StringEquals\"\n+ variable = \"${module.iam_github_oidc_provider.url}:actor\"\n+ # This should be the list of GitHub usernames for which you want to restrict\n+ # access to the role.\n+ values = [\"username\"]\n+ }\n+ ]\n+\n policies = {\n additional = aws_iam_policy.additional.arn\n S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n---\nmodules/iam-github-oidc-role/README.md\n@@ -82,6 +82,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_trust_policy_conditions\"></a> [additional\\_trust\\_policy\\_conditions](#input\\_additional\\_trust\\_policy\\_conditions) | Additional conditions for the constraint to apply to the trust policy | <pre>list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> }))</pre> | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,16 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.additional_trust_policy_conditions\n+\n+ content {\n+ test = condition.value.test\n+ values = condition.value.values\n+ variable = condition.value.variable\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -85,3 +85,13 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_trust_policy_conditions\" {\n+ description = \"Additional conditions for the constraint to apply to the trust policy\"\n+ type = list(object({\n+ test = string\n+ variable = string\n+ values = list(string)\n+ }))\n+ default = []\n+}\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -3,18 +3,19 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n- create = try(each.value.create, var.defaults.create, true)\n- description = try(each.value.description, var.defaults.description, null)\n- force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n- max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n- name = try(each.value.name, var.defaults.name, null)\n- name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n- policies = try(each.value.policies, var.defaults.policies, {})\n- provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n- subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n- subjects = try(each.value.subjects, var.defaults.subjects, [])\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ additional_trust_policy_conditions = try(each.value.additional_trust_policy_conditions, var.defaults.additional_trust_policy_conditions, [])\n+ audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n+ create = try(each.value.create, var.defaults.create, true)\n+ description = try(each.value.description, var.defaults.description, null)\n+ force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n+ name = try(each.value.name, var.defaults.name, null)\n+ name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n+ policies = try(each.value.policies, var.defaults.policies, {})\n+ provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n+ subjects = try(each.value.subjects, var.defaults.subjects, [])\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-github-oidc/main.tf\n@@ -46,6 +46,24 @@ module \"iam_github_oidc_role\" {\n \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n ]\n \n+ # As per the Github documentation for security hardening with OpenID Connect\n+ # (https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect)\n+ # This document makes many references to the fact that you can leverage any of the available\n+ # OIDC claims to when configuring the cloud providers trust relation. For example in\n+ # https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#customizing-the-token-claims\n+ # it is specified that granular OIDC policies can be defined using additional OIDC token claims.\n+ # In this example, we ensure that the OIDC token GitHub uses to assume the AWS IAM role has the correct\n+ # `actor` scope.\n+ additional_trust_policy_conditions = [\n+ {\n+ test = \"StringEquals\"\n+ variable = \"${module.iam_github_oidc_provider.url}:actor\"\n+ # This should be the list of GitHub usernames for which you want to restrict\n+ # access to the role.\n+ values = [\"username\"]\n+ }\n+ ]\n+\n policies = {\n additional = aws_iam_policy.additional.arn\n S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n---\nmodules/iam-github-oidc-role/README.md\n@@ -82,6 +82,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_trust_policy_conditions\"></a> [additional\\_trust\\_policy\\_conditions](#input\\_additional\\_trust\\_policy\\_conditions) | Additional conditions for the constraint to apply to the trust policy | <pre>list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> }))</pre> | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,16 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.additional_trust_policy_conditions\n+\n+ content {\n+ test = condition.value.test\n+ values = condition.value.values\n+ variable = condition.value.variable\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -85,3 +85,13 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_trust_policy_conditions\" {\n+ description = \"Additional conditions for the constraint to apply to the trust policy\"\n+ type = list(object({\n+ test = string\n+ variable = string\n+ values = list(string)\n+ }))\n+ default = []\n+}\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -3,18 +3,19 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n- create = try(each.value.create, var.defaults.create, true)\n- description = try(each.value.description, var.defaults.description, null)\n- force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n- max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n- name = try(each.value.name, var.defaults.name, null)\n- name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n- policies = try(each.value.policies, var.defaults.policies, {})\n- provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n- subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n- subjects = try(each.value.subjects, var.defaults.subjects, [])\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ additional_trust_policy_conditions = try(each.value.additional_trust_policy_conditions, var.defaults.additional_trust_policy_conditions, [])\n+ audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n+ create = try(each.value.create, var.defaults.create, true)\n+ description = try(each.value.description, var.defaults.description, null)\n+ force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n+ name = try(each.value.name, var.defaults.name, null)\n+ name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n+ policies = try(each.value.policies, var.defaults.policies, {})\n+ provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n+ subjects = try(each.value.subjects, var.defaults.subjects, [])\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-github-oidc/main.tf\n@@ -46,6 +46,24 @@ module \"iam_github_oidc_role\" {\n \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n ]\n \n+ # As per the Github documentation for security hardening with OpenID Connect\n+ # (https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect)\n+ # This document makes many references to the fact that you can leverage any of the available\n+ # OIDC claims to when configuring the cloud providers trust relation. For example in\n+ # https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#customizing-the-token-claims\n+ # it is specified that granular OIDC policies can be defined using additional OIDC token claims.\n+ # In this example, we ensure that the OIDC token GitHub uses to assume the AWS IAM role has the correct\n+ # `actor` scope.\n+ additional_trust_policy_conditions = [\n+ {\n+ test = \"StringEquals\"\n+ variable = \"${module.iam_github_oidc_provider.url}:actor\"\n+ # This should be the list of GitHub usernames for which you want to restrict\n+ # access to the role.\n+ values = [\"username\"]\n+ }\n+ ]\n+\n policies = {\n additional = aws_iam_policy.additional.arn\n S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n---\nmodules/iam-github-oidc-role/README.md\n@@ -82,6 +82,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_trust_policy_conditions\"></a> [additional\\_trust\\_policy\\_conditions](#input\\_additional\\_trust\\_policy\\_conditions) | Additional conditions for the constraint to apply to the trust policy | <pre>list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> }))</pre> | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,16 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to modules.\n for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.additional_trust_policy_conditions\n+\n+ content {\n+ test = condition.value.test\n+ values = condition.value.values\n+ variable = condition.value.variable\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -85,3 +85,13 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_trust_policy_conditions\" {\n+ description = \"Additional conditions for the constraint to apply to the trust policy\"\n+ type = list(object({\n+ test = string\n+ variable = string\n+ values = list(string)\n+ }))\n+ default = []\n+}\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -3,18 +3,19 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n- create = try(each.value.create, var.defaults.create, true)\n- description = try(each.value.description, var.defaults.description, null)\n- force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n- max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n- name = try(each.value.name, var.defaults.name, null)\n- name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n- policies = try(each.value.policies, var.defaults.policies, {})\n- provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n- subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n- subjects = try(each.value.subjects, var.defaults.subjects, [])\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ additional_trust_policy_conditions = try(each.value.additional_trust_policy_conditions, var.defaults.additional_trust_policy_conditions, [])\n+ audience = try(each.value.audience, var.defaults.audience, \"sts.amazonaws.com\")\n+ create = try(each.value.create, var.defaults.create, true)\n+ description = try(each.value.description, var.defaults.description, null)\n+ force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n+ name = try(each.value.name, var.defaults.name, null)\n+ name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n+ policies = try(each.value.policies, var.defaults.policies, {})\n+ provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n+ subjects = try(each.value.subjects, var.defaults.subjects, [])\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis pull request includes updates to the IAM policy document for external secrets in the `modules/iam-role-for-service-accounts-eks/policies.tf` file. The changes adjust the actions allowed for the secrets manager.\r\n\r\nChanges to IAM policy document:\r\n\r\n* Added the `secretsmanager:BatchGetSecretValue` action to the list of allowed actions in one statement.\r\n* Removed the `secretsmanager:BatchGetSecretValue` action from another statement to avoid redundancy.\r\n\r\n## Motivation and Context\r\n\r\nTwo weeks ago, the `0.12.1` version was launched for external-secrets. The new version requires a new permission for the action `BatchGetSecretValue`.\r\n\r\nI opened this PR https://github.com/terraform-aws-modules/terraform-aws-iam/pull/542 with the suggested changes from the external-secrets repo, and the proposed policy was not working as expected. After reviewing it and reporting it to external-secrets, they finally modified the documentation with a working policy (https://github.com/external-secrets/external-secrets/pull/4275).\r\n\r\nThe new policy has been tested and works properly with the latest version.\r\n\r\n## Breaking Changes\r\nNo breaking changes\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -548,7 +548,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\"secretsmanager:ListSecrets\"]\n+ actions = [\"secretsmanager:ListSecrets\", \"secretsmanager:BatchGetSecretValue\"]\n resources = [\"*\"]\n }\n \n@@ -557,8 +557,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetResourcePolicy\",\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\",\n- \"secretsmanager:BatchGetSecretValue\",\n+ \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\"\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -548,7 +548,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\"secretsmanager:ListSecrets\"]\n+ actions = [\"secretsmanager:ListSecrets\", \"secretsmanager:BatchGetSecretValue\"]\n resources = [\"*\"]\n }\n \n@@ -557,8 +557,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetResourcePolicy\",\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\",\n- \"secretsmanager:BatchGetSecretValue\",\n+ \"secretsmanager:ListSecretVersionIds\"\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -548,7 +548,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\"secretsmanager:ListSecrets\"]\n+ actions = [\"secretsmanager:ListSecrets\", \"secretsmanager:BatchGetSecretValue\"]\n resources = [\"*\"]\n }\n \n@@ -557,8 +557,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetResourcePolicy\",\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\",\n- \"secretsmanager:BatchGetSecretValue\",\n+ \"secretsmanager:ListSecretVersionIds\"\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -548,7 +548,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\"secretsmanager:ListSecrets\"]\n+ actions = [\"secretsmanager:ListSecrets\", \"secretsmanager:BatchGetSecretValue\"]\n resources = [\"*\"]\n }\n \n@@ -557,8 +557,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetResourcePolicy\",\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n- \"secretsmanager:ListSecretVersionIds\",\n- \"secretsmanager:BatchGetSecretValue\",\n+ \"secretsmanager:ListSecretVersionIds\"\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nChange `coalesece` to `coalesce` \r\n\r\n## Motivation and Context\r\n`coalesece` is a non existing method in terraform so all inline policies are named `_inline_`\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role/main.tf\n@@ -279,6 +279,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${try(coalesece(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n+ name_prefix \"aws_iam_role_policy\" \"${try(coalesce(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/main.tf\n@@ -279,6 +279,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${try(coalesece(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n+ name_prefix = \"${try(coalesce(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/main.tf\n@@ -279,6 +279,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${try(coalesece(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n+ name_prefix = \"${try(coalesce(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/main.tf\n@@ -279,6 +279,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${try(coalesece(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n+ name_prefix = \"${try(coalesce(var.role_name, var.role_name_prefix), \"\")}_inline_\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis pull request includes a change to the IAM policy document for external secrets in the `modules/iam-role-for-service-accounts-eks/policies.tf` file. The change adds a new permission to the policy.\r\n\r\n* Added `secretsmanager:BatchGetSecretValue` permission to the `data \"aws_iam_policy_document\" \"external_secrets\"` block to allow batch retrieval of secret values.\r\n\r\n## Motivation and Context\r\nExternal Secrets 0.12.1 introduces the use of BulkFetch to fetch secrets from the AWS Secret Manager.\r\nhttps://github.com/external-secrets/external-secrets/releases\r\nhttps://github.com/external-secrets/external-secrets/blob/main/docs/provider/aws-secrets-manager.md?plain=1\r\n\r\n## Breaking Changes\r\nNo breaking changes\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the examples/* to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided examples/* projects\r\n- [x] I have executed pre-commit run -a on my pull request\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ @@ +558,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n+ \"secretsmanager:BatchGetSecretValue\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -558,6 +558,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n+ \"secretsmanager:BatchGetSecretValue\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -558,6 +558,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n+ \"secretsmanager:BatchGetSecretValue\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -558,6 +558,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:GetSecretValue\",\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n+ \"secretsmanager:BatchGetSecretValue\",\n resources = var.external_secrets_secrets_manager_arns\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nAdd the `iss` condition to the assumable OIDC role.\r\n\r\n## Motivation and Context\r\nThe current implementation of the assumable OIDC role does not include the `iss` condition in the trust policy. This update follows the pattern introduced in [OIDC role PR #507](https://github.com/terraform-aws-modules/terraform-aws-iam/pull/507) to ensure consistency and compatibility with common OIDC providers.\r\n\r\n## Breaking Changes\r\nNone. This change is backward-compatible as it only adds an additional condition without altering existing functionality.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -71,6 +71,12 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ condition {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${statement.value}:iss\"\n+ values = [\"https://${statement.value}\"]\n+ }\n+\n dynamic \"condition\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -71,6 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ condition {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${statement.value}:iss\"\n+ values = [\"https://${statement.value}\"]\n+ }\n+\n dynamic \"condition\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -71,6 +71,12 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ condition {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${statement.value}:iss\"\n+ values = [\"https://${statement.value}\"]\n+ }\n+\n dynamic \"condition\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -71,6 +71,12 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ condition {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${statement.value}:iss\"\n+ values = [\"https://${statement.value}\"]\n+ }\n+\n dynamic \"condition\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n`docker pull` does API request to ECR and requires [BatchGetImage](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_BatchGetImage.html). With Read Only policy we expect that we can pull image from the registry. \r\n\r\nThis PR adds `BatchGet*` action to address this problem.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-read-only-policy/main.tf\n@@ -25,6 +25,7 @@ data \"aws_iam_policy_document\" \"allowed_services\" {\n actions = [\n \"${statement.value}:List*\",\n \"${statement.value}:Get*\",\n+ \"${statement.value}:BatchGet*\",\n \"${statement.value}:Describe*\",\n \"${statement.value}:View*\",\n ]\n---\n\n\n---\n\nChoice B:\nmodules/iam-read-only-policy/main.tf\n@@ -25,6 +25,7 @@ data \"aws_iam_policy_document\" \"allowed_services\" {\n actions = [\n \"${statement.value}:List*\",\n \"${statement.value}:Get*\",\n+ \"${statement.value}:BatchGet*\",\n \"${statement.value}:Describe*\",\n \"${statement.value}:View*\",\n ]\n---\n\n\n---\n\nChoice C:\nmodules/iam-read-only-policy/main.tf\n@@ -25,6 +25,7 @@ data \"aws_iam_policy_document\" \"allowed_services\" {\n = [\n \"${statement.value}:List*\",\n \"${statement.value}:Get*\",\n+ \"${statement.value}:BatchGet*\",\n \"${statement.value}:Describe*\",\n \"${statement.value}:View*\",\n ]\n---\n\n\n---\n\nChoice D:\nmodules/iam-read-only-policy/main.tf\n@@ -25,6 +25,7 @@ data \"aws_iam_policy_document\" \"allowed_services\" {\n actions = [\n \"${statement.value}:List*\",\n \"${statement.value}:Get*\",\n+ \"${statement.value}:BatchGet*\",\n \"${statement.value}:Describe*\",\n \"${statement.value}:View*\",\n ]\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nSee https://github.com/kubernetes-sigs/aws-load-balancer-controller/releases/tag/v2.11.0\r\n\r\n> We've updated the reference IAM policies to explicitly add the elasticloadbalancing:DescribeCapacityReservation and elasticloadbalancing:ModifyCapacityReservation permissions for describing and modifying capacity reservation. Please be sure to apply the latest IAM policy when upgrading.\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -854,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n \"elasticloadbalancing:DescribeListenerAttributes\",\n+ \"elasticloadbalancing:DescribeCapacityReservation\",\n ]\n resources = [\"*\"]\n }\n@@ -1016,6 +1017,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n+ \"elasticloadbalancing:ModifyCapacityReservation\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -854,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n \"elasticloadbalancing:DescribeListenerAttributes\",\n+ \"elasticloadbalancing:DescribeCapacityReservation\",\n ]\n resources = [\"*\"]\n }\n@@ -1016,6 +1017,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n+ \"elasticloadbalancing:ModifyCapacityReservation\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -854,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n \"elasticloadbalancing:DescribeListenerAttributes\",\n+ \"elasticloadbalancing:DescribeCapacityReservation\",\n ]\n resources = [\"*\"]\n }\n@@ -1016,6 +1017,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n+ \"elasticloadbalancing:ModifyCapacityReservation\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -854,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n \"elasticloadbalancing:DescribeListenerAttributes\",\n+ \"elasticloadbalancing:DescribeCapacityReservation\",\n ]\n resources = [\"*\"]\n }\n@@ -1016,6 +1017,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n \"elasticloadbalancing:ModifyListenerAttributes\",\n+ \"elasticloadbalancing:ModifyCapacityReservation\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nUpdate to the AWS Load Balancer Controller Policy\r\n\r\n## Motivation and Context\r\nSee details at kubernetes-sigs/aws-load-balancer-controller#3921\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -840,6 +840,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n @@ \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n+ \"ec2:GetSecurityGroupsForVpc\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -840,6 +840,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeTags\",\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n+ \"ec2:GetSecurityGroupsForVpc\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -840,6 +840,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeTags\",\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n+ \"ec2:GetSecurityGroupsForVpc\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -840,6 +840,7 @@ \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"ec2:DescribeTags\",\n \"ec2:GetCoipPoolUsage\",\n \"ec2:DescribeCoipPools\",\n+ \"ec2:GetSecurityGroupsForVpc\",\n \"elasticloadbalancing:DescribeLoadBalancers\",\n \"elasticloadbalancing:DescribeLoadBalancerAttributes\",\n \"elasticloadbalancing:DescribeListeners\",\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nMountpoint S3 CSI Driver was added to the list of optional supported policies in the Readme. \r\n\r\n## Motivation and Context\r\nThe policy already exists but is not in the documentation. Only in the list of inputs is the Mountpoint S3 CSI Driver described in the readme. This prevents the assumption that the Mountpoint S3 CSI Driver policy is not supported.\r\n\r\n## Breaking Changes\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -15,6 +15,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n - [App Mesh Envoy Proxy](https://raw.githubusercontent.com/aws/aws-app-mesh-controller-for-k8s/master/config/iam/envoy-iam-policy.json)\n - [Managed Service for Prometheus](https://docs.aws.amazon.com/prometheus/latest/userguide/set-up-irsa.html)\n+- [Mountpoint S3 CSI Driver](https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md#iam-permissions)\n - [Node AWS Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Velero](https://github.com/vmware-tanzu/velero-plugin-for-aws#option-1-set-permissions-with-an-iam-user)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -15,6 +15,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n S3 - [App Mesh Envoy Proxy](https://raw.githubusercontent.com/aws/aws-app-mesh-controller-for-k8s/master/config/iam/envoy-iam-policy.json)\n - [Managed Service for Prometheus](https://docs.aws.amazon.com/prometheus/latest/userguide/set-up-irsa.html)\n+- [Mountpoint S3 CSI Driver](https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md#iam-permissions)\n - [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Velero](https://github.com/vmware-tanzu/velero-plugin-for-aws#option-1-set-permissions-with-an-iam-user)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -15,6 +15,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n - [App Mesh Envoy Proxy](https://raw.githubusercontent.com/aws/aws-app-mesh-controller-for-k8s/master/config/iam/envoy-iam-policy.json)\n - [Managed Service for Prometheus](https://docs.aws.amazon.com/prometheus/latest/userguide/set-up-irsa.html)\n+- [Mountpoint S3 CSI [VPC - [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Velero](https://github.com/vmware-tanzu/velero-plugin-for-aws#option-1-set-permissions-with-an-iam-user)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -15,6 +15,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n - [App Mesh Envoy Proxy](https://raw.githubusercontent.com/aws/aws-app-mesh-controller-for-k8s/master/config/iam/envoy-iam-policy.json)\n - [Managed Service for Prometheus](https://docs.aws.amazon.com/prometheus/latest/userguide/set-up-irsa.html)\n+- [Mountpoint S3 CSI Driver](https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md#iam-permissions)\n - [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Velero](https://github.com/vmware-tanzu/velero-plugin-for-aws#option-1-set-permissions-with-an-iam-user)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nAdd functionality to interpolate resource arns to use local.partition instead of hardcoded value of \"aws\" to prevent breaking non-commercial use cases.\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nUpdated previously changed values to use local.partition instead of hardcoded 'aws' reference.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nResolves #531 \r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nThis shouldn't be a breaking change and is using a pattern that exists other places in the policies.tf file.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\nTested with project that was previously broken by a previous update to validate fix.\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\nRan \r\n\r\n\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = = resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -235,7 +235,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n }\n \n statement {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" +213,7 \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -235,7 +235,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n }\n \n statement {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -235,7 +235,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n }\n \n statement {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:volume/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -235,7 +235,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ resources = [\"arn:${local.partition}:ec2:*:*:snapshot/*\"]\n }\n \n statement {\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nUpdate to the EBS CSI Driver IAM Policy\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nSee details at https://github.com/kubernetes-sigs/aws-ebs-csi-driver/issues/2190\r\n\r\nCopied changes from https://github.com/kubernetes-sigs/aws-ebs-csi-driver/pull/2163\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -233,6 +233,11 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:CreateVolume\"]\n+ resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ }\n+\n statement {\n actions = [\"ec2:DeleteVolume\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -233,6 +233,11 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:CreateVolume\"]\n+ resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ }\n+\n statement {\n actions = [\"ec2:DeleteVolume\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -233,6 +233,11 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:CreateVolume\"]\n+ resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ }\n+\n statement {\n actions = [\"ec2:DeleteVolume\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -200,7 +200,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -213,7 +213,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n statement {\n actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n+ resources = [\"arn:aws:ec2:*:*:volume/*\"]\n \n condition {\n test = \"StringLike\"\n@@ -233,6 +233,11 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:CreateVolume\"]\n+ resources = [\"arn:aws:ec2:*:*:snapshot/*\"]\n+ }\n+\n statement {\n actions = [\"ec2:DeleteVolume\"]\n resources = [\"*\"]\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nFixes creating roles with name prefix AND inline policy.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n`name_prefix` attribute in inline policy resource contained `var.role_name`, which could be `null` when `var.role_name_prefix` is used instead. It is also not possible to set both `var.role_name` and `var.role_name_prefix`, which causes an error for `aws_iam_role` resource. Having `var.role_name` in inline policy's `name_prefix` is redundant because it is part of the role itself and can't be used outside of the role's context, so it is safe to remove.\r\n\r\nThere is actually an example in https://github.com/terraform-aws-modules/terraform-aws-iam/blob/e13cb1e5d1356ccb2ddd1bae0ad4c3a17e88eee2/examples/iam-assumable-role/main.tf with both `role_name_prefix` and `inline_policy_statements` vars set, which fails for me with `The expression result is null. Cannot include a null value in a string template.` error, not sure why it wasn't detected earlier, I guess it might depend on Terraform version.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -175,6 +175,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : name_prefix \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\nmodules/iam-assumable-role/main.tf\n@@ -255,6 +255,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -175,6 +175,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\nmodules/iam-assumable-role/main.tf\n@@ -255,6 +255,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -175,6 : @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\nmodules/iam-assumable-role/main.tf\n@@ -255,6 +255,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -175,6 +175,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n \n role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\nmodules/iam-assumable-role/main.tf\n@@ -255,6 +255,6 @@ resource \"aws_iam_role_policy\" \"inline\" {\n count = local.create_iam_role_inline_policy ? 1 : 0\n = role = aws_iam_role.this[0].name\n- name_prefix = \"${var.role_name}_inline_\"\n+ name_prefix = \"inline-\"\n policy = data.aws_iam_policy_document.inline[0].json\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\n\n- Update CI workflow versions to latest\n\n## Motivation and Context\n\n- Updates our workflows to use the latest versions\n- Removes warnings for Python 3.12 in runners\n\n## Breaking Changes\n\n- No\n\n## How Has This Been Tested?\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\n- [x] I have executed `pre-commit run -a` on my pull request\n\n\n---\n\nChoice A:\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.4.0\n+ - uses: amannn/action-semantic-pull-request@v5.5.3\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -45,14 +45,14 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: Terraform matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -92,7 +92,7 @@ jobs:\n sudo apt-get -qq remove -y 'postgresql-.*'\n sudo apt-get -qq remove -y 'php.*'\n sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox powershell mono-devel\n+ sudo apt-get -qq remove -y kubectl firefox mono-devel\n sudo apt-get -qq autoremove -y\n sudo apt-get -qq clean\n df -h\n@@ -105,10 +105,10 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.pre-commit-config.yaml\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_workspace_remote'\n - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.6.0\n+ rev: v5.0.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n\nChoice B:\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.4.0\n+ - uses: amannn/action-semantic-pull-request@v5.5.3\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -45,14 +45,14 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -92,7 +92,7 @@ jobs:\n sudo apt-get -qq remove -y 'postgresql-.*'\n sudo apt-get -qq remove -y 'php.*'\n sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox powershell mono-devel\n+ sudo apt-get -qq remove -y kubectl firefox mono-devel\n sudo apt-get -qq autoremove -y\n sudo apt-get -qq clean\n df -h\n@@ -105,10 +105,10 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.pre-commit-config.yaml\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_workspace_remote'\n - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.6.0\n+ rev: v5.0.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n\nChoice C:\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.4.0\n+ - uses: amannn/action-semantic-pull-request@v5.5.3\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -45,14 +45,14 @@ jobs:\n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -92,7 +92,7 @@ jobs:\n sudo apt-get -qq remove -y 'postgresql-.*'\n sudo apt-get -qq remove -y 'php.*'\n sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox powershell mono-devel\n+ sudo apt-get -qq remove -y kubectl firefox mono-devel\n sudo apt-get -qq autoremove -y\n sudo apt-get -qq clean\n df -h\n@@ -105,10 +105,10 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.pre-commit-config.yaml\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_workspace_remote'\n - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.6.0\n+ rev: v5.0.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n\nChoice D:\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.4.0\n+ - uses: amannn/action-semantic-pull-request@v5.5.3\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -45,14 +45,14 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -92,7 +92,7 @@ jobs:\n sudo apt-get -qq remove -y 'postgresql-.*'\n sudo apt-get -qq remove -y 'php.*'\n sudo apt-get -qq remove -y 'temurin-.*'\n- sudo apt-get -qq remove -y kubectl firefox powershell mono-devel\n+ sudo apt-get -qq remove -y kubectl firefox mono-devel\n sudo apt-get -qq autoremove -y\n sudo apt-get -qq clean\n df -h\n@@ -105,10 +105,10 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.3.0\n+ uses: clowdhaus/terraform-min-max@v1.3.1\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.pre-commit-config.yaml\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_workspace_remote'\n - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.6.0\n+ rev: v5.0.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nThis PR is to update the iam-role-for-service-accounts-eks module to add additional permissions when attach_load_balancer_controller_policy is set to true.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nAddresses https://github.com/terraform-aws-modules/terraform-aws-iam/issues/524. Stems from upstream updates to https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json that have not yet been ported into this module.\r\n\r\nResolves #524 \r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ x ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ x ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ x ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -846,6 +846,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n+ \"elasticloadbalancing:DescribeListenerAttributes\",\n ]\n +846,7 resources = [\"*\"]\n }\n@@ -1007,6 +1008,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n+ \"elasticloadbalancing:ModifyListenerAttributes\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -846,6 +846,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n+ \"elasticloadbalancing:DescribeListenerAttributes\",\n ]\n resources = [\"*\"]\n }\n@@ -1007,6 +1008,7 @@ data \"aws_iam_policy_document\" {\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n+ \"elasticloadbalancing:ModifyListenerAttributes\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -846,6 +846,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n+ \"elasticloadbalancing:DescribeListenerAttributes\",\n ]\n resources = [\"*\"]\n }\n@@ -1007,6 +1008,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n+ \"elasticloadbalancing:ModifyListenerAttributes\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -846,6 +846,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n \"elasticloadbalancing:DescribeTrustStores\",\n+ \"elasticloadbalancing:DescribeListenerAttributes\",\n ]\n resources = [\"*\"]\n }\n@@ -1007,6 +1008,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:DeleteTargetGroup\",\n+ \"elasticloadbalancing:ModifyListenerAttributes\",\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n- Allow modifying the `iam-github-oidc-role` subject condition\r\n\r\n## Motivation and Context\r\n- Resolves #522\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-role/README.md\n@@ -93,6 +93,7 @@ No modules.\n | <a name=\"input_permissions_boundary_arn\"></a> [permissions\\_boundary\\_arn](#input\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `null` | no |\n | <a name=\"input_policies\"></a> [policies](#input\\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"token.actions.githubusercontent.com\"` | no |\n+| <a name=\"input_subject_condition\"></a> [subject\\_condition](#input\\_subject\\_condition) | Condition to use for the GitHub OIDC role. Defaults to `StringLike` | `string` | `\"StringLike\"` | no |\n | <a name=\"input_subjects\"></a> [subjects](#input\\_subjects) | List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']` | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n \n---\nmodules/iam-github-oidc-role/main.tf\n@@ -42,7 +42,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringLike\"\n+ test = var.subject_condition\n variable = \"${local.provider_url}:sub\"\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -68,6 +68,12 @@ variable \"audience\" {\n default = \"sts.amazonaws.com\"\n }\n \n+variable \"subject_condition\" {\n+ description = \"Condition to use for the GitHub OIDC role. Defaults to `StringLike`\"\n+ type = string\n+ default = \"StringLike\"\n+}\n+\n variable \"subjects\" {\n description = \"List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']`\"\n \"StringLike\")\n type = list(string)\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -14,6 +14,7 @@ module \"wrapper\" {\n permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n policies = try(each.value.policies, var.defaults.policies, {})\n provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n subjects = try(each.value.subjects, var.defaults.subjects, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-role/README.md\n@@ -93,6 +93,7 @@ No modules.\n | <a name=\"input_permissions_boundary_arn\"></a> [permissions\\_boundary\\_arn](#input\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `null` | no |\n | <a name=\"input_policies\"></a> [policies](#input\\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"token.actions.githubusercontent.com\"` | no |\n+| <a name=\"input_subject_condition\"></a> [subject\\_condition](#input\\_subject\\_condition) | Condition to use for the GitHub OIDC role. Defaults to `StringLike` | `string` | `\"StringLike\"` | no |\n | <a name=\"input_subjects\"></a> [subjects](#input\\_subjects) | List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']` | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n \n---\nmodules/iam-github-oidc-role/main.tf\n@@ -42,7 +42,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringLike\"\n+ test = var.subject_condition\n variable = \"${local.provider_url}:sub\"\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -68,6 +68,12 @@ variable \"audience\" {\n default = \"sts.amazonaws.com\"\n }\n \n+variable \"subject_condition\" {\n+ description = \"Condition to use for the GitHub OIDC role. Defaults to `StringLike`\"\n+ type = string\n+ default = \"StringLike\"\n+}\n+\n variable \"subjects\" {\n description = \"List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']`\"\n type = list(string)\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -14,6 +14,7 @@ module \"wrapper\" {\n permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n policies = try(each.value.policies, var.defaults.policies, {})\n provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n subjects = try(each.value.subjects, var.defaults.subjects, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-role/README.md\n@@ -93,6 +93,7 @@ No modules.\n | <a name=\"input_permissions_boundary_arn\"></a> [permissions\\_boundary\\_arn](#input\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `null` | no |\n | <a name=\"input_policies\"></a> [policies](#input\\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | The URL of the identity provider. Corresponds to the iss cases | `string` | `\"token.actions.githubusercontent.com\"` | no |\n+| <a name=\"input_subject_condition\"></a> [subject\\_condition](#input\\_subject\\_condition) | Condition to use for the GitHub OIDC role. Defaults to `StringLike` | `string` | `\"StringLike\"` | no |\n | <a name=\"input_subjects\"></a> [subjects](#input\\_subjects) | List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']` | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n \n---\nmodules/iam-github-oidc-role/main.tf\n@@ -42,7 +42,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringLike\"\n+ test = var.subject_condition\n variable = \"${local.provider_url}:sub\"\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -68,6 +68,12 @@ variable \"audience\" {\n default = \"sts.amazonaws.com\"\n }\n \n+variable \"subject_condition\" {\n+ description = \"Condition to use for the GitHub OIDC role. Defaults to `StringLike`\"\n+ type = string\n+ default = \"StringLike\"\n+}\n+\n variable \"subjects\" {\n description = \"List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']`\"\n type = list(string)\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -14,6 +14,7 @@ module \"wrapper\" {\n permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n policies = try(each.value.policies, var.defaults.policies, {})\n provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n subjects = try(each.value.subjects, var.defaults.subjects, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-role/README.md\n@@ -93,6 +93,7 @@ No modules.\n | <a name=\"input_permissions_boundary_arn\"></a> [permissions\\_boundary\\_arn](#input\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `null` | no |\n | <a name=\"input_policies\"></a> [policies](#input\\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"token.actions.githubusercontent.com\"` | no |\n+| <a name=\"input_subject_condition\"></a> [subject\\_condition](#input\\_subject\\_condition) | Condition to use for the GitHub OIDC role. Defaults to `StringLike` | `string` | `\"StringLike\"` | no |\n | <a name=\"input_subjects\"></a> [subjects](#input\\_subjects) | List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']` | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n \n---\nmodules/iam-github-oidc-role/main.tf\n@@ -42,7 +42,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringLike\"\n+ test = var.subject_condition\n variable = \"${local.provider_url}:sub\"\n # Strip `repo:` to normalize for cases where users | prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -68,6 +68,12 @@ variable \"audience\" {\n default = \"sts.amazonaws.com\"\n }\n \n+variable \"subject_condition\" {\n+ description = \"Condition to use for the GitHub OIDC role. Defaults to `StringLike`\"\n+ type = string\n+ default = \"StringLike\"\n+}\n+\n variable \"subjects\" {\n description = \"List of GitHub OIDC subjects that are permitted by the trust policy. You do not need to prefix with `repo:` as this is provided. Example: `['my-org/my-repo:*', 'octo-org/octo-repo:ref:refs/heads/octo-branch']`\"\n type = list(string)\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -14,6 +14,7 @@ module \"wrapper\" {\n permissions_boundary_arn = try(each.value.permissions_boundary_arn, var.defaults.permissions_boundary_arn, null)\n policies = try(each.value.policies, var.defaults.policies, {})\n provider_url = try(each.value.provider_url, var.defaults.provider_url, \"token.actions.githubusercontent.com\")\n+ subject_condition = try(each.value.subject_condition, var.defaults.subject_condition, \"StringLike\")\n subjects = try(each.value.subjects, var.defaults.subjects, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nFixes #496, Re-Open of #497, Blocked by https://github.com/kubernetes-sigs/aws-fsx-csi-driver/pull/394\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -640,6 +640,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -640,6 +640,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -640,6 +640,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -640,6 +640,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nEnhanced the `iam-role-for-service-accounts-eks` module to support additional trusted principals including both IAM roles and users.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nTo allow an IRSA role from one service to be assumed by an IRSA role in another service, supporting cross-service role assumption.\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -48,6 +48,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n+| <a name=\"module_irsa_assumable_role_with_external_principals\"></a> [irsa\\_assumable\\_role\\_with\\_external\\_principals](#module\\_irsa\\_assumable\\_role\\_with\\_external\\_principals) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,27 @@ module \"irsa_role\" {\n tags = local.tags\n }\n \n+module \"irsa_assumable_role_with_external_principals\" {\n+ source = \"../../modules/iam-role-for-service-accounts-eks\"\n+\n+ role_name = local.name\n+ allow_self_assume_role = true\n+ additional_assumable_principal_arns = [module.irsa_role.iam_role_arn]\n+\n+ oidc_providers = {\n+ first = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ }\n+ }\n+\n+ role_policy_arns = {\n+ additional = aws_iam_policy.additional.arn\n+ }\n+\n+ tags = local.tags\n+}\n+\n module \"aws_gateway_controller_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -188,6 +188,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_assumable_principal_arns\"></a> [additional\\_assumable\\_principal\\_arns](#input\\_additional\\_assumable\\_principal\\_arns) | A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true. | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -30,7 +30,10 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = concat(\n+ [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"],\n+ var.additional_assumable_principal_arns\n+ )\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"additional_assumable_principal_arns\" {\n+ description = \"A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true.\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ additional_assumable_principal_arns = try(each.value.additional_assumable_principal_arns, var.defaults.additional_assumable_principal_arns, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -48,6 +48,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n+| <a name=\"module_irsa_assumable_role_with_external_principals\"></a> [irsa\\_assumable\\_role\\_with\\_external\\_principals](#module\\_irsa\\_assumable\\_role\\_with\\_external\\_principals) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,27 @@ module \"irsa_role\" {\n tags = local.tags\n }\n \n+module \"irsa_assumable_role_with_external_principals\" {\n+ source = \"../../modules/iam-role-for-service-accounts-eks\"\n+\n+ role_name = local.name\n+ allow_self_assume_role = true\n+ additional_assumable_principal_arns = [module.irsa_role.iam_role_arn]\n+\n+ oidc_providers = {\n+ first = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ }\n+ }\n+\n+ role_policy_arns = {\n+ additional = aws_iam_policy.additional.arn\n+ }\n+\n+ tags = local.tags\n+}\n+\n module \"aws_gateway_controller_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -188,6 +188,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_assumable_principal_arns\"></a> [additional\\_assumable\\_principal\\_arns](#input\\_additional\\_assumable\\_principal\\_arns) | A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true. | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -30,7 +30,10 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = concat(\n+ [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"],\n+ var.additional_assumable_principal_arns\n+ )\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"additional_assumable_principal_arns\" {\n+ description = \"A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true.\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ additional_assumable_principal_arns = try(each.value.additional_assumable_principal_arns, var.defaults.additional_assumable_principal_arns, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -48,6 +48,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n+| <a name=\"module_irsa_assumable_role_with_external_principals\"></a> [irsa\\_assumable\\_role\\_with\\_external\\_principals](#module\\_irsa\\_assumable\\_role\\_with\\_external\\_principals) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,27 @@ module \"irsa_role\" {\n tags = local.tags\n }\n \n+module \"irsa_assumable_role_with_external_principals\" {\n+ source = \"../../modules/iam-role-for-service-accounts-eks\"\n+\n+ role_name = local.name\n+ allow_self_assume_role = true\n+ additional_assumable_principal_arns = [module.irsa_role.iam_role_arn]\n+\n+ oidc_providers = {\n+ first = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ }\n+ }\n+\n+ role_policy_arns = {\n+ additional = aws_iam_policy.additional.arn\n+ }\n+\n+ tags = local.tags\n+}\n+\n module \"aws_gateway_controller_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -188,6 +188,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_assumable_principal_arns\"></a> [additional\\_assumable\\_principal\\_arns](#input\\_additional\\_assumable\\_principal\\_arns) | A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true. | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -30,7 +30,10 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = concat(\n+ [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"],\n+ var.additional_assumable_principal_arns\n+ )\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"additional_assumable_principal_arns\" {\n+ description = \"A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true.\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ additional_assumable_principal_arns = try(each.value.additional_assumable_principal_arns, var.defaults.additional_assumable_principal_arns, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -48,6 +48,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n+| <a name=\"module_irsa_assumable_role_with_external_principals\"></a> [irsa\\_assumable\\_role\\_with\\_external\\_principals](#module\\_irsa\\_assumable\\_role\\_with\\_external\\_principals) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,27 @@ module \"irsa_role\" {\n tags = local.tags\n }\n \n+module \"irsa_assumable_role_with_external_principals\" {\n+ source = \"../../modules/iam-role-for-service-accounts-eks\"\n+\n+ role_name = local.name\n+ allow_self_assume_role = true\n+ additional_assumable_principal_arns = [module.irsa_role.iam_role_arn]\n+\n+ oidc_providers = {\n+ first = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ }\n+ }\n+\n+ role_policy_arns = {\n+ additional = aws_iam_policy.additional.arn\n+ }\n+\n+ tags = local.tags\n+}\n+\n module \"aws_gateway_controller_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -188,6 +188,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_assumable_principal_arns\"></a> [additional\\_assumable\\_principal\\_arns](#input\\_additional\\_assumable\\_principal\\_arns) | A list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true. | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -30,7 +30,10 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = concat(\n+ [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"],\n+ var.additional_assumable_principal_arns\n+ )\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"additional_assumable_principal_arns\" {\n+ description = -3,6 list of additional trusted AWS Principals (IAM roles and users) allowed to assume this role, applied only if `allow_self_assume_role` is true.\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ additional_assumable_principal_arns = try(each.value.additional_assumable_principal_arns, var.defaults.additional_assumable_principal_arns, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nExtended functionality of `iam-assumable-role-with-oidc` to also allow assuming the role by trusted AWS principals\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nIn some cases, it's needed to extend the trust policy of a role that gets assumed with OIDC to also be assumed by trusted principals in AWS. In my case, I need to allow some principals to assume the target roles locally without using OIDC, while maintaining the ability for a federated assumed role and without duplicating the role with different trust policies.\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -34,6 +34,8 @@ No providers.\n | <a name=\"module_iam_assumable_role_inline_policy\"></a> [iam\\_assumable\\_role\\_inline\\_policy](#module\\_iam\\_assumable\\_role\\_inline\\_policy) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_provider_trust_policy_conditions\"></a> [iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions](#module\\_iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_actions\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_actions](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_actions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_roles\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_roles](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_roles) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -120,3 +120,57 @@ module \"iam_assumable_role_provider_trust_policy_conditions\" {\n }\n ]\n }\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_roles\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-roles\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-roles\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_actions\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-actions\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-actions\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -60,6 +60,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -38,6 +38,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) > 0 ? [1] : []\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = var.trusted_role_actions\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n for_each = local.urls\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -22,6 +22,18 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"trusted_role_actions\" {\n+ description = \"Additional trusted role actions\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+}\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of {\n entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to IAM role resources\"\n type = map(string)\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -23,4 +23,6 @@ module \"wrapper\" {\n role_permissions_boundary_arn = try(each.value.role_permissions_boundary_arn, var.defaults.role_permissions_boundary_arn, \"\")\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n+ trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n+ trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -34,6 +34,8 @@ No providers.\n | <a name=\"module_iam_assumable_role_inline_policy\"></a> [iam\\_assumable\\_role\\_inline\\_policy](#module\\_iam\\_assumable\\_role\\_inline\\_policy) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_provider_trust_policy_conditions\"></a> [iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions](#module\\_iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_actions\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_actions](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_actions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_roles\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_roles](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_roles) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -120,3 +120,57 @@ module \"iam_assumable_role_provider_trust_policy_conditions\" {\n }\n ]\n }\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_roles\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-roles\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-roles\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_actions\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-actions\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-actions\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -60,6 +60,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -38,6 +38,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) > 0 ? [1] : []\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = var.trusted_role_actions\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n for_each = local.urls\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -22,6 +22,18 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"trusted_role_actions\" {\n+ description = \"Additional trusted role actions\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+}\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to IAM role resources\"\n type = map(string)\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -23,4 +23,6 @@ module \"wrapper\" {\n role_permissions_boundary_arn = try(each.value.role_permissions_boundary_arn, var.defaults.role_permissions_boundary_arn, \"\")\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n+ trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n+ trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -34,6 +34,8 @@ No providers.\n | <a name=\"module_iam_assumable_role_inline_policy\"></a> [iam\\_assumable\\_role\\_inline\\_policy](#module\\_iam\\_assumable\\_role\\_inline\\_policy) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_provider_trust_policy_conditions\"></a> [iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions](#module\\_iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | role_policy_arns name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_actions\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_actions](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_actions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_roles\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_roles](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_roles) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -120,3 +120,57 @@ module \"iam_assumable_role_provider_trust_policy_conditions\" {\n }\n ]\n }\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_roles\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-roles\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-roles\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_actions\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-actions\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-actions\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -60,6 +60,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -38,6 +38,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) > 0 ? [1] : []\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = var.trusted_role_actions\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n for_each = local.urls\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -22,6 +22,18 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"trusted_role_actions\" {\n+ description = \"Additional trusted role actions\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+}\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to IAM role resources\"\n type = map(string)\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -23,4 +23,6 @@ module \"wrapper\" {\n role_permissions_boundary_arn = try(each.value.role_permissions_boundary_arn, var.defaults.role_permissions_boundary_arn, \"\")\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n+ trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n+ trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -34,6 +34,8 @@ No providers.\n | <a name=\"module_iam_assumable_role_inline_policy\"></a> [iam\\_assumable\\_role\\_inline\\_policy](#module\\_iam\\_assumable\\_role\\_inline\\_policy) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_provider_trust_policy_conditions\"></a> [iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions](#module\\_iam\\_assumable\\_role\\_provider\\_trust\\_policy\\_conditions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_actions\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_actions](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_actions) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_trusted_roles\"></a> [iam\\_assumable\\_role\\_with\\_trusted\\_roles](#module\\_iam\\_assumable\\_role\\_with\\_trusted\\_roles) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -120,3 +120,57 @@ module \"iam_assumable_role_provider_trust_policy_conditions\" {\n }\n ]\n }\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_roles\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-roles\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-roles\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n+\n+#####################################\n+# IAM assumable role with trusted role\n+#####################################\n+module \"iam_assumable_role_with_trusted_actions\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+ role_name = \"role-with-trusted-actions\"\n+\n+ tags = {\n+ Role = \"role-with-trusted-actions\"\n+ }\n+\n+ provider_url = \"oidc.circleci.com/org/<CIRCLECI_ORG_UUID>\"\n+ oidc_fully_qualified_audiences = [\"<CIRCLECI_ORG_UUID>\"]\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_actions = [\n+ \"sts:AssumeRole\"\n+ ]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser\",\n+ ]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -60,6 +60,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -38,6 +38,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) > 0 ? [1] : []\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = var.trusted_role_actions\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n for_each = local.urls\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -22,6 +22,18 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"trusted_role_actions\" {\n+ description = \"Additional trusted role actions\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+}\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to IAM role resources\"\n type = map(string)\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -23,4 +23,6 @@ module \"wrapper\" {\n role_permissions_boundary_arn = try(each.value.role_permissions_boundary_arn, var.defaults.role_permissions_boundary_arn, \"\")\n role_policy_arns = try(each.value.role_policy_arns, var.defaults.role_policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n+ trusted_role_actions try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n+ trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nResolves #509\r\n\r\nDefaults `enable_mfa_enforcement` to `false` as it should be an opt-in feature.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nUsers migrating from older version (example version 5.3.1) to current version may find that IAM groups users with `attach_iam_self_management_policy` set to `true` suddenly lose access to their consoles, which can cause more harm than good.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nThis change should maintain backward compatibility for users migrating from versions prior to 5.14.3. However, users having versions 5.14.3 and beyond may find that MFA enforcement no longer being enforced by default, requiring `enable_mfa_enforcement` to be explicitly set to `true`.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given. | `bool` | `false` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -35,9 +35,9 @@ variable \"custom_group_policies\" {\n }\n \n variable \"enable_mfa_enforcement\" {\n- description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given.\"\n type = bool\n- default = true\n+ default = false\n }\n \n variable \"attach_iam_self_management_policy\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given. | `bool` | `false` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -35,9 +35,9 @@ variable \"custom_group_policies\" {\n }\n \n variable \"enable_mfa_enforcement\" {\n- description = \"Determines whether permissions are added to `false` policy which requires the groups IAM users to use MFA\"\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given.\"\n type = bool\n- default = true\n+ default = false\n }\n \n variable \"attach_iam_self_management_policy\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to If to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given. | `bool` | `false` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -35,9 +35,9 @@ variable \"custom_group_policies\" {\n }\n \n variable \"enable_mfa_enforcement\" {\n- description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given.\"\n type = bool\n- default = true\n+ default = false\n }\n \n variable \"attach_iam_self_management_policy\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given. | `bool` | `false` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -35,9 +35,9 @@ variable \"custom_group_policies\" {\n }\n \n variable \"enable_mfa_enforcement\" {\n- description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA. Warning: If set to `true`, users without MFA in this group will be denied access to resources, even though permissions are given.\"\n type = bool\n- default = true\n+ default = false\n }\n \n variable \"attach_iam_self_management_policy\" name=\"input_create_group\"></a>\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nWe are in need of having the enterprise suffix in our github oidc. This change should allow us to use the terraform-aws-iam submodule with ease.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nThere are github users which use the enterprise path in the github issuer field.\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-role/main.tf\n@@ -31,8 +31,8 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = \"ForAllValues:StringEquals\"\n- variable \"token.actions.githubusercontent.com:iss\"\n- values = [\"https://token.actions.githubusercontent.com\"]\n+ variable = \"${local.provider_url}:iss\"\n+ values = [\"https://${local.provider_url}\"]\n }\n \n condition {\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-role/main.tf\n@@ -31,8 +31,8 @@ data \"aws_iam_policy_document\" \"this\" {\n \n {\n test = \"ForAllValues:StringEquals\"\n- variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"https://token.actions.githubusercontent.com\"]\n+ variable = \"${local.provider_url}:iss\"\n+ values = [\"https://${local.provider_url}\"]\n }\n \n condition {\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-role/main.tf\n@@ -31,8 +31,8 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = \"ForAllValues:StringEquals\"\n- variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"https://token.actions.githubusercontent.com\"]\n+ variable = \"${local.provider_url}:iss\"\n+ values = [\"https://${local.provider_url}\"]\n }\n \n condition {\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-role/main.tf\n@@ -31,8 +31,8 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = \"ForAllValues:StringEquals\"\n- variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"https://token.actions.githubusercontent.com\"]\n+ variable = \"${local.provider_url}:iss\"\n+ values = [\"https://${local.provider_url}\"]\n }\n \n condition {\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nFixes #496\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -628,6 +628,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\"\n ]\n resources = [\"*\"]\n \"fsx:UpdateFileSystem\"\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -628,6 +628,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -628,6 +628,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -628,6 +628,7 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"fsx:DeleteFileSystem\",\n \"fsx:DescribeFileSystems\",\n \"fsx:TagResource\",\n+ \"fsx:UpdateFileSystem\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nTo use aws:kms encryption with the Mountpoint S3 CSI driver the IAM policy needs to include kms:Decrypt and kms:GenerateDataKey permissions for the KMS key used for the bucket(s)\r\n\r\n## Motivation and Context\r\nWithout the change usage of Buckets with aws:kms encryption is not possible for Mountpoint S3 CSI driver \r\n\r\n## Breaking Changes\r\nnone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated the changes using my fork on existing infrastructure\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -233,6 +233,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_mountpoint_s3_csi_bucket_arns\"></a> [mountpoint\\_s3\\_csi\\_bucket\\_arns](#input\\_mountpoint\\_s3\\_csi\\_bucket\\_arns) | S3 bucket ARNs to allow Mountpoint S3 CSI to list buckets | `list(string)` | `[]` | no |\n+| <a name=\"input_mountpoint_s3_csi_kms_arns\"></a> [mountpoint\\_s3\\_csi\\_kms\\_arns](#input\\_mountpoint\\_s3\\_csi\\_kms\\_arns) | KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE | `list(string)` | `[]` | no |\n | <a name=\"input_mountpoint_s3_csi_path_arns\"></a> [mountpoint\\_s3\\_csi\\_path\\_arns](#input\\_mountpoint\\_s3\\_csi\\_path\\_arns) | S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true` | `list(string)` | `[]` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` ARNs `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -447,6 +447,18 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n ]\n resources = var.mountpoint_s3_csi_path_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:GenerateDataKey\",\n+ \"kms:Decrypt\"\n+ ]\n+\n+ resources = var.mountpoint_s3_csi_kms_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"mountpoint_s3_csi\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -158,6 +158,12 @@ variable \"mountpoint_s3_csi_bucket_arns\" {\n default = []\n }\n \n+variable \"mountpoint_s3_csi_kms_arns\" {\n+ description = \"KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"mountpoint_s3_csi_path_arns\" {\n description = \"S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true`\"\n type = list(string)\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -48,6 +48,7 @@ module \"wrapper\" {\n load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n mountpoint_s3_csi_bucket_arns = try(each.value.mountpoint_s3_csi_bucket_arns, var.defaults.mountpoint_s3_csi_bucket_arns, [])\n+ mountpoint_s3_csi_kms_arns = try(each.value.mountpoint_s3_csi_kms_arns, var.defaults.mountpoint_s3_csi_kms_arns, [])\n mountpoint_s3_csi_path_arns = try(each.value.mountpoint_s3_csi_path_arns, var.defaults.mountpoint_s3_csi_path_arns, [])\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -233,6 +233,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_mountpoint_s3_csi_bucket_arns\"></a> [mountpoint\\_s3\\_csi\\_bucket\\_arns](#input\\_mountpoint\\_s3\\_csi\\_bucket\\_arns) | S3 bucket ARNs to allow Mountpoint S3 CSI to list buckets | `list(string)` | `[]` | no |\n+| <a name=\"input_mountpoint_s3_csi_kms_arns\"></a> [mountpoint\\_s3\\_csi\\_kms\\_arns](#input\\_mountpoint\\_s3\\_csi\\_kms\\_arns) | KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE | `list(string)` | `[]` | no |\n | <a name=\"input_mountpoint_s3_csi_path_arns\"></a> [mountpoint\\_s3\\_csi\\_path\\_arns](#input\\_mountpoint\\_s3\\_csi\\_path\\_arns) | S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true` | `list(string)` | `[]` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -447,6 +447,18 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n ]\n resources = var.mountpoint_s3_csi_path_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:GenerateDataKey\",\n+ \"kms:Decrypt\"\n+ ]\n+\n+ resources = var.mountpoint_s3_csi_kms_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"mountpoint_s3_csi\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -158,6 +158,12 @@ variable \"mountpoint_s3_csi_bucket_arns\" {\n default = []\n }\n \n+variable \"mountpoint_s3_csi_kms_arns\" {\n+ description = \"KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"mountpoint_s3_csi_path_arns\" {\n description = \"S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true`\"\n type = list(string)\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -48,6 +48,7 @@ module \"wrapper\" {\n load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n mountpoint_s3_csi_bucket_arns items = try(each.value.mountpoint_s3_csi_bucket_arns, var.defaults.mountpoint_s3_csi_bucket_arns, [])\n+ mountpoint_s3_csi_kms_arns = try(each.value.mountpoint_s3_csi_kms_arns, var.defaults.mountpoint_s3_csi_kms_arns, [])\n mountpoint_s3_csi_path_arns = try(each.value.mountpoint_s3_csi_path_arns, var.defaults.mountpoint_s3_csi_path_arns, [])\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -233,6 +233,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_mountpoint_s3_csi_bucket_arns\"></a> [mountpoint\\_s3\\_csi\\_bucket\\_arns](#input\\_mountpoint\\_s3\\_csi\\_bucket\\_arns) | S3 bucket ARNs to allow Mountpoint S3 CSI to list buckets | `list(string)` | `[]` | no |\n+| <a name=\"input_mountpoint_s3_csi_kms_arns\"></a> [mountpoint\\_s3\\_csi\\_kms\\_arns](#input\\_mountpoint\\_s3\\_csi\\_kms\\_arns) | KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE | `list(string)` | `[]` | no |\n | <a name=\"input_mountpoint_s3_csi_path_arns\"></a> [mountpoint\\_s3\\_csi\\_path\\_arns](#input\\_mountpoint\\_s3\\_csi\\_path\\_arns) | S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true` | `list(string)` | `[]` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -447,6 +447,18 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n ]\n resources = var.mountpoint_s3_csi_path_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:GenerateDataKey\",\n+ \"kms:Decrypt\"\n+ ]\n+\n+ resources = var.mountpoint_s3_csi_kms_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"mountpoint_s3_csi\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -158,6 +158,12 @@ variable \"mountpoint_s3_csi_bucket_arns\" {\n default = []\n }\n \n+variable \"mountpoint_s3_csi_kms_arns\" {\n+ description = \"KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"mountpoint_s3_csi_path_arns\" {\n description = \"S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true`\"\n type = list(string)\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -48,6 +48,7 @@ module \"wrapper\" {\n load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n mountpoint_s3_csi_bucket_arns = try(each.value.mountpoint_s3_csi_bucket_arns, var.defaults.mountpoint_s3_csi_bucket_arns, [])\n+ mountpoint_s3_csi_kms_arns = try(each.value.mountpoint_s3_csi_kms_arns, var.defaults.mountpoint_s3_csi_kms_arns, [])\n mountpoint_s3_csi_path_arns = try(each.value.mountpoint_s3_csi_path_arns, var.defaults.mountpoint_s3_csi_path_arns, [])\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -233,6 +233,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_mountpoint_s3_csi_bucket_arns\"></a> [mountpoint\\_s3\\_csi\\_bucket\\_arns](#input\\_mountpoint\\_s3\\_csi\\_bucket\\_arns) | S3 bucket ARNs to allow Mountpoint S3 CSI to list buckets | `list(string)` | `[]` | no |\n+| <a name=\"input_mountpoint_s3_csi_kms_arns\"></a> [mountpoint\\_s3\\_csi\\_kms\\_arns](#input\\_mountpoint\\_s3\\_csi\\_kms\\_arns) | KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE | `list(string)` | `[]` | no |\n | <a name=\"input_mountpoint_s3_csi_path_arns\"></a> [mountpoint\\_s3\\_csi\\_path\\_arns](#input\\_mountpoint\\_s3\\_csi\\_path\\_arns) | S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true` | `list(string)` | `[]` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -447,6 +447,18 @@ data \"aws_iam_policy_document\" \"mountpoint_s3_csi\" {\n ]\n resources = var.mountpoint_s3_csi_path_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.mountpoint_s3_csi_kms_arns) > 0 ? Key : []\n+ content {\n+ actions = [\n+ \"kms:GenerateDataKey\",\n+ \"kms:Decrypt\"\n+ ]\n+\n+ resources = var.mountpoint_s3_csi_kms_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"mountpoint_s3_csi\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -158,6 +158,12 @@ variable \"mountpoint_s3_csi_bucket_arns\" {\n default = []\n }\n \n+variable \"mountpoint_s3_csi_kms_arns\" {\n+ description = \"KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"mountpoint_s3_csi_path_arns\" {\n description = \"S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true`\"\n type = list(string)\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -48,6 +48,7 @@ module \"wrapper\" {\n load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n mountpoint_s3_csi_bucket_arns = try(each.value.mountpoint_s3_csi_bucket_arns, var.defaults.mountpoint_s3_csi_bucket_arns, [])\n+ mountpoint_s3_csi_kms_arns = try(each.value.mountpoint_s3_csi_kms_arns, var.defaults.mountpoint_s3_csi_kms_arns, [])\n mountpoint_s3_csi_path_arns = try(each.value.mountpoint_s3_csi_path_arns, var.defaults.mountpoint_s3_csi_path_arns, [])\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR configures properly the policy to use `StringEquals` when using fully qualified audiences and uses `StringLike` when using newly added var for wildcards `oidc_audiences_with_wildcards`.\r\n\r\n## Motivation and Context\r\nThis should do what the user is expecting (Configuring exact audiences), although the `StringLike` works it might not be the user's expectation.\r\n\r\n## Breaking Changes\r\nThis is a breaking change for people that could have configured wildcards using `oidc_fully_qualified_audiences` variable as it will now configure `StringEquals` as conditional.\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -47,6 +47,7 @@ No modules.\n | <a name=\"input_inline_policy_statements\"></a> [inline\\_policy\\_statements](#input\\_inline\\_policy\\_statements) | List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy | `any` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | <a name=\"input_number_of_role_policy_arns\"></a> [number\\_of\\_role\\_policy\\_arns](#input\\_number\\_of\\_role\\_policy\\_arns) | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The audiences using wildcards to be added to the role policy. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_subjects\"></a> [oidc\\_fully\\_qualified\\_subjects](#input\\_oidc\\_fully\\_qualified\\_subjects) | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_subjects_with_wildcards\"></a> [oidc\\_subjects\\_with\\_wildcards](#input\\_oidc\\_subjects\\_with\\_wildcards) | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,11 +75,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_audiences_with_wildcards) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_audiences_with_wildcards\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -100,6 +100,12 @@ variable \"oidc_fully_qualified_audiences\" {\n default = []\n }\n \n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The audiences using wildcards to be added to the role policy.\"\n+ type = set(string)\n+ default = []\n+}\n+\n variable \"force_detach_policies\" {\n description = \"Whether policies should be detached from this role when destroying\"\n type = bool\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -10,6 +10,7 @@ module \"wrapper\" {\n inline_policy_statements = try(each.value.inline_policy_statements, var.defaults.inline_policy_statements, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, 3600)\n number_of_role_policy_arns = try(each.value.number_of_role_policy_arns, var.defaults.number_of_role_policy_arns, null)\n+ oidc_audiences_with_wildcards = try(each.value.oidc_audiences_with_wildcards, var.defaults.oidc_audiences_with_wildcards, [])\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n oidc_fully_qualified_subjects = try(each.value.oidc_fully_qualified_subjects, var.defaults.oidc_fully_qualified_subjects, [])\n oidc_subjects_with_wildcards = try(each.value.oidc_subjects_with_wildcards, var.defaults.oidc_subjects_with_wildcards, [])\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -47,6 +47,7 @@ No modules.\n | <a name=\"input_inline_policy_statements\"></a> [inline\\_policy\\_statements](#input\\_inline\\_policy\\_statements) | List of inline [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy | `any` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | <a name=\"input_number_of_role_policy_arns\"></a> [number\\_of\\_role\\_policy\\_arns](#input\\_number\\_of\\_role\\_policy\\_arns) | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The audiences using wildcards to be added to the role policy. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_subjects\"></a> [oidc\\_fully\\_qualified\\_subjects](#input\\_oidc\\_fully\\_qualified\\_subjects) | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_subjects_with_wildcards\"></a> [oidc\\_subjects\\_with\\_wildcards](#input\\_oidc\\_subjects\\_with\\_wildcards) | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,11 +75,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_audiences_with_wildcards) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_audiences_with_wildcards\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -100,6 +100,12 @@ variable \"oidc_fully_qualified_audiences\" {\n default = []\n }\n \n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The audiences using wildcards to be added to the role policy.\"\n+ type = set(string)\n+ default = []\n+}\n+\n variable \"force_detach_policies\" {\n description = \"Whether policies should be detached from this role when destroying\"\n type = bool\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -10,6 +10,7 @@ module \"wrapper\" {\n inline_policy_statements = try(each.value.inline_policy_statements, var.defaults.inline_policy_statements, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, 3600)\n number_of_role_policy_arns = try(each.value.number_of_role_policy_arns, var.defaults.number_of_role_policy_arns, null)\n+ oidc_audiences_with_wildcards = try(each.value.oidc_audiences_with_wildcards, var.defaults.oidc_audiences_with_wildcards, [])\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n oidc_fully_qualified_subjects = try(each.value.oidc_fully_qualified_subjects, var.defaults.oidc_fully_qualified_subjects, [])\n oidc_subjects_with_wildcards = try(each.value.oidc_subjects_with_wildcards, var.defaults.oidc_subjects_with_wildcards, [])\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -47,6 +47,7 @@ No modules.\n | <a name=\"input_inline_policy_statements\"></a> [inline\\_policy\\_statements](#input\\_inline\\_policy\\_statements) | List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy | `any` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | <a name=\"input_number_of_role_policy_arns\"></a> [number\\_of\\_role\\_policy\\_arns](#input\\_number\\_of\\_role\\_policy\\_arns) | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The audiences using wildcards to be added to the role policy. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_subjects\"></a> [oidc\\_fully\\_qualified\\_subjects](#input\\_oidc\\_fully\\_qualified\\_subjects) | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_subjects_with_wildcards\"></a> [oidc\\_subjects\\_with\\_wildcards](#input\\_oidc\\_subjects\\_with\\_wildcards) | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,11 +75,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_audiences_with_wildcards) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_audiences_with_wildcards\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -100,6 +100,12 @@ variable \"oidc_fully_qualified_audiences\" {\n default = []\n }\n \n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The audiences using wildcards to be added to the role policy.\"\n+ type = set(string)\n+ default = []\n+}\n+\n variable \"force_detach_policies\" {\n description = \"Whether policies should be detached from this role when destroying\"\n type = bool\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -10,6 +10,7 @@ module \"wrapper\" {\n inline_policy_statements = try(each.value.inline_policy_statements, var.defaults.inline_policy_statements, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, 3600)\n number_of_role_policy_arns = try(each.value.number_of_role_policy_arns, var.defaults.number_of_role_policy_arns, null)\n+ oidc_audiences_with_wildcards = try(each.value.oidc_audiences_with_wildcards, var.defaults.oidc_audiences_with_wildcards, [])\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n oidc_fully_qualified_subjects = try(each.value.oidc_fully_qualified_subjects, var.defaults.oidc_fully_qualified_subjects, [])\n oidc_subjects_with_wildcards = try(each.value.oidc_subjects_with_wildcards, var.defaults.oidc_subjects_with_wildcards, [])\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -47,6 +47,7 @@ No modules.\n | <a name=\"input_inline_policy_statements\"></a> [inline\\_policy\\_statements](#input\\_inline\\_policy\\_statements) | List of inline policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) to attach to IAM role as an inline policy | `any` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | <a name=\"input_number_of_role_policy_arns\"></a> [number\\_of\\_role\\_policy\\_arns](#input\\_number\\_of\\_role\\_policy\\_arns) | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The audiences using wildcards to be added to the role policy. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise. | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_fully_qualified_subjects\"></a> [oidc\\_fully\\_qualified\\_subjects](#input\\_oidc\\_fully\\_qualified\\_subjects) | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_oidc_subjects_with_wildcards\"></a> [oidc\\_subjects\\_with\\_wildcards](#input\\_oidc\\_subjects\\_with\\_wildcards) | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,11 +75,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_audiences_with_wildcards) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_audiences_with_wildcards\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -100,6 +100,12 @@ variable \"oidc_fully_qualified_audiences\" {\n default = []\n }\n \n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The audiences using wildcards to be added to the role policy.\"\n+ type = set(string)\n+ default = []\n+}\n+\n variable \"force_detach_policies\" {\n description = \"Whether policies should be detached from this role when destroying\"\n type = bool\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -10,6 +10,7 @@ module \"wrapper\" {\n inline_policy_statements = try(each.value.inline_policy_statements, var.defaults.inline_policy_statements, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, 3600)\n number_of_role_policy_arns = try(each.value.number_of_role_policy_arns, var.defaults.number_of_role_policy_arns, null)\n+ oidc_audiences_with_wildcards = try(each.value.oidc_audiences_with_wildcards, var.defaults.oidc_audiences_with_wildcards, [])\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n oidc_fully_qualified_subjects = try(each.value.oidc_fully_qualified_subjects, var.defaults.oidc_fully_qualified_subjects, [])\n oidc_subjects_with_wildcards = try(each.value.oidc_subjects_with_wildcards, var.defaults.oidc_subjects_with_wildcards, [])\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nEnforce users to set the `role-session-name` to their user name when assuming a role. See https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/ for details.\r\n\r\n## Motivation and Context\r\n\r\nThis allows to identify user activities in AWS audit logs (e.g. EKS audit logs) based on a reliable identifier. If the user can set `role-session-name` to an arbitrary value this would not be possible.\r\n\r\n## Breaking Changes\r\n\r\nNothing.\r\n\r\n## How Has This Been Tested?\r\n\r\nI tested this using my fork in our AWS account.\r\n\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-roles/README.md\n@@ -66,6 +66,8 @@ No modules.\n | <a name=\"input_readonly_role_policy_arns\"></a> [readonly\\_role\\_policy\\_arns](#input\\_readonly\\_role\\_policy\\_arns) | List of policy ARNs to use for readonly role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/ReadOnlyAccess\"<br>]</pre> | no |\n | <a name=\"input_readonly_role_requires_mfa\"></a> [readonly\\_role\\_requires\\_mfa](#input\\_readonly\\_role\\_requires\\_mfa) | Whether readonly role requires MFA | `bool` | `true` | no |\n | <a name=\"input_readonly_role_tags\"></a> [readonly\\_role\\_tags](#input\\_readonly\\_role\\_tags) | A map of tags to add to readonly role resource. | `map(string)` | `{}` | no |\n+| <a readonly_role_tags [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-roles/main.tf\n@@ -181,6 +181,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n variable = \"aws:MultiFactorAuthAge\"\n values = [var.mfa_age]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-roles/variables.tf\n@@ -168,3 +168,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\nwrappers/iam-assumable-roles/main.tf\n@@ -28,6 +28,8 @@ module \"wrapper\" {\n readonly_role_policy_arns = try(each.value.readonly_role_policy_arns, var.defaults.readonly_role_policy_arns, [\"arn:aws:iam::aws:policy/ReadOnlyAccess\"])\n readonly_role_requires_mfa = try(each.value.readonly_role_requires_mfa, var.defaults.readonly_role_requires_mfa, true)\n readonly_role_tags = try(each.value.readonly_role_tags, var.defaults.readonly_role_tags, {})\n+ role_requires_session_name = try(each.value.role_requires_session_name, var.defaults.role_requires_session_name, false)\n+ role_session_name = try(each.value.role_session_name, var.defaults.role_session_name, [\"$${aws:username}\"])\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-roles/README.md\n@@ -66,6 +66,8 @@ No modules.\n | <a name=\"input_readonly_role_policy_arns\"></a> [readonly\\_role\\_policy\\_arns](#input\\_readonly\\_role\\_policy\\_arns) | List of policy ARNs to use for readonly role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/ReadOnlyAccess\"<br>]</pre> | no |\n | <a name=\"input_readonly_role_requires_mfa\"></a> [readonly\\_role\\_requires\\_mfa](#input\\_readonly\\_role\\_requires\\_mfa) | Whether readonly role requires MFA | `bool` | `true` | no |\n | <a name=\"input_readonly_role_tags\"></a> [readonly\\_role\\_tags](#input\\_readonly\\_role\\_tags) | A map of tags to add to readonly role resource. | `map(string)` | `{}` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-roles/main.tf\n@@ -181,6 +181,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n variable = \"aws:MultiFactorAuthAge\"\n values = [var.mfa_age]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-roles/variables.tf\n@@ -168,3 +168,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\nwrappers/iam-assumable-roles/main.tf\n@@ -28,6 +28,8 @@ module \"wrapper\" {\n readonly_role_policy_arns = try(each.value.readonly_role_policy_arns, var.defaults.readonly_role_policy_arns, [\"arn:aws:iam::aws:policy/ReadOnlyAccess\"])\n readonly_role_requires_mfa = try(each.value.readonly_role_requires_mfa, var.defaults.readonly_role_requires_mfa, true)\n readonly_role_tags = try(each.value.readonly_role_tags, var.defaults.readonly_role_tags, {})\n+ role_requires_session_name | = try(each.value.role_requires_session_name, var.defaults.role_requires_session_name, false)\n+ role_session_name = try(each.value.role_session_name, var.defaults.role_session_name, [\"$${aws:username}\"])\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-roles/README.md\n@@ -66,6 +66,8 @@ No modules.\n | <a name=\"input_readonly_role_policy_arns\"></a> [readonly\\_role\\_policy\\_arns](#input\\_readonly\\_role\\_policy\\_arns) | List of policy ARNs to use for readonly role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/ReadOnlyAccess\"<br>]</pre> | no |\n | <a name=\"input_readonly_role_requires_mfa\"></a> [readonly\\_role\\_requires\\_mfa](#input\\_readonly\\_role\\_requires\\_mfa) | Whether readonly role requires MFA | `bool` | `true` | no |\n | <a name=\"input_readonly_role_tags\"></a> [readonly\\_role\\_tags](#input\\_readonly\\_role\\_tags) | A map of tags to add to readonly role resource. | `map(string)` | `{}` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-roles/main.tf\n@@ -181,6 +181,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n variable = \"aws:MultiFactorAuthAge\"\n values = [var.mfa_age]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-roles/variables.tf\n@@ -168,3 +168,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\nwrappers/iam-assumable-roles/main.tf\n@@ -28,6 +28,8 @@ module \"wrapper\" {\n readonly_role_policy_arns = try(each.value.readonly_role_policy_arns, var.defaults.readonly_role_policy_arns, [\"arn:aws:iam::aws:policy/ReadOnlyAccess\"])\n readonly_role_requires_mfa = try(each.value.readonly_role_requires_mfa, var.defaults.readonly_role_requires_mfa, true)\n readonly_role_tags = try(each.value.readonly_role_tags, var.defaults.readonly_role_tags, {})\n+ role_requires_session_name = try(each.value.role_requires_session_name, var.defaults.role_requires_session_name, false)\n+ role_session_name = try(each.value.role_session_name, var.defaults.role_session_name, [\"$${aws:username}\"])\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n trusted_role_arns = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-roles/README.md\n@@ -66,6 +66,8 @@ No modules.\n | <a name=\"input_readonly_role_policy_arns\"></a> [readonly\\_role\\_policy\\_arns](#input\\_readonly\\_role\\_policy\\_arns) | List of policy ARNs to use for readonly role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/ReadOnlyAccess\"<br>]</pre> | no |\n | <a name=\"input_readonly_role_requires_mfa\"></a> [readonly\\_role\\_requires\\_mfa](#input\\_readonly\\_role\\_requires\\_mfa) | Whether readonly role requires MFA | `bool` | `true` | no |\n | <a name=\"input_readonly_role_tags\"></a> [readonly\\_role\\_tags](#input\\_readonly\\_role\\_tags) | A map of tags to add to readonly role resource. | `map(string)` | `{}` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional trusted role actions | `list(string)` | <pre>[<br> \"sts:AssumeRole\",<br> \"sts:TagSession\"<br>]</pre> | no |\n | <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-roles/main.tf\n@@ -181,6 +181,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n variable = \"aws:MultiFactorAuthAge\"\n values = [var.mfa_age]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-roles/variables.tf\n@@ -168,3 +168,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role (https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\nwrappers/iam-assumable-roles/main.tf\n@@ -28,6 +28,8 @@ module \"wrapper\" {\n readonly_role_policy_arns = try(each.value.readonly_role_policy_arns, var.defaults.readonly_role_policy_arns, [\"arn:aws:iam::aws:policy/ReadOnlyAccess\"])\n readonly_role_requires_mfa = try(each.value.readonly_role_requires_mfa, var.defaults.readonly_role_requires_mfa, true)\n readonly_role_tags = try(each.value.readonly_role_tags, var.defaults.readonly_role_tags, {})\n+ role_requires_session_name = try(each.value.role_requires_session_name, var.defaults.role_requires_session_name, false)\n+ role_session_name = try(each.value.role_session_name, var.defaults.role_session_name, [\"$${aws:username}\"])\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRole\", \"sts:TagSession\"])\n trusted_role_arns = = try(each.value.trusted_role_arns, var.defaults.trusted_role_arns, [])\n trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nCorrecting this to use HTTPS. Adding a pull request to remediate a potential security issue within the \"terraform-aws-modules/iam/aws//modules/iam-github-oidc-role\" module that pertains to the configuration of IAM roles for OIDC (OpenID Connect) with GitHub Actions.\r\n \r\nIssue Description:\r\nThe current implementation of the IAM role's trust relationship within the module uses an HTTP URL (http://token.actions.githubusercontent.com) in the token.actions.githubusercontent.com:iss condition. This configuration poses a security risk as the HTTP protocol is not encrypted, making it susceptible to man-in-the-middle attacks where an attacker could intercept or alter the communication.\r\n \r\nSecurity Risk:\r\nUsing HTTP allows potential attackers to intercept the authentication tokens used between GitHub Actions and AWS, leading to unauthorized actions or access within AWS resources under certain conditions. The industry best practice is to use HTTPS to ensure the integrity and confidentiality of the communication between clients and servers.\r\n \r\nSuggested Fix:\r\nTo mitigate this issue and enhance the security of the module, I recommend updating the URL in the trust policy from HTTP to HTTPS. Here is the updated snippet for your reference:\r\n \r\njson\r\nCopy code\r\n\"Condition\": {\r\n \"StringEquals\": {\r\n \"token.actions.githubusercontent.com:aud\": \"sts.amazonaws.com\",\r\n \"token.actions.githubusercontent.com:iss\": https://token.actions.githubusercontent.com\r\n }\r\n}\r\nBenefits of the Fix:\r\nUpdating to HTTPS ensures that the communication between GitHub Actions and AWS IAM via the token issuer URL is secure and encrypted, thereby safeguarding against eavesdropping and tampering by malicious entities.\r\n \r\nI believe this change will significantly enhance the security of the module and its users, aligning it with best security practices and AWS recommendations.\r\n \r\nThank you for considering this issue. I appreciate the work you have put into developing this useful module and am looking forward to the continued improvement that enhances its security and reliability. Please let me know if I can provide any further information or assistance.\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-role/main.tf\n@@ -32,7 +32,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ForAllValues:StringEquals\"\n variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"http://token.actions.githubusercontent.com\"]\n+ values = [\"https://token.actions.githubusercontent.com\"]\n }\n \n condition {\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-role/main.tf\n@@ -32,7 +32,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ForAllValues:StringEquals\"\n variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"http://token.actions.githubusercontent.com\"]\n+ values = [\"https://token.actions.githubusercontent.com\"]\n }\n \n condition {\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-role/main.tf\n@@ -32,7 +32,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n [\"https://token.actions.githubusercontent.com\"]\n test = \"ForAllValues:StringEquals\"\n variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"http://token.actions.githubusercontent.com\"]\n+ values = [\"https://token.actions.githubusercontent.com\"]\n }\n \n condition {\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-role/main.tf\n@@ -32,7 +32,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"ForAllValues:StringEquals\"\n +32,7 variable = \"token.actions.githubusercontent.com:iss\"\n- values = [\"http://token.actions.githubusercontent.com\"]\n+ values = [\"https://token.actions.githubusercontent.com\"]\n }\n \n condition {\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR adds a dynamic block and optional variable to support specifying a set of allowed `job_workflow_ref` to allow fine-grained access to a github OIDC role.\r\n\r\n## Motivation and Context\r\nCurrently, the github OIDC role module doesn't support passing `job_workflow_ref` to explicitly allow a limited set of workflows to assume an AWS IAM role through OIDC. The potential impact of this is that using this module, someone would be able to fork one of our github workflows, change the business logic and still have no issues assuming the IAM role.\r\n\r\nAt HPE, we have a local version of this module which allows us to say \"only allow a workflow to assume this IAM role if it's coming from the main branch of our organisation-wide reusable-workflows\", which isn't possible in the main branch of this module due to the lack of support.\r\n\r\n## Breaking Changes\r\nn/a, this adds a new optional variable so should extend the current functionality for those who require this feature\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] This is running in production at HPE\r\n- [x] I have executed pre-commit run -a on my pull request\r\n\n\n---\n\nChoice A:\nexamples/iam-github-oidc/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_iam_github_oidc_job_workflow_refs\"></a> [iam\\_github\\_oidc\\_job\\_workflow\\_refs](#module\\_iam\\_github\\_oidc\\_job\\_workflow\\_refs) | ../../modules/iam-github-oidc-role | n/a |\n | <a name=\"module_iam_github_oidc_provider\"></a> [iam\\_github\\_oidc\\_provider](#module\\_iam\\_github\\_oidc\\_provider) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_provider_disabled\"></a> [iam\\_github\\_oidc\\_provider\\_disabled](#module\\_iam\\_github\\_oidc\\_provider\\_disabled) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_role\"></a> [iam\\_github\\_oidc\\_role](#module\\_iam\\_github\\_oidc\\_role) | ../../modules/iam-github-oidc-role | n/a |\n---\nexamples/iam-github-oidc/main.tf\n@@ -60,6 +60,33 @@ module \"iam_github_oidc_role_disabled\" {\n create = false\n }\n \n+################################################################################\n+# GitHub OIDC Role w/ fine-grained job_workflow_refs\n+################################################################################\n+\n+module \"iam_github_oidc_job_workflow_refs\" {\n+ source = \"../../modules/iam-github-oidc-role\"\n+\n+ name = \"${local.name}-job-workflow-refs\"\n+ create = true\n+\n+ policies = {\n+ S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n+ }\n+\n+ # We can still say \"I only want these repos to be the only principals\"\n+ subjects = [\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n+\n+ # But we can now say \"Only allow them to be the principal if they're running an approved workflow from this branch\"\n+ job_workflow_refs = [\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pre-commit.yml@refs/heads/main\",\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pr-title@refs/heads/main\",\n+ ]\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-github-oidc-role/README.md\n@@ -86,6 +86,7 @@ No modules.\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n+| <a name=\"input_job_workflow_refs\"></a> [job\\_workflow\\_refs](#input\\_job\\_workflow\\_refs) | List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']` | `list(string)` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.job_workflow_refs) > 0 ? [1] : []\n+ content {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${local.provider_url}:job_workflow_ref\"\n+ values = var.job_workflow_ref\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -74,6 +74,12 @@ variable \"subjects\" {\n default = []\n }\n \n+variable \"job_workflow_refs\" {\n+ description = \"List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']`\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"provider_url\" {\n description = \"The URL of the identity provider. Corresponds to the iss claim\"\n type = string\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -7,6 +7,7 @@ module \"wrapper\" {\n create = try(each.value.create, var.defaults.create, true)\n description = try(each.value.description, var.defaults.description, null)\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ job_workflow_refs = try(each.value.job_workflow_refs, var.defaults.job_workflow_refs, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n name = try(each.value.name, var.defaults.name, null)\n name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n---\n\n\n---\n\nChoice B:\nexamples/iam-github-oidc/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_iam_github_oidc_job_workflow_refs\"></a> [iam\\_github\\_oidc\\_job\\_workflow\\_refs](#module\\_iam\\_github\\_oidc\\_job\\_workflow\\_refs) | ../../modules/iam-github-oidc-role | n/a |\n | <a name=\"module_iam_github_oidc_provider\"></a> [iam\\_github\\_oidc\\_provider](#module\\_iam\\_github\\_oidc\\_provider) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_provider_disabled\"></a> [iam\\_github\\_oidc\\_provider\\_disabled](#module\\_iam\\_github\\_oidc\\_provider\\_disabled) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_role\"></a> [iam\\_github\\_oidc\\_role](#module\\_iam\\_github\\_oidc\\_role) | ../../modules/iam-github-oidc-role | n/a |\n---\nexamples/iam-github-oidc/main.tf\n@@ -60,6 +60,33 @@ module \"iam_github_oidc_role_disabled\" {\n create = false\n }\n \n+################################################################################\n+# GitHub OIDC Role w/ fine-grained job_workflow_refs\n+################################################################################\n+\n+module \"iam_github_oidc_job_workflow_refs\" {\n+ source = \"../../modules/iam-github-oidc-role\"\n+\n+ name = \"${local.name}-job-workflow-refs\"\n+ create = true\n+\n+ policies = {\n+ S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n+ }\n+\n+ # We can still say \"I only want these repos to be the only principals\"\n+ subjects = [\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n+\n+ # But we can now say \"Only allow them to be the principal if they're running an approved workflow from this branch\"\n+ job_workflow_refs = [\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pre-commit.yml@refs/heads/main\",\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pr-title@refs/heads/main\",\n+ ]\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-github-oidc-role/README.md\n@@ -86,6 +86,7 @@ No modules.\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should resources detached from this role when destroying | `bool` | `true` | no |\n+| <a name=\"input_job_workflow_refs\"></a> [job\\_workflow\\_refs](#input\\_job\\_workflow\\_refs) | List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']` | `list(string)` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.job_workflow_refs) > 0 ? [1] : []\n+ content {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${local.provider_url}:job_workflow_ref\"\n+ values = var.job_workflow_ref\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -74,6 +74,12 @@ variable \"subjects\" {\n default = []\n }\n \n+variable \"job_workflow_refs\" {\n+ description = \"List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']`\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"provider_url\" {\n description = \"The URL of the identity provider. Corresponds to the iss claim\"\n type = string\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -7,6 +7,7 @@ module \"wrapper\" {\n create = try(each.value.create, var.defaults.create, true)\n description = try(each.value.description, var.defaults.description, null)\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ job_workflow_refs = try(each.value.job_workflow_refs, var.defaults.job_workflow_refs, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n name = try(each.value.name, var.defaults.name, null)\n name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n---\n\n\n---\n\nChoice C:\nexamples/iam-github-oidc/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_iam_github_oidc_job_workflow_refs\"></a> [iam\\_github\\_oidc\\_job\\_workflow\\_refs](#module\\_iam\\_github\\_oidc\\_job\\_workflow\\_refs) | ../../modules/iam-github-oidc-role | n/a |\n | <a name=\"module_iam_github_oidc_provider\"></a> [iam\\_github\\_oidc\\_provider](#module\\_iam\\_github\\_oidc\\_provider) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_provider_disabled\"></a> [iam\\_github\\_oidc\\_provider\\_disabled](#module\\_iam\\_github\\_oidc\\_provider\\_disabled) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_role\"></a> [iam\\_github\\_oidc\\_role](#module\\_iam\\_github\\_oidc\\_role) | ../../modules/iam-github-oidc-role | n/a |\n---\nexamples/iam-github-oidc/main.tf\n@@ -60,6 +60,33 @@ module \"iam_github_oidc_role_disabled\" {\n create = false\n }\n \n+################################################################################\n+# GitHub OIDC Role w/ fine-grained job_workflow_refs\n+################################################################################\n+\n+module \"iam_github_oidc_job_workflow_refs\" {\n+ source = \"../../modules/iam-github-oidc-role\"\n+\n+ name = \"${local.name}-job-workflow-refs\"\n+ create = true\n+\n+ policies = {\n+ S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n+ }\n+\n+ # We can still say \"I only want these repos to be the only principals\"\n+ subjects = [\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n+\n+ # But we can now say \"Only allow them to be the principal if they're running an approved workflow from this branch\"\n+ job_workflow_refs = [\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pre-commit.yml@refs/heads/main\",\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pr-title@refs/heads/main\",\n+ ]\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-github-oidc-role/README.md\n@@ -86,6 +86,7 @@ No modules.\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n+| <a name=\"input_job_workflow_refs\"></a> [job\\_workflow\\_refs](#input\\_job\\_workflow\\_refs) | List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']` | `list(string)` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.job_workflow_refs) > 0 ? [1] : []\n+ content {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${local.provider_url}:job_workflow_ref\"\n+ values = var.job_workflow_ref\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -74,6 +74,12 @@ running \"subjects\" {\n default = []\n }\n \n+variable \"job_workflow_refs\" {\n+ description = \"List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']`\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"provider_url\" {\n description = \"The URL of the identity provider. Corresponds to the iss claim\"\n type = string\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -7,6 +7,7 @@ module \"wrapper\" {\n create = try(each.value.create, var.defaults.create, true)\n description = try(each.value.description, var.defaults.description, null)\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ job_workflow_refs = try(each.value.job_workflow_refs, var.defaults.job_workflow_refs, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n name = try(each.value.name, var.defaults.name, null)\n name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n---\n\n\n---\n\nChoice D:\nexamples/iam-github-oidc/README.md\n@@ -35,6 +35,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_iam_github_oidc_job_workflow_refs\"></a> [iam\\_github\\_oidc\\_job\\_workflow\\_refs](#module\\_iam\\_github\\_oidc\\_job\\_workflow\\_refs) | ../../modules/iam-github-oidc-role | n/a |\n | <a name=\"module_iam_github_oidc_provider\"></a> [iam\\_github\\_oidc\\_provider](#module\\_iam\\_github\\_oidc\\_provider) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_provider_disabled\"></a> [iam\\_github\\_oidc\\_provider\\_disabled](#module\\_iam\\_github\\_oidc\\_provider\\_disabled) | ../../modules/iam-github-oidc-provider | n/a |\n | <a name=\"module_iam_github_oidc_role\"></a> [iam\\_github\\_oidc\\_role](#module\\_iam\\_github\\_oidc\\_role) | ../../modules/iam-github-oidc-role | n/a |\n---\nexamples/iam-github-oidc/main.tf\n@@ -60,6 +60,33 @@ module \"iam_github_oidc_role_disabled\" {\n create = false\n }\n \n+################################################################################\n+# GitHub OIDC Role w/ fine-grained job_workflow_refs\n+################################################################################\n+\n+module \"iam_github_oidc_job_workflow_refs\" {\n+ source = \"../../modules/iam-github-oidc-role\"\n+\n+ name = \"${local.name}-job-workflow-refs\"\n+ create = true\n+\n+ policies = {\n+ S3ReadOnly = \"arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess\"\n+ }\n+\n+ # We can still say \"I only want these repos to be the only principals\"\n+ subjects = [\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n+\n+ # But we can now say \"Only allow them to be the principal if they're running an approved workflow from this branch\"\n+ job_workflow_refs = [\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pre-commit.yml@refs/heads/main\",\n+ \"terraform-aws-modules/terraform-aws-iam/.github/workflows/pr-title@refs/heads/main\",\n+ ]\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-github-oidc-role/README.md\n@@ -86,6 +86,7 @@ No modules.\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n+| <a name=\"input_job_workflow_refs\"></a> [job\\_workflow\\_refs](#input\\_job\\_workflow\\_refs) | List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']` | `list(string)` | `[]` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.job_workflow_refs) > 0 ? [1] : []\n+ content {\n+ test = \"ForAllValues:StringEquals\"\n+ variable = \"${local.provider_url}:job_workflow_ref\"\n+ values = var.job_workflow_ref\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -74,6 +74,12 @@ variable \"subjects\" {\n default = []\n }\n \n+variable \"job_workflow_refs\" {\n+ description = \"List of references to workflows that should be allowed to assume an OIDC role. Allows fine-grained workflow access to an AWS account. Example `['octo-org/reusable-workflows/.github/workflows/ci-terraform.yml@refs/heads/main']`\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"provider_url\" {\n description = \"The URL of the identity provider. Corresponds to the iss claim\"\n type = string\n---\nwrappers/iam-github-oidc-role/main.tf\n@@ -7,6 +7,7 @@ module \"wrapper\" {\n create = try(each.value.create, var.defaults.create, true)\n description = try(each.value.description, var.defaults.description, null)\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, true)\n+ job_workflow_refs = try(each.value.job_workflow_refs, var.defaults.job_workflow_refs, [])\n max_session_duration = try(each.value.max_session_duration, var.defaults.max_session_duration, null)\n name = try(each.value.name, var.defaults.name, null)\n name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis pull request adds a new output for the `external_dns_policy_arn`. This output provides the ARN of the IAM policy for external-dns. This information can be useful for other parts of the codebase that need to reference this policy.\r\n\r\n## Motivation and Context\r\nThis can help in indexing and using this arn by other modules\r\n\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -78,4 +78,5 @@ No inputs.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = module.irsa_role.iam_role_unique_id\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for external-dns\"\n+ value = module.irsa_role.external_dns_policy_arn\n+}\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -256,4 +256,5 @@ No modules.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = try(aws_iam_role.this[0].unique_id, \"\")\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN Name IAM policy for external-dns\"\n+ value = try(aws_iam_policy.external_dns[0].arn, \"\")\n+}\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -78,4 +78,5 @@ No inputs.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = module.irsa_role.iam_role_unique_id\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for Path value = module.irsa_role.external_dns_policy_arn\n+}\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -256,4 +256,5 @@ No modules.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = try(aws_iam_role.this[0].unique_id, \"\")\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for external-dns\"\n+ value = try(aws_iam_policy.external_dns[0].arn, \"\")\n+}\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -78,4 +78,5 @@ No inputs.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = module.irsa_role.iam_role_unique_id\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for external-dns\"\n+ value = module.irsa_role.external_dns_policy_arn\n+}\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -256,4 +256,5 @@ No modules.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = try(aws_iam_role.this[0].unique_id, \"\")\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for external-dns\"\n+ value = try(aws_iam_policy.external_dns[0].arn, \"\")\n+}\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -78,4 +78,5 @@ No inputs.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = module.irsa_role.iam_role_unique_id\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for external-dns\"\n+ value = module.irsa_role.external_dns_policy_arn\n+}\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -256,4 +256,5 @@ No modules.\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n | <a name=\"output_iam_role_unique_id\"></a> [iam\\_role\\_unique\\_id](#output\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n+| <a name=\"output_external_dns_policy_arn\"></a> [external\\_dns\\_policy\\_arn](#output\\_external\\_dns\\_policy\\_arn) | ARN of the created External DNS IAM policy |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-role-for-service-accounts-eks/outputs.tf\n@@ -17,3 +17,8 @@ output \"iam_role_unique_id\" {\n description = \"Unique ID of IAM role\"\n value = try(aws_iam_role.this[0].unique_id, \"\")\n }\n+\n+output \"external_dns_policy_arn\" {\n+ description = \"ARN of IAM policy for external-dns\"\n+ value = try(aws_iam_policy.external_dns[0].arn, \"\")\n+}\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nUpdate VPC CNI policy to version released on 3/4/24. https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEKS_CNI_Policy.html\r\n\r\n## Description\r\nThe VPC CNI policy is missing `ec2:DescribeSubnets ` from the updated policy.\r\n\r\n## Motivation and Context\r\nThe AWS managed VPC CNI 1.18.0 uses ec2:DescribeSubnets.\r\n\r\n## Breaking Changes\r\nUpdates VPC CNI policy.\r\nOpen issue: https://github.com/terraform-aws-modules/terraform-aws-iam/issues/474\r\n\r\n## How Has This Been Tested?\r\n- I have tested with a local project. This is the Terraform plan. It shows `ec2:DescribeSubnets` being added.\r\n```\r\n# module.eks.module.vpc_cni_irsa_role.aws_iam_policy.vpc_cni[0] will be updated in-place\r\n ~ resource \"aws_iam_policy\" \"vpc_cni\" {\r\n id = \"arn:aws:iam::<redacted>:policy/AmazonEKS_CNI_Policy-20240117193907447200000001\"\r\n name = \"AmazonEKS_CNI_Policy-20240117193907447200000001\"\r\n ~ policy = jsonencode(\r\n ~ {\r\n ~ Statement = [\r\n ~ {\r\n ~ Action = [\r\n # (3 unchanged elements hidden)\r\n \"ec2:DescribeTags\",\r\n + \"ec2:DescribeSubnets\",\r\n \"ec2:DescribeNetworkInterfaces\",\r\n # (6 unchanged elements hidden)\r\n ]\r\n # (3 unchanged attributes hidden)\r\n },\r\n {\r\n Action = \"ec2:CreateTags\"\r\n Effect = \"Allow\"\r\n Resource = \"arn:aws:ec2:*:*:network-interface/*\"\r\n Sid = \"CreateTags\"\r\n },\r\n ]\r\n # (1 unchanged attribute hidden)\r\n }\r\n )\r\n tags = {}\r\n # (6 unchanged attributes hidden)\r\n }\r\n```\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1443,9 +1443,10 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeSubnets\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:UnassignPrivateIpAddresses\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1443,9 +1443,10 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeSubnets\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:UnassignPrivateIpAddresses\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1443,9 +1443,10 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeSubnets\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:UnassignPrivateIpAddresses\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1443,9 +1443,10 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeSubnets\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:UnassignPrivateIpAddresses\"\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nThis permission is no longer required per karpenter documentation: https://github.com/aws/karpenter-provider-aws/blob/v0.35.2/website/content/en/docs/reference/cloudformation.md?plain=1#L345-L354\r\n\r\n## Description\r\nRemoved a single line providing excess permissions for Karpenter per Karpenter documentation: https://github.com/aws/karpenter-provider-aws/blob/v0.35.2/website/content/en/docs/reference/cloudformation.md?plain=1#L345-L354\r\n\r\n## Motivation and Context\r\nCame across this difference when setting up Karpenter SQS based spot interruption monitoring\r\n\r\n## Breaking Changes\r\nRemoving this line brings the code in line with the official Karpenter documentation. Removing it does not have any negative effects on functionality when tested on my Karpenter deployment.\r\n\r\n## How Has This Been Tested?\r\nRemoving this line does not have any negative effects on functionality when tested on my Karpenter deployment\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -760,7 +760,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n content {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:GetQueueAttributes\",\n \"sqs:GetQueueUrl\",\n \"sqs:ReceiveMessage\",\n ]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -760,7 +760,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n content {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:GetQueueAttributes\",\n \"sqs:GetQueueUrl\",\n \"sqs:ReceiveMessage\",\n ]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -760,7 +760,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n [\n content {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:GetQueueAttributes\",\n \"sqs:GetQueueUrl\",\n \"sqs:ReceiveMessage\",\n ]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -760,7 +760,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n content {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:GetQueueAttributes\",\n \"sqs:GetQueueUrl\",\n \"sqs:ReceiveMessage\",\n ]\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nRemove a duplicate line\r\n\r\n## Motivation and Context\r\nFound a duplicate line, does not affect anything but readability.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\nImplemented this change in my AWS IAM Policy with no issues (line is a duplicate).\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -670,7 +670,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateTags\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeImages\",\n- \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeImages\",\n- \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeInstanceTypes\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -670,7 +670,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateTags\",\n modules/iam-role-for-service-accounts-eks/policies.tf\n@@ \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeImages\",\n- \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeInstanceTypes\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -670,7 +670,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateTags\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeImages\",\n- \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeInstanceTypes\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -670,7 +670,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateTags\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeImages\",\n- \"ec2:DescribeImages\",\n \"karpenter_controller\" \"ec2:DescribeInstances\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeInstanceTypes\",\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis allows a user to change their own password when no MFA is present on the account. This is only needed in once situation: when a new users signs in, and is then forced to choose a new password. The MFA isn't set up at that point, and the changing of the password is blocked.\r\n\r\n## Motivation and Context\r\nCurrently users created with the iam_user and iam_group_with_policies are not able to sign in.\r\n- Resolves #471 \r\n\r\n## Breaking Changes\r\nDon't think so\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\r\nI tested this manually using a new account\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -167,7 +167,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n+ \"sts:GetSessionToken\",\n+ \"iam:ChangePassword\"\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -167,7 +167,8 @@ \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n+ \"sts:GetSessionToken\",\n+ \"iam:ChangePassword\"\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -167,7 +167,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n+ \"sts:GetSessionToken\",\n+ \"iam:ChangePassword\"\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -167,7 +167,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n+ \"sts:GetSessionToken\",\n+ \"iam:ChangePassword\"\n ]\n resources = [\"*\"]\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nAdd addition policy to enable fast snapshot restore for ebs csi\r\n\r\nrefer to this link for the details\r\n\r\nhttps://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/fast-snapshot-restores.md\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -165,6 +165,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n+ \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -165,6 +165,7 @@ \"ec2:EnableFastSnapshotRestores\"\n \"aws_iam_policy_document\" \"ebs_csi\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n+ \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -165,6 +165,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n+ \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -165,6 +165,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"ec2:DescribeTags\",\n \"ec2:DescribeVolumes\",\n \"ec2:DescribeVolumesModifications\",\n+ \"ec2:EnableFastSnapshotRestores\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nAdd an extra variable so that the assume-roles policy created by iam-group-with-assumable-roles-policy module can be customized with minimal effort: just have an optional suffix that defaults to empty so this PR is fully backwards compatible. Eg \r\n```\r\nmodule \"iam_group_with_assumable_roles_policy_production_admin\" {\r\n source = \"../../modules/iam-group-with-assumable-roles-policy\"\r\n\r\n name = \"production-admin\"\r\n assumable_roles = [module.iam_assumable_roles_in_prod.admin_iam_role_arn]\r\n assumable_roles_policy_name_suffix = \"-assumable-roles\"\r\n ...\r\n```\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nI have been using this module for many months and I really dislike the default name, which is just the group name, because I for one have IAM groups that have a policies named after them since they represenent the group's \"main permissions\". Eg if I create group `Foo`, I have policy named `Foo` that gives that group it's basic set of permissions (eg read-only permissions), and I want a policy `FooAssumeRoles` that provides the roles that can be assumed by members of that group.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\nI applied using the example, in my own AWS account, on master branch. Then I switched to my branch and re-planned: no changes. Then, I set a non-empty value to `assumable_roles_policy_name_suffix` and the diff was correct: policy would be replaced due to new name and the attachment too. \n\n---\n\nChoice A:\nexamples/iam-group-with-assumable-roles-policy/main.tf\n@@ -107,7 +107,8 @@ module \"iam_group_with_assumable_roles_policy_production_readonly\" {\n module \"iam_group_with_assumable_roles_policy_production_admin\" {\n source = \"../../modules/iam-group-with-assumable-roles-policy\"\n \n- name = \"production-admin\"\n+ name = \"production-admin\"\n+ assumable_roles_policy_name_suffix = \"-assumable-roles\"\n \n assumable_roles = [module.iam_assumable_roles_in_prod.admin_iam_role_arn]\n \n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -35,6 +35,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_assumable_roles\"></a> [assumable\\_roles](#input\\_assumable\\_roles) | List of IAM roles ARNs which can be assumed by the group | `list(string)` | `[]` | no |\n+| <a name=\"input_assumable_roles_policy_name_suffix\"></a> [assumable\\_roles\\_policy\\_name\\_suffix](#input\\_assumable\\_roles\\_policy\\_name\\_suffix) | Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name) | `string` | `\"\"` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the | `list(string)` | `[]` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM policy and IAM group | `string` | n/a | yes |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -7,7 +7,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n resource \"aws_iam_policy\" \"this\" {\n- name = var.name\n+ name = \"${var.name}${var.assumable_roles_policy_name_suffix}\"\n path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,6 +15,12 @@ variable \"assumable_roles\" {\n default = []\n }\n \n+variable \"assumable_roles_policy_name_suffix\" {\n+ description = \"Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name)\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-assumable-roles-policy/main.tf\n@@ -3,9 +3,10 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n- group_users = try(each.value.group_users, var.defaults.group_users, [])\n- name = try(each.value.name, var.defaults.name)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n+ assumable_roles_policy_name_suffix = try(each.value.assumable_roles_policy_name_suffix, var.defaults.assumable_roles_policy_name_suffix, \"\")\n+ group_users = try(each.value.group_users, var.defaults.group_users, [])\n+ name = try(each.value.name, var.defaults.name)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-group-with-assumable-roles-policy/main.tf\n@@ -107,7 +107,8 @@ module \"iam_group_with_assumable_roles_policy_production_readonly\" {\n module \"iam_group_with_assumable_roles_policy_production_admin\" {\n source = \"../../modules/iam-group-with-assumable-roles-policy\"\n \n- name = \"production-admin\"\n+ name = \"production-admin\"\n+ assumable_roles_policy_name_suffix = \"-assumable-roles\"\n \n assumable_roles = [module.iam_assumable_roles_in_prod.admin_iam_role_arn]\n \n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -35,6 +35,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_assumable_roles\"></a> [assumable\\_roles](#input\\_assumable\\_roles) | List of IAM roles ARNs which can be assumed by the group | `list(string)` | `[]` | no |\n+| <a name=\"input_assumable_roles_policy_name_suffix\"></a> [assumable\\_roles\\_policy\\_name\\_suffix](#input\\_assumable\\_roles\\_policy\\_name\\_suffix) | Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name) | `string` | `\"\"` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM policy and IAM group | `string` | n/a | yes |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -7,7 +7,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n resource \"aws_iam_policy\" \"this\" {\n- name = var.name\n+ name = \"${var.name}${var.assumable_roles_policy_name_suffix}\"\n path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,6 +15,12 @@ variable \"assumable_roles\" {\n default = []\n }\n \n+variable \"assumable_roles_policy_name_suffix\" {\n+ description = \"Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name)\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-assumable-roles-policy/main.tf\n@@ -3,9 +3,10 @@ module \"wrapper\" {\n \n = var.items\n \n- assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n- group_users = try(each.value.group_users, var.defaults.group_users, [])\n- name = try(each.value.name, var.defaults.name)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n+ assumable_roles_policy_name_suffix = try(each.value.assumable_roles_policy_name_suffix, var.defaults.assumable_roles_policy_name_suffix, \"\")\n+ group_users = try(each.value.group_users, var.defaults.group_users, [])\n+ name = try(each.value.name, var.defaults.name)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-group-with-assumable-roles-policy/main.tf\n@@ -107,7 +107,8 @@ module \"iam_group_with_assumable_roles_policy_production_readonly\" {\n module \"iam_group_with_assumable_roles_policy_production_admin\" {\n source = \"../../modules/iam-group-with-assumable-roles-policy\"\n \n- name = \"production-admin\"\n+ name = \"production-admin\"\n+ assumable_roles_policy_name_suffix = \"-assumable-roles\"\n \n assumable_roles = [module.iam_assumable_roles_in_prod.admin_iam_role_arn]\n \n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -35,6 +35,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_assumable_roles\"></a> [assumable\\_roles](#input\\_assumable\\_roles) | List of IAM roles ARNs which can be assumed by the group | `list(string)` | `[]` | no |\n+| <a name=\"input_assumable_roles_policy_name_suffix\"></a> [assumable\\_roles\\_policy\\_name\\_suffix](#input\\_assumable\\_roles\\_policy\\_name\\_suffix) | Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name) | `string` | `\"\"` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM policy and IAM group | `string` | n/a | yes |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -7,7 +7,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n resource \"aws_iam_policy\" \"this\" {\n- name = var.name\n+ name = \"${var.name}${var.assumable_roles_policy_name_suffix}\"\n path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,6 +15,12 @@ variable \"assumable_roles\" {\n default = []\n }\n \n+variable \"assumable_roles_policy_name_suffix\" {\n+ description = \"Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name)\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-assumable-roles-policy/main.tf\n@@ -3,9 +3,10 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n- group_users = try(each.value.group_users, var.defaults.group_users, [])\n- name = try(each.value.name, var.defaults.name)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n+ assumable_roles_policy_name_suffix = try(each.value.assumable_roles_policy_name_suffix, var.defaults.assumable_roles_policy_name_suffix, \"\")\n+ group_users = try(each.value.group_users, var.defaults.group_users, [])\n+ name = try(each.value.name, var.defaults.name)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-group-with-assumable-roles-policy/main.tf\n@@ -107,7 +107,8 @@ module \"iam_group_with_assumable_roles_policy_production_readonly\" {\n module \"iam_group_with_assumable_roles_policy_production_admin\" {\n source = \"../../modules/iam-group-with-assumable-roles-policy\"\n \n- name = \"production-admin\"\n+ name = \"production-admin\"\n+ assumable_roles_policy_name_suffix = \"-assumable-roles\"\n \n assumable_roles = [module.iam_assumable_roles_in_prod.admin_iam_role_arn]\n \n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -35,6 +35,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_assumable_roles\"></a> [assumable\\_roles](#input\\_assumable\\_roles) | List of IAM roles ARNs which can be assumed by the group | `list(string)` | `[]` | no |\n+| <a name=\"input_assumable_roles_policy_name_suffix\"></a> [assumable\\_roles\\_policy\\_name\\_suffix](#input\\_assumable\\_roles\\_policy\\_name\\_suffix) | Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name) | `string` | `\"\"` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM policy and IAM group | `string` | n/a | yes |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -7,7 +7,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n resource \"aws_iam_policy\" \"this\" {\n- name = var.name\n+ name = \"${var.name}${var.assumable_roles_policy_name_suffix}\"\n path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,6 +15,12 @@ variable \"assumable_roles\" {\n default = []\n name) \n+variable \"assumable_roles_policy_name_suffix\" {\n+ description = \"Append this name to the policy name that will be created for assuming the given roles (default: null -- the policy name will be group name)\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-assumable-roles-policy/main.tf\n@@ -3,9 +3,10 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n- group_users = try(each.value.group_users, var.defaults.group_users, [])\n- name = try(each.value.name, var.defaults.name)\n- path = try(each.value.path, var.defaults.path, \"/\")\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ assumable_roles = try(each.value.assumable_roles, var.defaults.assumable_roles, [])\n+ assumable_roles_policy_name_suffix = try(each.value.assumable_roles_policy_name_suffix, var.defaults.assumable_roles_policy_name_suffix, \"\")\n+ group_users = try(each.value.group_users, var.defaults.group_users, [])\n+ name = try(each.value.name, var.defaults.name)\n+ path = try(each.value.path, var.defaults.path, \"/\")\n+ tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\n\n- Update CI workflow versions to remove deprecated runtime warnings\n\n## Motivation and Context\n\n- Updates our workflows to use the latest versions\n- Removes the `deprecated runtime` warnings from the workflow execution output\n\n## Breaking Changes\n\n- No\n\n## How Has This Been Tested?\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\n- [ ] I have executed `pre-commit run -a` on my pull request\n\n\n---\n\nChoice A:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.0.2\n+ - uses: amannn/action-semantic-pull-request@v5.4.0\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -41,18 +41,18 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -81,17 +81,17 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/changelog@6.0.0\n- @semantic-release/git@10.0.0\n- conventional-changelog-conventionalcommits@4.6.3\n+ @semantic-release/changelog@6.0.3\n+ @semantic-release/git@10.0.1\n+ conventional-changelog-conventionalcommits@7.0.2\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -4,7 +4,6 @@ repos:\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nexamples/iam-group-complete/README.md\n@@ -22,7 +22,6 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n \n ## Providers\n \n---\nexamples/iam-group-complete/versions.tf\n@@ -1,10 +1,3 @@\n terraform {\n required_version = \">= 1.0\"\n-\n- required_providers {\n- aws = {\n- source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n- }\n- }\n }\n---\n\n\n---\n\nChoice B:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.0.2\n+ - uses: amannn/action-semantic-pull-request@v5.4.0\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -41,18 +41,18 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -81,17 +81,17 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/changelog@6.0.0\n- @semantic-release/git@10.0.0\n- conventional-changelog-conventionalcommits@4.6.3\n+ @semantic-release/changelog@6.0.3\n+ @semantic-release/git@10.0.1\n+ conventional-changelog-conventionalcommits@7.0.2\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -4,7 +4,6 @@ repos:\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nexamples/iam-group-complete/README.md\n@@ -22,7 +22,6 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n \n ## Providers\n \n---\nexamples/iam-group-complete/versions.tf\n@@ -1,10 +1,3 @@\n terraform {\n required_version = \">= 1.0\"\n-\n- required_providers {\n- aws = {\n- source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n- }\n- }\n }\n---\n\n\n---\n\nChoice C:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.0.2\n+ - uses: amannn/action-semantic-pull-request@v5.4.0\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -41,18 +41,18 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -81,17 +81,17 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/changelog@6.0.0\n- @semantic-release/git@10.0.0\n- conventional-changelog-conventionalcommits@4.6.3\n+ @semantic-release/changelog@6.0.3\n+ @semantic-release/git@10.0.1\n+ conventional-changelog-conventionalcommits@7.0.2\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -4,7 +4,6 @@ repos:\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n supported\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nexamples/iam-group-complete/README.md\n@@ -22,7 +22,6 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n \n ## Providers\n \n---\nexamples/iam-group-complete/versions.tf\n@@ -1,10 +1,3 @@\n terraform {\n required_version = \">= 1.0\"\n-\n- required_providers {\n- aws = {\n- source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n- }\n- }\n }\n---\n\n\n---\n\nChoice D:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/action-semantic-pull-request@v5.0.2\n+ - uses: amannn/action-semantic-pull-request@v5.4.0\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/directories@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/directories@v1.9.0\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -41,18 +41,18 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -61,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -81,17 +81,17 @@ jobs:\n rm -rf /opt/hostedtoolcache/go\n \n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/terraform-min-max@v1.2.4\n+ uses: clowdhaus/terraform-min-max@v1.3.0\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3\n+ uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/changelog@6.0.0\n- @semantic-release/git@10.0.0\n- conventional-changelog-conventionalcommits@4.6.3\n+ @semantic-release/changelog@6.0.3\n+ @semantic-release/git@10.0.1\n+ conventional-changelog-conventionalcommits@7.0.2\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -4,7 +4,6 @@ repos:\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nexamples/iam-group-complete/README.md\n@@ -22,7 +22,6 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n \n ## Providers\n \n---\nexamples/iam-group-complete/versions.tf\n@@ -1,10 +1,3 @@\n terraform {\n required_version = \">= 1.0\"\n-\n- required_providers {\n- aws = {\n- source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n- }\n- }\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR extends default self-management policy for IAM group with permissions to read account summary.\r\n\r\n## Motivation and Context\r\nThis change is necessary to have a clean view of IAM Dashboard in AWS Console for authenticated IAM user with self-management policy.\r\nIt allows to:\r\n* see AWS account general security recommendations, which is always good to have\r\n* see current AWS account ID and Alias in AWS Console, it is useful when using \"Switch Role\" wizard with account alias\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\nApplied default policy and checked through AWS Console.\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -18,7 +18,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Allow\"\n \n actions = [\n+ \"iam:GetAccountSummary\",\n \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListAccountAliases\",\n \"iam:ListVirtualMFADevices\"\n ]\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -18,7 +18,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Allow\"\n \n actions = [\n+ \"iam:GetAccountSummary\",\n \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListAccountAliases\",\n \"iam:ListVirtualMFADevices\"\n ]\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -18,7 +18,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Allow\"\n \n actions = [\n+ \"iam:GetAccountSummary\",\n \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListAccountAliases\",\n \"iam:ListVirtualMFADevices\"\n ]\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -18,7 +18,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Allow\"\n \n actions = [\n+ \"iam:GetAccountSummary\",\n \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListAccountAliases\",\n \"iam:ListVirtualMFADevices\"\n ]\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR fixes default IAM permissions for user group created by `iam-group-with-policies` module, extending it to allow users set and read own access keys description when creating them via AWS Console.\r\n\r\n## Motivation and Context\r\nThe issue with missing permissions was already addressed before by PR #287 , but the lines looks like were just lost after some major changes.\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\nBy applying the change to existing policies and checking AWS console.\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -53,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n \"iam:UpdateAccessKey\",\n- \"iam:GetAccessKeyLastUsed\"\n+ \"iam:GetAccessKeyLastUsed\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n resources = [\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -53,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:DeleteAccessKey\",\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n \"iam:UpdateAccessKey\",\n- \"iam:GetAccessKeyLastUsed\"\n+ \"iam:GetAccessKeyLastUsed\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n resources = [\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -53,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n \"iam:UpdateAccessKey\",\n- \"iam:GetAccessKeyLastUsed\"\n+ \n \"iam:GetAccessKeyLastUsed\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n resources = [\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -53,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n \"iam:UpdateAccessKey\",\n- \"iam:GetAccessKeyLastUsed\"\n+ \"iam:GetAccessKeyLastUsed\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n resources = [\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nCloses #457\r\n\r\n## Motivation and Context\r\n\r\nA new feature was added to [aws-load-balancer-controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller) in v2.7.0: [mutual TLS authentication support for Ingress](https://github.com/kubernetes-sigs/aws-load-balancer-controller/pull/3532).\r\n\r\nThis feature requires a new IAM policy permission: `elasticloadbalancing:DescribeTrustStores`.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -788,6 +788,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetGroupAttributes\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n+ \"elasticloadbalancing:DescribeTrustStores\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -788,6 +788,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetGroupAttributes\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n+ ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -788,6 +788,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetGroupAttributes\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n+ \"elasticloadbalancing:DescribeTrustStores\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -788,6 +788,7 @@ resources \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:DescribeTargetGroupAttributes\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:DescribeTags\",\n+ \"elasticloadbalancing:DescribeTrustStores\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nChecks the `attach_*_policy` variable to add a fitting description for the role. Improvement on #453 \r\n\r\n## Motivation and Context\r\nAdd a useful default description for the IAM role added\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -8,6 +8,25 @@ locals {\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ default_description = var.attach_external_dns_policy ? \"Provides OIDC provider access to Route53\" :\n+ var.attach_aws_gateway_controller_policy ? \"Provides OIDC provider access to AWS Gateway Controller\" :\n+ var.attach_cert_manager_policy ? \"Provides OIDC provider access to Cert Manager\" :\n+ var.attach_cluster_autoscaler_policy ? \"Provides OIDC provider access to Cluster Autoscaler\" :\n+ var.attach_ebs_csi_policy ? \"Provides OIDC provider access to EBS CSI\" :\n+ var.attach_efs_csi_policy ? \"Provides OIDC provider access to EFS CSI\" :\n+ var.attach_external_secrets_policy ? \"Provides OIDC provider access to Secrets Manager\" :\n+ var.attach_fsx_lustre_csi_policy ? \"Provides OIDC provider access to FSX\" :\n+ var.attach_karpenter_controller_policy ? \"Provides Karpenter access to EC2\" :\n+ var.attach_load_balancer_controller_policy ? \"Provides OIDC provider access to EC2 and Load Balancing\" :\n+ var.attach_appmesh_controller_policy ? \"Provides OIDC provider access to Appmesh, ACM, Service Discovery, and Route53\" :\n+ var.attach_appmesh_envoy_proxy_policy ? \"Provides OIDC provider access to Appmesh and ACM\" :\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Provides OIDC provider access to APS\" :\n+ var.attach_velero_policy ? \"Provides OIDC provider access to EC2 and S3\" :\n+ var.attach_vpc_cni_policy ? \"Provides OIDC provider access to EC2\" :\n+ var.attach_node_termination_handler_policy ? \"Provides OIDC provider access to EC2 and SQS\" :\n+ :\n+ var.attach_cloudwatch_observability_policy ? \"Provides OIDC provider access to CloudWatch and Xray\" :\n+ null\n+ role_description = var.role_description == null ? local.default_description : var.role_description\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n@@ -70,7 +89,7 @@ resource \"aws_iam_role\" \"this\" {\n name = var.role_name\n name_prefix = var.role_name_prefix\n path = var.role_path\n- description = var.role_description\n+ description = local.role_description\n \n assume_role_policy = data.aws_iam_policy_document.this[0].json\n max_session_duration = var.max_session_duration\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -8,6 +8,25 @@ locals {\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ default_description = var.attach_external_dns_policy ? \"Provides OIDC provider access to Route53\" :\n+ var.attach_aws_gateway_controller_policy ? \"Provides OIDC provider access to AWS Gateway Controller\" :\n+ var.attach_cert_manager_policy ? \"Provides OIDC provider access to Cert Manager\" :\n+ var.attach_cluster_autoscaler_policy ? \"Provides OIDC provider access to Cluster Autoscaler\" :\n+ var.attach_ebs_csi_policy ? \"Provides OIDC provider access to EBS CSI\" :\n+ var.attach_efs_csi_policy ? \"Provides OIDC provider access to EFS CSI\" :\n+ var.attach_external_secrets_policy ? \"Provides OIDC provider access to Secrets Manager\" :\n+ var.attach_fsx_lustre_csi_policy ? \"Provides OIDC provider access to FSX\" :\n+ var.attach_karpenter_controller_policy ? \"Provides Karpenter access to EC2\" :\n+ var.attach_load_balancer_controller_policy ? \"Provides OIDC provider access to EC2 and Load Balancing\" :\n+ var.attach_appmesh_controller_policy ? \"Provides OIDC provider access to Appmesh, ACM, Service Discovery, and Route53\" :\n+ var.attach_appmesh_envoy_proxy_policy ? \"Provides OIDC provider access to Appmesh and ACM\" :\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Provides OIDC provider access to APS\" :\n+ var.attach_velero_policy ? \"Provides OIDC provider access to EC2 and S3\" :\n+ var.attach_vpc_cni_policy ? \"Provides OIDC provider access to EC2\" :\n+ var.attach_node_termination_handler_policy ? \"Provides OIDC provider access to EC2 and SQS\" :\n+ var.attach_cloudwatch_observability_policy ? \"Provides OIDC provider access to CloudWatch and Xray\" :\n+ null\n+ role_description = var.role_description == null ? local.default_description : var.role_description\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n@@ -70,7 +89,7 @@ resource \"aws_iam_role\" \"this\" {\n name = var.role_name\n name_prefix = var.role_name_prefix\n path = var.role_path\n- description = var.role_description\n+ description = local.role_description\n \n assume_role_policy = data.aws_iam_policy_document.this[0].json\n max_session_duration = var.max_session_duration\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -8,6 +8,25 @@ locals {\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ default_description = var.attach_external_dns_policy ? \"Provides OIDC provider access to Route53\" :\n+ var.attach_aws_gateway_controller_policy ? \"Provides OIDC provider access to AWS Gateway Controller\" :\n+ var.attach_cert_manager_policy ? \"Provides OIDC provider access to Cert Manager\" :\n+ var.attach_cluster_autoscaler_policy ? \"Provides OIDC provider access to Cluster Autoscaler\" :\n+ var.attach_ebs_csi_policy ? \"Provides OIDC provider access to EBS CSI\" :\n+ var.attach_efs_csi_policy ? \"Provides OIDC provider access to EFS CSI\" :\n+ var.attach_external_secrets_policy ? \"Provides OIDC provider access to Secrets Manager\" :\n+ var.attach_fsx_lustre_csi_policy ? \"Provides OIDC provider access to FSX\" :\n+ var.attach_karpenter_controller_policy ? \"Provides Karpenter access to EC2\" :\n+ var.attach_load_balancer_controller_policy ? \"Provides OIDC provider access to EC2 and Load Balancing\" :\n+ var.attach_appmesh_controller_policy ? \"Provides OIDC provider access to Appmesh, ACM, Service Discovery, and Route53\" :\n+ var.attach_appmesh_envoy_proxy_policy ? \"Provides OIDC provider access to Appmesh and ACM\" :\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Provides OIDC provider access to APS\" :\n+ var.attach_velero_policy ? \"Provides OIDC provider access to EC2 and S3\" :\n+ var.attach_vpc_cni_policy ? \"Provides OIDC provider access to EC2\" :\n+ var.attach_node_termination_handler_policy ? \"Provides OIDC provider access to EC2 and SQS\" :\n+ var.attach_cloudwatch_observability_policy ? \"Provides OIDC provider access to CloudWatch and Xray\" :\n+ null\n+ role_description = var.role_description == null ? local.default_description : var.role_description\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n@@ -70,7 +89,7 @@ resource \"aws_iam_role\" \"this\" {\n name = var.role_name\n name_prefix = var.role_name_prefix\n path = var.role_path\n- description = var.role_description\n+ description = local.role_description\n \n assume_role_policy = data.aws_iam_policy_document.this[0].json\n max_session_duration = var.max_session_duration\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -8,6 +8,25 @@ locals {\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ default_description = var.attach_external_dns_policy ? \"Provides OIDC provider access to Route53\" :\n+ var.attach_aws_gateway_controller_policy ? \"Provides OIDC provider access to AWS Gateway Controller\" :\n+ var.attach_cert_manager_policy ? \"Provides OIDC provider access to Cert Manager\" :\n+ var.attach_cluster_autoscaler_policy ? \"Provides OIDC provider access to Cluster Autoscaler\" :\n+ var.attach_ebs_csi_policy ? \"Provides OIDC provider access to EBS CSI\" :\n+ var.attach_efs_csi_policy ? \"Provides OIDC provider access to EFS CSI\" :\n+ var.attach_external_secrets_policy ? \"Provides OIDC provider access to Secrets Manager\" :\n+ var.attach_fsx_lustre_csi_policy ? \"Provides OIDC provider access to FSX\" :\n+ var.attach_karpenter_controller_policy ? \"Provides Karpenter access to EC2\" :\n+ var.attach_load_balancer_controller_policy ? \"Provides OIDC provider access to EC2 and Load Balancing\" :\n+ var.attach_appmesh_controller_policy ? \"Provides OIDC provider access to Appmesh, ACM, Service Discovery, and Route53\" :\n+ var.attach_appmesh_envoy_proxy_policy ? \"Provides OIDC provider access to Appmesh and ACM\" :\n+ var.attach_amazon_managed_service_prometheus_policy ? \"Provides OIDC provider access to APS\" :\n+ var.attach_velero_policy ? \"Provides OIDC provider access to EC2 and S3\" :\n+ var.attach_vpc_cni_policy ? \"Provides OIDC provider access to EC2\" :\n+ var.attach_node_termination_handler_policy ? \"Provides OIDC provider access to EC2 and SQS\" :\n+ var.attach_cloudwatch_observability_policy ? \"Provides OIDC provider access to CloudWatch and Xray\" :\n+ null\n+ role_description = var.role_description == null ? local.default_description : var.role_description\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n@@ -70,7 +89,7 @@ resource \"aws_iam_role\" \"this\" {\n name = var.role_name\n name_prefix = var.role_name_prefix\n path = var.role_path\n- description = var.role_description\n+ description = local.role_description\n \n assume_role_policy = data.aws_iam_policy_document.this[0].json\n max_session_duration = var.max_session_duration\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nCreates a default role description for the oidc provider\r\n\r\n## Motivation and Context\r\nCreates more clarity and traceability for IAM roles by default\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -230,7 +230,7 @@ No modules.\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n-| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n+| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"Provides Route53 access for the external-dns oidc providers\"` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -25,7 +25,7 @@ variable \"role_permissions_boundary_arn\" {\n variable \"role_description\" {\n description = \"IAM Role description\"\n type = string\n- default = null\n+ default = \"Provides Route53 access for the external-dns oidc providers\"\n }\n \n variable \"role_name_prefix\" {\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -49,7 +49,7 @@ module \"wrapper\" {\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n policy_name_prefix = try(each.value.policy_name_prefix, var.defaults.policy_name_prefix, \"AmazonEKS_\")\n- role_description = try(each.value.role_description, var.defaults.role_description, null)\n+ role_description = try(each.value.role_description, var.defaults.role_description, \"Provides Route53 access for the external-dns oidc providers\")\n role_name = try(each.value.role_name, var.defaults.role_name, null)\n role_name_prefix = try(each.value.role_name_prefix, var.defaults.role_name_prefix, null)\n role_path = try(each.value.role_path, var.defaults.role_path, \"/\")\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -230,7 +230,7 @@ No modules.\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n-| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n+| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"Provides Route53 access for the external-dns oidc providers\"` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -25,7 +25,7 @@ variable \"role_permissions_boundary_arn\" {\n variable \"role_description\" {\n description = \"IAM Role description\"\n type = string\n- default = null\n+ default = \"Provides Route53 access for the external-dns oidc providers\"\n }\n \n variable \"role_name_prefix\" {\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -49,7 +49,7 @@ module \"wrapper\" {\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n policy_name_prefix = try(each.value.policy_name_prefix, var.defaults.policy_name_prefix, \"AmazonEKS_\")\n- role_description = try(each.value.role_description, var.defaults.role_description, null)\n+ role_description = try(each.value.role_description, var.defaults.role_description, \"Provides Route53 access for the external-dns oidc providers\")\n role_name = try(each.value.role_name, var.defaults.role_name, null)\n role_name_prefix = try(each.value.role_name_prefix, var.defaults.role_name_prefix, null)\n role_path = try(each.value.role_path, var.defaults.role_path, \"/\")\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -230,7 +230,7 @@ No modules.\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n-| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n+| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"Provides Route53 access for the external-dns oidc providers\"` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -25,7 +25,7 @@ variable \"role_permissions_boundary_arn\" {\n variable \"role_description\" {\n description = \"IAM Role description\"\n type = string\n- default = null\n+ default = \"Provides Route53 access for the external-dns oidc providers\"\n }\n \n variable \"role_name_prefix\" {\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -49,7 +49,7 @@ module \"wrapper\" {\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n policy_name_prefix = try(each.value.policy_name_prefix, var.defaults.policy_name_prefix, \"AmazonEKS_\")\n- role_description = try(each.value.role_description, var.defaults.role_description, = role_description = try(each.value.role_description, var.defaults.role_description, \"Provides Route53 access for the external-dns oidc providers\")\n role_name = try(each.value.role_name, var.defaults.role_name, null)\n role_name_prefix = try(each.value.role_name_prefix, var.defaults.role_name_prefix, null)\n role_path = try(each.value.role_path, var.defaults.role_path, \"/\")\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -230,7 +230,7 @@ No modules.\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n-| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n+| <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"Provides Route53 access for the external-dns oidc providers\"` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -25,7 +25,7 @@ variable \"role_permissions_boundary_arn\" {\n variable \"role_description\" {\n description = \"IAM Role description\"\n type = string\n- default = null\n+ default = \"Provides Route53 access for the external-dns oidc providers\"\n }\n \n variable \"role_name_prefix\" {\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -49,7 +49,7 @@ module \"wrapper\" {\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})\n policy_name_prefix = try(each.value.policy_name_prefix, var.defaults.policy_name_prefix, \"AmazonEKS_\")\n- role_description = try(each.value.role_description, var.defaults.role_description, null)\n+ role_description = try(each.value.role_description, var.defaults.role_description, \"Provides Route53 access for the external-dns oidc providers\")\n role_name = try(each.value.role_name, var.defaults.role_name, null)\n role_name_prefix = try(each.value.role_name_prefix, var.defaults.role_name_prefix, null)\n role_path = try(each.value.role_path, var.defaults.role_path, \"/\")\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThe `provider` attribute is never accessed and thus shouldn't be listed. It also changes the type of `oidc_providers` from `any` to a `map(any)` because it is a map.\r\n\r\n## Motivation and Context\r\nIt clutters the requirements for the variable and thus should be removed\r\n\r\n## Breaking Changes\r\nIf someone used to pass something into `oidc_providers` it will now throw an error at an earlier stage of validation\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -228,7 +228,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -47,7 +47,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n+ description = <a of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -228,7 +228,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -47,7 +47,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ contain +228,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -47,7 +47,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -228,7 +228,7 @@ No modules.\n | <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_policy_name_prefix\"></a> [policy\\_name\\_prefix](#input\\_policy\\_name\\_prefix) | IAM policy name prefix | `string` | `\"AmazonEKS_\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -47,7 +47,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map <a OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider_arn` and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nEnabling AWS China support for the EKS Service Accounts OIDC role.\r\nInstead of using a hardcoded audience for the `iam-role-for-service-accounts-eks` trust policy, a calculated and based on `data.aws_partition` value will be applyed.\r\n\r\n## Motivation and Context\r\nSince STS service ID differs from Global AWS to China, the policy audience condition should be different as well:\r\n`sts.amazonaws.com` => `sts.amazonaws.com.cn`\r\n\r\n## Breaking Changes\r\nNo\r\n\r\n## How Has This Been Tested?\r\n- [x] ~I have updated at least one of the `examples/*` to demonstrate and validate my change(s)~ Not affected\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_region\" \"current\" {}\n \n locals {\n+ audience ? = data.aws_partition.current.partition == \"aws-cn\" ? \"sts.amazonaws.com.cn\" : \"sts.amazonaws.com\"\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n@@ -57,7 +58,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n- values = [\"sts.amazonaws.com\"]\n+ values = [local.audience]\n }\n \n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_region\" \"current\" {}\n \n locals {\n+ audience = data.aws_partition.current.partition == \"aws-cn\" ? \"sts.amazonaws.com.cn\" : \"sts.amazonaws.com\"\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n@@ -57,7 +58,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n- values = [\"sts.amazonaws.com\"]\n+ values = [local.audience]\n }\n \n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_region\" \"current\" {}\n \n locals {\n+ audience = data.aws_partition.current.partition == \"aws-cn\" ? \"sts.amazonaws.com.cn\" : \"sts.amazonaws.com\"\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n@@ -57,7 +58,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n- values = [\"sts.amazonaws.com\"]\n+ values = [local.audience]\n }\n \n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_region\" \"current\" {}\n \n locals {\n+ audience [\"sts.amazonaws.com\"]\n+ = data.aws_partition.current.partition == \"aws-cn\" ? \"sts.amazonaws.com.cn\" : \"sts.amazonaws.com\"\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n@@ -57,7 +58,7 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n- values = [\"sts.amazonaws.com\"]\n+ values = [local.audience]\n }\n \n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nThis changes allows the user to pass role ARN's into the `iam-role-for-service-accounts-eks` module for allowing additional IAM roles to assume the created role.\r\n\r\n## Motivation and Context\r\n\r\nThis change helps to facilitate some more complex setups in EKS where other roles need to access the IRSA enabled role.\r\n\r\nFor example: Keda autoscaler with pod identity authentication, where the Keda operator Pod (with IRSA enabled) will access the target (ScaledObject) Pod's attached role.\r\n\r\n## Breaking Changes\r\n\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,6 +51,10 @@ module \"irsa_role\" {\n additional = aws_iam_policy.additional.arn\n }\n \n+ allow_additional_role_assume = [\n+ module.aws_gateway_controller_irsa_role.iam_role_arn,\n+ ]\n+\n tags = local.tags\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -184,6 +184,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allow_additional_role_assume\"></a> [allow\\_additional\\_role\\_assume](#input\\_allow\\_additional\\_role\\_assume) | A list of additional roles to allow assuming this role | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -13,6 +13,20 @@ locals {\n data \"aws_iam_policy_document\" \"this\" {\n count = var.create_role ? 1 : 0\n \n+ dynamic \"statement\" {\n+ for_each = var.allow_additional_role_assume\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ identifiers = [statement.value]\n+ type = \"AWS\"\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n@@ -59,7 +73,6 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n values = [\"sts.amazonaws.com\"]\n }\n-\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"allow_additional_role_assume\" {\n+ description = \"A list of additional roles to allow assuming this role\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ allow_additional_role_assume = try(each.value.allow_additional_role_assume, var.defaults.allow_additional_role_assume, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,6 +51,10 @@ module \"irsa_role\" {\n additional = aws_iam_policy.additional.arn\n }\n \n+ allow_additional_role_assume = [\n+ module.aws_gateway_controller_irsa_role.iam_role_arn,\n+ ]\n+\n tags = local.tags\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -184,6 +184,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allow_additional_role_assume\"></a> [allow\\_additional\\_role\\_assume](#input\\_allow\\_additional\\_role\\_assume) | A list of additional roles to allow assuming this role | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -13,6 +13,20 @@ locals {\n data \"aws_iam_policy_document\" \"this\" {\n count = var.create_role ? 1 : 0\n \n+ dynamic \"statement\" {\n+ for_each = var.allow_additional_role_assume\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ identifiers = [statement.value]\n+ type = \"AWS\"\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n@@ -59,7 +73,6 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n values = [\"sts.amazonaws.com\"]\n }\n-\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n +17,6 -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"allow_additional_role_assume\" {\n+ description = \"A list of additional roles to allow assuming this role\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ allow_additional_role_assume = try(each.value.allow_additional_role_assume, var.defaults.allow_additional_role_assume, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,6 +51,10 @@ module \"irsa_role\" {\n write additional = aws_iam_policy.additional.arn\n }\n \n+ allow_additional_role_assume = [\n+ module.aws_gateway_controller_irsa_role.iam_role_arn,\n+ ]\n+\n tags = local.tags\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -184,6 +184,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allow_additional_role_assume\"></a> [allow\\_additional\\_role\\_assume](#input\\_allow\\_additional\\_role\\_assume) | A list of additional roles to allow assuming this role | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -13,6 +13,20 @@ locals {\n data \"aws_iam_policy_document\" \"this\" {\n count = var.create_role ? 1 : 0\n \n+ dynamic \"statement\" {\n+ for_each = var.allow_additional_role_assume\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ identifiers = [statement.value]\n+ type = \"AWS\"\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n@@ -59,7 +73,6 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n values = [\"sts.amazonaws.com\"]\n }\n-\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"allow_additional_role_assume\" {\n+ description = \"A list of additional roles to allow assuming this role\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ allow_additional_role_assume = try(each.value.allow_additional_role_assume, var.defaults.allow_additional_role_assume, [])\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,6 +51,10 @@ module \"irsa_role\" {\n additional = aws_iam_policy.additional.arn\n }\n \n+ allow_additional_role_assume = [\n+ module.aws_gateway_controller_irsa_role.iam_role_arn,\n+ ]\n+\n tags = local.tags\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -184,6 +184,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allow_additional_role_assume\"></a> [allow\\_additional\\_role\\_assume](#input\\_allow\\_additional\\_role\\_assume) | A list of additional roles to allow assuming this role | `list(string)` | `[]` | no |\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_amazon_managed_service_prometheus_workspace_arns\"></a> [amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns](#input\\_amazon\\_managed\\_service\\_prometheus\\_workspace\\_arns) | List of AMP Workspace ARNs to read and write metrics | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -13,6 +13,20 @@ locals {\n data \"aws_iam_policy_document\" \"this\" {\n count = var.create_role ? 1 : 0\n \n+ dynamic \"statement\" {\n+ for_each = var.allow_additional_role_assume\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ identifiers = [statement.value]\n+ type = \"AWS\"\n+ }\n+ }\n+ }\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n@@ -59,7 +73,6 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n values = [\"sts.amazonaws.com\"]\n }\n-\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,6 @@ data \"aws_iam_policy_document\" \"aws_gateway_controller\" {\n }\n }\n \n-\n resource \"aws_iam_policy\" \"aws_gateway_controller\" {\n count = var.create_role && var.attach_aws_gateway_controller_policy ? 1 : 0\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -82,6 +82,12 @@ variable \"allow_self_assume_role\" {\n default = false\n }\n \n+variable \"allow_additional_role_assume\" {\n+ description = \"A list of additional roles to allow assuming this role\"\n+ type = list(string)\n+ default = []\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -3,6 +3,7 @@ module \"wrapper\" {\n \n for_each = var.items\n \n+ allow_additional_role_assume = try(each.value.allow_additional_role_assume, var.defaults.allow_additional_role_assume, [])\n {\n = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n amazon_managed_service_prometheus_workspace_arns = try(each.value.amazon_managed_service_prometheus_workspace_arns, var.defaults.amazon_managed_service_prometheus_workspace_arns, [\"*\"])\n assume_role_condition_test = try(each.value.assume_role_condition_test, var.defaults.assume_role_condition_test, \"StringEquals\")\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nClose #447 \r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -155,6 +155,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -155,6 +155,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -155,6 +155,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -155,6 +155,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nAs in title\r\n\r\n## Motivation and Context\r\n\r\nAllow to use EKS IAM roles for add-ons with new pod identity service that allows to run workloads without service account annotations.\r\n\r\n## Breaking Changes\r\n\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n\r\n- [x] I have updated at least one of the examples/* to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided examples/* projects\r\n- [x] I have executed `pre-commit run -a` on my pull \r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n@@ -46,6 +46,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_pod_identity_role\"></a> [iam\\_pod\\_identity\\_role](#module\\_iam\\_pod\\_identity\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -61,6 +62,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Type |\n |------|------|\n+| [aws_eks_pod_identity_association.my_app_staging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_pod_identity_association) | resource |\n | [aws_iam_policy.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -399,6 +399,26 @@ module \"iam_eks_role\" {\n }\n }\n \n+################################################################################\n+# Pod Identity Roles\n+################################################################################\n+module \"iam_pod_identity_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-pod-identity\"\n+\n+ role_policy_arns = {\n+ policy = module.iam_policy.arn\n+ }\n+}\n+\n+# This resource requires installed eks-pod-identity-agent to work\n+resource \"aws_eks_pod_identity_association\" \"my_app_staging\" {\n+ cluster_name = module.eks.cluster_name\n+ role_arn = module.iam_pod_identity_role.iam_role_arn\n+ namespace = \"default\"\n+ service_account = \"my-app-staging\"\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n@@ -438,6 +458,13 @@ module \"eks\" {\n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n \n+ cluster_addons = {\n+ # Required for Pod Identity roles\n+ eks-pod-identity-agent = {\n+ most_recent = true\n+ }\n+ }\n+\n eks_managed_node_groups = {\n default = {}\n }\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -105,13 +105,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -62,6 +62,16 @@ data \"aws_iam_policy_document\" \"this\" {\n \n }\n }\n+\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"pods.eks.amazonaws.com\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n@@ -46,6 +46,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_pod_identity_role\"></a> [iam\\_pod\\_identity\\_role](#module\\_iam\\_pod\\_identity\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -61,6 +62,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Type |\n |------|------|\n+| [aws_eks_pod_identity_association.my_app_staging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_pod_identity_association) | resource |\n | [aws_iam_policy.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -399,6 +399,26 @@ module \"iam_eks_role\" {\n }\n }\n \n+################################################################################\n+# Pod Identity Roles\n+################################################################################\n+module \"iam_pod_identity_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-pod-identity\"\n+\n+ role_policy_arns = {\n+ policy = module.iam_policy.arn\n+ }\n+}\n+\n+# This resource requires installed eks-pod-identity-agent to work\n+resource \"aws_eks_pod_identity_association\" \"my_app_staging\" {\n+ cluster_name = module.eks.cluster_name\n+ role_arn = module.iam_pod_identity_role.iam_role_arn\n+ namespace = \"default\"\n+ service_account = \"my-app-staging\"\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n@@ -438,6 +458,13 @@ module \"eks\" {\n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n \n+ cluster_addons = {\n+ # Required for Pod Identity roles\n+ eks-pod-identity-agent = {\n+ most_recent = true\n+ }\n+ }\n+\n eks_managed_node_groups = {\n default = {}\n }\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -105,13 +105,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -62,6 +62,16 @@ data \"aws_iam_policy_document\" \"this\" {\n \n }\n }\n+\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"pods.eks.amazonaws.com\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n@@ -46,6 +46,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_pod_identity_role\"></a> [iam\\_pod\\_identity\\_role](#module\\_iam\\_pod\\_identity\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -61,6 +62,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Type |\n |------|------|\n+| [aws_eks_pod_identity_association.my_app_staging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_pod_identity_association) | resource |\n | [aws_iam_policy.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -399,6 +399,26 @@ module \"iam_eks_role\" {\n }\n }\n \n+################################################################################\n+# Pod Identity Roles\n+################################################################################\n+module \"iam_pod_identity_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-pod-identity\"\n+\n+ role_policy_arns = {\n+ policy = module.iam_policy.arn\n+ }\n+}\n+\n+# This resource requires installed eks-pod-identity-agent to work\n+resource \"aws_eks_pod_identity_association\" \"my_app_staging\" {\n+ cluster_name = module.eks.cluster_name\n+ role_arn = module.iam_pod_identity_role.iam_role_arn\n+ namespace = \"default\"\n+ service_account = \"my-app-staging\"\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n@@ -438,6 +458,13 @@ module \"eks\" {\n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n \n+ cluster_addons = {\n+ # Required for Pod Identity roles\n+ eks-pod-identity-agent = {\n+ most_recent = true\n+ }\n+ }\n+\n eks_managed_node_groups = {\n default = {}\n }\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -105,13 +105,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -62,6 +62,16 @@ data \"aws_iam_policy_document\" \"this\" {\n \n }\n }\n+\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"pods.eks.amazonaws.com\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -20,13 +20,13 @@ Run `terraform destroy` when you don't need these resources.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n@@ -46,6 +46,7 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_pod_identity_role\"></a> [iam\\_pod\\_identity\\_role](#module\\_iam\\_pod\\_identity\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n@@ -61,6 +62,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Type |\n |------|------|\n+| [aws_eks_pod_identity_association.my_app_staging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_pod_identity_association) | resource |\n | [aws_iam_policy.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |\n \n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -399,6 +399,26 @@ module \"iam_eks_role\" {\n }\n }\n \n+################################################################################\n+# Pod Identity Roles\n+################################################################################\n+module \"iam_pod_identity_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-pod-identity\"\n+\n+ role_policy_arns = {\n+ policy = module.iam_policy.arn\n+ }\n+}\n+\n+# This resource requires installed eks-pod-identity-agent to work\n+resource \"aws_eks_pod_identity_association\" \"my_app_staging\" {\n+ cluster_name = module.eks.cluster_name\n+ role_arn <a = module.iam_pod_identity_role.iam_role_arn\n+ namespace = \"default\"\n+ service_account = \"my-app-staging\"\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n@@ -438,6 +458,13 @@ module \"eks\" {\n vpc_id = module.vpc.vpc_id\n subnet_ids = module.vpc.private_subnets\n \n+ cluster_addons = {\n+ # Required for Pod Identity roles\n+ eks-pod-identity-agent = {\n+ most_recent = true\n+ }\n+ }\n+\n eks_managed_node_groups = {\n default = {}\n }\n---\nexamples/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -105,13 +105,13 @@ module \"eks\" {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.29 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.29 |\n \n ## Modules\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -62,6 +62,16 @@ data \"aws_iam_policy_document\" \"this\" {\n \n }\n }\n+\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\", \"sts:TagSession\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"pods.eks.amazonaws.com\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-role-for-service-accounts-eks/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.0\"\n+ version = \">= 5.29\"\n }\n }\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nRelated resources shouldn't be created when group creation is disabled\r\n\r\n## Motivation and Context\r\nIn some scenarios the `iam-group-with-policies` submodule attempts to create `aws_iam_group_membership`, `aws_iam_policy` and `aws_iam_group_policy_attachment` resources even though the `create_group` variable is set to `false`. Workarounds do exist, but ultimately this behaviour is undesired.\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nexamples/iam-group-with-policies/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_group_superadmins\"></a> [iam\\_group\\_superadmins](#module\\_iam\\_group\\_superadmins) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_group_with_custom_policies\"></a> [iam\\_group\\_with\\_custom\\_policies](#module\\_iam\\_group\\_with\\_custom\\_policies) | ../../modules/iam-group-with-policies | n/a |\n+| <a name=\"module_iam_group_with_custom_policies_disabled\"></a> [iam\\_group\\_with\\_custom\\_policies\\_disabled](#module\\_iam\\_group\\_with\\_custom\\_policies\\_disabled) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_user1\"></a> [iam\\_user1](#module\\_iam\\_user1) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n \n---\nexamples/iam-group-with-policies/main.tf\n@@ -65,6 +65,35 @@ module \"iam_group_with_custom_policies\" {\n ]\n }\n \n+#####################################################################################\n+# IAM group to test the `create_group = false` option\n+#####################################################################################\n+module \"iam_group_with_custom_policies_disabled\" {\n+ source = \"../../modules/iam-group-with-policies\"\n+\n+ create_group = false\n+\n+ name = \"custom-disabled\"\n+ path = \"/custom/\"\n+\n+ group_users = [\n+ module.iam_user1.iam_user_name,\n+ module.iam_user2.iam_user_name,\n+ ]\n+\n+ custom_group_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ ]\n+\n+ custom_group_policies = [\n+ {\n+ name = \"AllowS3Listing\"\n+ policy = data.aws_iam_policy_document.sample.json\n+ },\n+ ]\n+}\n+\n ######################\n # IAM policy (sample)\n ######################\n---\nmodules/iam-group-with-policies/main.tf\n@@ -21,21 +21,21 @@ resource \"aws_iam_group_membership\" \"this\" {\n # IAM group policy attachements\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n group = local.group_name\n policy_arn = aws_iam_policy.iam_self_management[0].arn\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns)\n+ count = var.create_group ? length(var.custom_group_policy_arns) : 0\n \n group = local.group_name\n policy_arn = element(var.custom_group_policy_arns, count.index)\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n@@ -45,7 +45,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\n # IAM policies\n ###############\n resource \"aws_iam_policy\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n@@ -54,7 +54,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n---\n\n\n---\n\nChoice B:\nexamples/iam-group-with-policies/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_group_superadmins\"></a> [iam\\_group\\_superadmins](#module\\_iam\\_group\\_superadmins) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_group_with_custom_policies\"></a> [iam\\_group\\_with\\_custom\\_policies](#module\\_iam\\_group\\_with\\_custom\\_policies) | ../../modules/iam-group-with-policies | n/a |\n+| <a name=\"module_iam_group_with_custom_policies_disabled\"></a> [iam\\_group\\_with\\_custom\\_policies\\_disabled](#module\\_iam\\_group\\_with\\_custom\\_policies\\_disabled) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_user1\"></a> [iam\\_user1](#module\\_iam\\_user1) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n \n---\nexamples/iam-group-with-policies/main.tf\n@@ -65,6 +65,35 @@ module \"iam_group_with_custom_policies\" ]\n }\n \n+#####################################################################################\n+# IAM group to test the `create_group = false` option\n+#####################################################################################\n+module \"iam_group_with_custom_policies_disabled\" {\n+ source = \"../../modules/iam-group-with-policies\"\n+\n+ create_group = false\n+\n+ name = \"custom-disabled\"\n+ path = \"/custom/\"\n+\n+ group_users = [\n+ module.iam_user1.iam_user_name,\n+ module.iam_user2.iam_user_name,\n+ ]\n+\n+ custom_group_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ ]\n+\n+ custom_group_policies = [\n+ {\n+ name = \"AllowS3Listing\"\n+ policy = data.aws_iam_policy_document.sample.json\n+ },\n+ ]\n+}\n+\n ######################\n # IAM policy (sample)\n ######################\n---\nmodules/iam-group-with-policies/main.tf\n@@ -21,21 +21,21 @@ resource \"aws_iam_group_membership\" \"this\" {\n # IAM group policy attachements\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n group = local.group_name\n policy_arn = aws_iam_policy.iam_self_management[0].arn\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns)\n+ count = var.create_group ? length(var.custom_group_policy_arns) : 0\n \n group = local.group_name\n policy_arn = element(var.custom_group_policy_arns, count.index)\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n@@ -45,7 +45,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\n # IAM policies\n ###############\n resource \"aws_iam_policy\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n@@ -54,7 +54,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n---\n\n\n---\n\nChoice C:\nexamples/iam-group-with-policies/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_group_superadmins\"></a> [iam\\_group\\_superadmins](#module\\_iam\\_group\\_superadmins) name_prefix ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_group_with_custom_policies\"></a> [iam\\_group\\_with\\_custom\\_policies](#module\\_iam\\_group\\_with\\_custom\\_policies) | ../../modules/iam-group-with-policies | n/a |\n+| <a name=\"module_iam_group_with_custom_policies_disabled\"></a> [iam\\_group\\_with\\_custom\\_policies\\_disabled](#module\\_iam\\_group\\_with\\_custom\\_policies\\_disabled) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_user1\"></a> [iam\\_user1](#module\\_iam\\_user1) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n \n---\nexamples/iam-group-with-policies/main.tf\n@@ -65,6 +65,35 @@ module \"iam_group_with_custom_policies\" {\n ]\n }\n \n+#####################################################################################\n+# IAM group to test the `create_group = false` option\n+#####################################################################################\n+module \"iam_group_with_custom_policies_disabled\" {\n+ source = \"../../modules/iam-group-with-policies\"\n+\n+ create_group = false\n+\n+ name = \"custom-disabled\"\n+ path = \"/custom/\"\n+\n+ group_users = [\n+ module.iam_user1.iam_user_name,\n+ module.iam_user2.iam_user_name,\n+ ]\n+\n+ custom_group_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ ]\n+\n+ custom_group_policies = [\n+ {\n+ name = \"AllowS3Listing\"\n+ policy = data.aws_iam_policy_document.sample.json\n+ },\n+ ]\n+}\n+\n ######################\n # IAM policy (sample)\n ######################\n---\nmodules/iam-group-with-policies/main.tf\n@@ -21,21 +21,21 @@ resource \"aws_iam_group_membership\" \"this\" {\n # IAM group policy attachements\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n group = local.group_name\n policy_arn = aws_iam_policy.iam_self_management[0].arn\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns)\n+ count = var.create_group ? length(var.custom_group_policy_arns) : 0\n \n group = local.group_name\n policy_arn = element(var.custom_group_policy_arns, count.index)\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n@@ -45,7 +45,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\n # IAM policies\n ###############\n resource \"aws_iam_policy\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n@@ -54,7 +54,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n---\n\n\n---\n\nChoice D:\nexamples/iam-group-with-policies/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_group_superadmins\"></a> [iam\\_group\\_superadmins](#module\\_iam\\_group\\_superadmins) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_group_with_custom_policies\"></a> [iam\\_group\\_with\\_custom\\_policies](#module\\_iam\\_group\\_with\\_custom\\_policies) | ../../modules/iam-group-with-policies | n/a |\n+| <a name=\"module_iam_group_with_custom_policies_disabled\"></a> [iam\\_group\\_with\\_custom\\_policies\\_disabled](#module\\_iam\\_group\\_with\\_custom\\_policies\\_disabled) | ../../modules/iam-group-with-policies | n/a |\n | <a name=\"module_iam_user1\"></a> [iam\\_user1](#module\\_iam\\_user1) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n \n---\nexamples/iam-group-with-policies/main.tf\n@@ -65,6 +65,35 @@ module \"iam_group_with_custom_policies\" {\n ]\n }\n \n+#####################################################################################\n+# IAM group to test the `create_group = false` option\n+#####################################################################################\n+module \"iam_group_with_custom_policies_disabled\" {\n+ source = \"../../modules/iam-group-with-policies\"\n+\n+ create_group = false\n+\n+ name = \"custom-disabled\"\n+ path = \"/custom/\"\n+\n+ group_users = [\n+ module.iam_user1.iam_user_name,\n+ module.iam_user2.iam_user_name,\n+ ]\n+\n+ custom_group_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ ]\n+\n+ custom_group_policies = [\n+ {\n+ name = \"AllowS3Listing\"\n+ policy = data.aws_iam_policy_document.sample.json\n+ },\n+ ]\n+}\n+\n ######################\n # IAM policy (sample)\n ######################\n---\nmodules/iam-group-with-policies/main.tf\n@@ -21,21 +21,21 @@ resource \"aws_iam_group_membership\" \"this\" {\n # IAM group policy attachements\n ################################\n resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n group = local.group_name\n policy_arn = aws_iam_policy.iam_self_management[0].arn\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns)\n+ count = var.create_group ? length(var.custom_group_policy_arns) \"iam_self_management\" 0\n \n group = local.group_name\n policy_arn = element(var.custom_group_policy_arns, count.index)\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n@@ -45,7 +45,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\n # IAM policies\n ###############\n resource \"aws_iam_policy\" \"iam_self_management\" {\n- count = var.attach_iam_self_management_policy ? 1 : 0\n+ count = var.create_group && var.attach_iam_self_management_policy ? 1 : 0\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n@@ -54,7 +54,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies)\n+ count = var.create_group ? length(var.custom_group_policies) : 0\n \n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nAs in title\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nThis module unnecessarily depends on the `tls` provider, I believe this copied over from `iam-github-oidc-provider`\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-role/README.md\n@@ -57,7 +57,6 @@ module \"iam_github_oidc_role\" {\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n-| <a name=\"requirement_tls\"></a> [tls](#requirement\\_tls) | >= 3.0 |\n \n ## Providers\n \n---\nmodules/iam-github-oidc-role/versions.tf\n@@ -6,9 +6,5 @@ terraform {\n source = \"hashicorp/aws\"\n version = \">= 4.0\"\n }\n- tls = {\n- source = \"hashicorp/tls\"\n- version = \">= 3.0\"\n- }\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-role/README.md\n@@ -57,7 +57,6 @@ module \"iam_github_oidc_role\" {\n |------|---------|\n | name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n-| <a name=\"requirement_tls\"></a> [tls](#requirement\\_tls) | >= 3.0 |\n \n ## Providers\n \n---\nmodules/iam-github-oidc-role/versions.tf\n@@ -6,9 +6,5 @@ terraform {\n source = \"hashicorp/aws\"\n version = \">= 4.0\"\n }\n- tls = {\n- source = \"hashicorp/tls\"\n- version = \">= 3.0\"\n- }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-role/README.md\n@@ -57,7 +57,6 @@ module \"iam_github_oidc_role\" {\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n-| <a name=\"requirement_tls\"></a> [tls](#requirement\\_tls) | >= 3.0 |\n \n ## Providers\n \n---\nmodules/iam-github-oidc-role/versions.tf\n@@ -6,9 +6,5 @@ terraform {\n source = \"hashicorp/aws\"\n terraform version = \">= 4.0\"\n }\n- tls = {\n- source = \"hashicorp/tls\"\n- version = \">= 3.0\"\n- }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-role/README.md\n@@ -57,7 +57,6 @@ module \"iam_github_oidc_role\" {\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= |\n-| <a name=\"requirement_tls\"></a> [tls](#requirement\\_tls) | >= 3.0 |\n \n ## Providers\n \n---\nmodules/iam-github-oidc-role/versions.tf\n@@ -6,9 +6,5 @@ terraform {\n source = \"hashicorp/aws\"\n version = \">= 4.0\"\n }\n- tls = {\n- source = \"hashicorp/tls\"\n- version = \">= 3.0\"\n- }\n }\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nAdds an additional conditional in the existing `for_each` for reading the EKS cluster data and constructing part of the policy document.\r\n\r\n(I suppose the whole policy document can be skipped if there's no role being created... but no harm done in keeping it in, didn't want to break other things.)\r\n\r\n## Motivation and Context\r\n\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/324\r\n\r\n## Breaking Changes\r\n\r\nNo breaking changes afaik, only adds hardening in the need for the execution of certain resources.\r\n\r\n## How Has This Been Tested?\r\n\r\nTested with the following code (module is local fork, at the `v5.5.1` tag).\r\n\r\n```\r\nmodule \"cluster_autoscaler_role\" {\r\n create_role = false\r\n source = \"./modules/terraform-aws-iam/modules/iam-eks-role\"\r\n # version = \"5.5.1\" \r\n\r\n role_name = \"cluster-autoscaler-false\"\r\n\r\n cluster_service_accounts = {\r\n \"foo\" = [\"kube-system:cluster-autoscaler\"]\r\n }\r\n\r\n # role_policy_arns = {\r\n # cluster-autoscaler = module.cluster_autoscaler_policy.arn\r\n # }\r\n}\r\n```\r\n\r\nAlso toggled the `create_role` to true to validate that the old flow still functions.\r\n\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n\r\n```\r\n➜ pre-commit run -a\r\nTerraform fmt............................................................Passed\r\nTerraform wrapper with for_each in module................................Passed\r\nTerraform validate.......................................................Passed\r\nTerraform docs...........................................................Passed\r\nTerraform validate with tflint...........................................Passed\r\ncheck for merge conflicts................................................Passed\r\nfix end of files.........................................................Passed\r\n```\n\n---\n\nChoice A:\nmodules/iam-eks-role/main.tf\n@@ -8,7 +8,7 @@ locals {\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n name = each.key\n }\n@@ -37,7 +37,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n content {\n effect = \"Allow\"\n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/main.tf\n@@ -8,7 +8,7 @@ locals {\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n name = each.key\n }\n@@ -37,7 +37,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n content {\n effect = \"Allow\"\n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/main.tf\n@@ -8,7 +8,7 @@ locals {\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n name = each.key\n }\n@@ -37,7 +37,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n content {\n {\n- = \"Allow\"\n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/main.tf\n@@ -8,7 +8,7 @@ locals {\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each { { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n name = each.key\n }\n@@ -37,7 +37,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.cluster_service_accounts\n+ for_each = { for k, v in var.cluster_service_accounts : k => v if var.create_role }\n \n content {\n effect = \"Allow\"\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR corrects IAM Self-manage policy according to example from [AWS: Allows MFA-authenticated IAM users to manage their own credentials on the My security credentials page ](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html):\r\n1. Previously, it did not allow users to change their password on their own user page. To allow this, now the `iam:GetLoginProfile` and `iam:UpdateLoginProfile` actions to be added to the `AllowManageOwnPasswords` statement.\r\n2. The `DenyAllExceptListedIfNoMFA` statement has been corrected to include missing ` iam:GetMFADevice` permission for own MFA management.\r\n3. Also, in the same statement `iam:ChangePassword` action should not be allowed without MFA authorization if it was enforced. This does not allow a user to create a password at sign-in, the MFA must be created and user must authenticate using it before attempting to change administrator provided password.\r\n\r\n## Motivation and Context\r\nStay up to date with AWS recommendations for access policies, grant permissions necessary for IAM user selfie-management via AWS Web Console.\r\nMake sure if MFA is enforced, it disallows unauthorized password change for IAM user in case of credentials leak.\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -32,7 +32,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n actions = [\n \"iam:ChangePassword\",\n- \"iam:GetUser\"\n+ \"iam:GetLoginProfile\",\n+ \"iam:GetUser\",\n+ \"iam:UpdateLoginProfile\"\n ]\n \n resources = [\n@@ -153,10 +155,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n = sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n- \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n+ \"iam:GetMFADevice\",\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -32,7 +32,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n actions = [\n \"iam:ChangePassword\",\n- \"iam:GetUser\"\n+ \"iam:GetLoginProfile\",\n+ \"iam:GetUser\",\n+ \"iam:UpdateLoginProfile\"\n ]\n \n resources = [\n@@ -153,10 +155,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n- \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n+ \"iam:GetMFADevice\",\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -32,7 +32,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n actions = [\n \"iam:ChangePassword\",\n- \"iam:GetUser\"\n+ \"iam:GetLoginProfile\",\n+ \"iam:GetUser\",\n+ \"iam:UpdateLoginProfile\"\n ]\n \n resources = [\n@@ -153,10 +155,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions [\n- \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n+ \"iam:GetMFADevice\",\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -32,7 +32,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n actions = [\n \"iam:ChangePassword\",\n- \"iam:GetUser\"\n+ \"iam:GetLoginProfile\",\n+ \"iam:GetUser\",\n+ \"iam:UpdateLoginProfile\"\n ]\n \n resources = [\n@@ -153,10 +155,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n sid = \"DenyAllExceptListedIfNoMFA\"\n effect = \"Deny\"\n not_actions = [\n- \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n+ \"iam:GetMFADevice\",\n \"iam:ListMFADevices\",\n \"iam:ListVirtualMFADevices\",\n \"iam:ResyncMFADevice\",\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\nfixes #433\r\n\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.83.5\n+ rev: v1.83.6\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -208,6 +208,7 @@ No modules.\n | <a name=\"input_cluster_autoscaler_cluster_names\"></a> [cluster\\_autoscaler\\_cluster\\_names](#input\\_cluster\\_autoscaler\\_cluster\\_names) | List of cluster names to appropriately scope permissions within the Cluster Autoscaler IAM policy | `list(string)` | `[]` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_karpenter_instance_profile_creation\"></a> [enable\\_karpenter\\_instance\\_profile\\_creation](#input\\_enable\\_karpenter\\_instance\\_profile\\_creation) | Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+) | `bool` | `false` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -645,7 +645,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:TerminateInstances\",\n \"ec2:DeleteLaunchTemplate\",\n ]\n-\n resources = [\"*\"]\n \n condition {\n@@ -691,6 +690,22 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ dynamic \"statement\" {\n+ for_each = var.enable_karpenter_instance_profile_creation ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"iam:AddRoleToInstanceProfile\",\n+ \"iam:CreateInstanceProfile\",\n+ \"iam:DeleteInstanceProfile\",\n+ \"iam:GetInstanceProfile\",\n+ \"iam:RemoveRoleFromInstanceProfile\",\n+ \"iam:TagInstanceProfile\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"eks:DescribeCluster\"]\n resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${local.karpenter_controller_cluster_name}\"]\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -252,6 +252,12 @@ variable \"karpenter_sqs_queue_arn\" {\n default = null\n }\n \n+variable \"enable_karpenter_instance_profile_creation\" {\n+ description = \"Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+)\"\n+ type = bool\n+ default = false\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n cluster_autoscaler_cluster_names = try(each.value.cluster_autoscaler_cluster_names, var.defaults.cluster_autoscaler_cluster_names, [])\n create_role = try(each.value.create_role, var.defaults.create_role, true)\n ebs_csi_kms_cmk_ids = try(each.value.ebs_csi_kms_cmk_ids, var.defaults.ebs_csi_kms_cmk_ids, [])\n+ enable_karpenter_instance_profile_creation = try(each.value.enable_karpenter_instance_profile_creation, var.defaults.enable_karpenter_instance_profile_creation, false)\n external_dns_hosted_zone_arns = try(each.value.external_dns_hosted_zone_arns, var.defaults.external_dns_hosted_zone_arns, [\"arn:aws:route53:::hostedzone/*\"])\n external_secrets_kms_key_arns = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.83.5\n+ rev: v1.83.6\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -208,6 +208,7 @@ No modules.\n | <a name=\"input_cluster_autoscaler_cluster_names\"></a> [cluster\\_autoscaler\\_cluster\\_names](#input\\_cluster\\_autoscaler\\_cluster\\_names) | List of cluster names to appropriately scope permissions within the Cluster Autoscaler IAM policy | `list(string)` | `[]` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_karpenter_instance_profile_creation\"></a> [enable\\_karpenter\\_instance\\_profile\\_creation](#input\\_enable\\_karpenter\\_instance\\_profile\\_creation) | Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+) | `bool` | `false` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -645,7 +645,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:TerminateInstances\",\n \"ec2:DeleteLaunchTemplate\",\n ]\n-\n resources = [\"*\"]\n \n condition {\n@@ -691,6 +690,22 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ dynamic \"statement\" {\n+ for_each = var.enable_karpenter_instance_profile_creation ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"iam:AddRoleToInstanceProfile\",\n+ \"iam:CreateInstanceProfile\",\n+ \"iam:DeleteInstanceProfile\",\n+ \"iam:GetInstanceProfile\",\n+ \"iam:RemoveRoleFromInstanceProfile\",\n+ \"iam:TagInstanceProfile\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"eks:DescribeCluster\"]\n resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${local.karpenter_controller_cluster_name}\"]\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -252,6 +252,12 @@ variable \"karpenter_sqs_queue_arn\" {\n default = null\n }\n \n+variable \"enable_karpenter_instance_profile_creation\" {\n+ description = \"Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+)\"\n+ type = bool\n+ default = false\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n cluster_autoscaler_cluster_names = try(each.value.cluster_autoscaler_cluster_names, var.defaults.cluster_autoscaler_cluster_names, [])\n create_role = try(each.value.create_role, var.defaults.create_role, true)\n ebs_csi_kms_cmk_ids = try(each.value.ebs_csi_kms_cmk_ids, var.defaults.ebs_csi_kms_cmk_ids, [])\n+ enable_karpenter_instance_profile_creation = try(each.value.enable_karpenter_instance_profile_creation, var.defaults.enable_karpenter_instance_profile_creation, false)\n external_dns_hosted_zone_arns = try(each.value.external_dns_hosted_zone_arns, var.defaults.external_dns_hosted_zone_arns, [\"arn:aws:route53:::hostedzone/*\"])\n external_secrets_kms_key_arns hosted = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.83.5\n+ rev: v1.83.6\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -208,6 +208,7 @@ No modules.\n | <a name=\"input_cluster_autoscaler_cluster_names\"></a> [cluster\\_autoscaler\\_cluster\\_names](#input\\_cluster\\_autoscaler\\_cluster\\_names) | List of cluster names to appropriately scope permissions within the Cluster Autoscaler IAM policy | `list(string)` | `[]` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_karpenter_instance_profile_creation\"></a> [enable\\_karpenter\\_instance\\_profile\\_creation](#input\\_enable\\_karpenter\\_instance\\_profile\\_creation) | Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+) | `bool` | `false` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -645,7 +645,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:TerminateInstances\",\n \"ec2:DeleteLaunchTemplate\",\n ]\n-\n resources = [\"*\"]\n \n condition {\n@@ -691,6 +690,22 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ dynamic \"statement\" {\n+ for_each = var.enable_karpenter_instance_profile_creation ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"iam:AddRoleToInstanceProfile\",\n+ \"iam:CreateInstanceProfile\",\n+ \"iam:DeleteInstanceProfile\",\n+ \"iam:GetInstanceProfile\",\n+ \"iam:RemoveRoleFromInstanceProfile\",\n+ \"iam:TagInstanceProfile\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"eks:DescribeCluster\"]\n resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${local.karpenter_controller_cluster_name}\"]\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -252,6 +252,12 @@ variable \"karpenter_sqs_queue_arn\" {\n default = null\n }\n \n+variable \"enable_karpenter_instance_profile_creation\" {\n+ description = \"Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+)\"\n+ type = bool\n+ default = false\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n cluster_autoscaler_cluster_names = try(each.value.cluster_autoscaler_cluster_names, var.defaults.cluster_autoscaler_cluster_names, [])\n create_role = try(each.value.create_role, var.defaults.create_role, true)\n ebs_csi_kms_cmk_ids = try(each.value.ebs_csi_kms_cmk_ids, var.defaults.ebs_csi_kms_cmk_ids, [])\n+ enable_karpenter_instance_profile_creation = try(each.value.enable_karpenter_instance_profile_creation, var.defaults.enable_karpenter_instance_profile_creation, false)\n external_dns_hosted_zone_arns = try(each.value.external_dns_hosted_zone_arns, var.defaults.external_dns_hosted_zone_arns, [\"arn:aws:route53:::hostedzone/*\"])\n external_secrets_kms_key_arns = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.83.5\n+ rev: v1.83.6\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -208,6 +208,7 @@ No modules.\n | <a name=\"input_cluster_autoscaler_cluster_names\"></a> [cluster\\_autoscaler\\_cluster\\_names](#input\\_cluster\\_autoscaler\\_cluster\\_names) | List of cluster names to appropriately scope permissions within the Cluster Autoscaler IAM policy | `list(string)` | `[]` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_karpenter_instance_profile_creation\"></a> [enable\\_karpenter\\_instance\\_profile\\_creation](#input\\_enable\\_karpenter\\_instance\\_profile\\_creation) | Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+) | `bool` | `false` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -645,7 +645,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:TerminateInstances\",\n \"ec2:DeleteLaunchTemplate\",\n ]\n-\n resources = [\"*\"]\n \n condition {\n@@ -691,6 +690,22 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ dynamic \"statement\" {\n+ for_each = var.enable_karpenter_instance_profile_creation ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"iam:AddRoleToInstanceProfile\",\n+ \"iam:CreateInstanceProfile\",\n+ \"iam:DeleteInstanceProfile\",\n+ \"iam:GetInstanceProfile\",\n+ \"iam:RemoveRoleFromInstanceProfile\",\n+ \"iam:TagInstanceProfile\",\n+ ]\n+ resources = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"eks:DescribeCluster\"]\n resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${local.karpenter_controller_cluster_name}\"]\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -252,6 +252,12 @@ variable \"karpenter_sqs_queue_arn\" {\n default = null\n }\n \n+variable \"enable_karpenter_instance_profile_creation\" {\n+ description = \"Determines whether Karpenter will be allowed to create the IAM instance profile (v1beta1/v0.32+)\"\n+ type = bool\n+ default = false\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n cluster_autoscaler_cluster_names = try(each.value.cluster_autoscaler_cluster_names, var.defaults.cluster_autoscaler_cluster_names, [])\n create_role = try(each.value.create_role, var.defaults.create_role, true)\n ebs_csi_kms_cmk_ids = try(each.value.ebs_csi_kms_cmk_ids, var.defaults.ebs_csi_kms_cmk_ids, [])\n+ enable_karpenter_instance_profile_creation = try(each.value.enable_karpenter_instance_profile_creation, var.defaults.enable_karpenter_instance_profile_creation, false)\n external_dns_hosted_zone_arns = try(each.value.external_dns_hosted_zone_arns, var.defaults.external_dns_hosted_zone_arns, [\"arn:aws:route53:::hostedzone/*\"])\n external_secrets_kms_key_arns | = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n\r\n## Description\r\nThe \"AWS: Self-manage credentials with MFA (My security credentials)\" reference policy got updated by AWS in the docs[1] and this implements the following correction:\r\n\r\nThe AllowManageOwnAccessKeys statement allows the user to create, update, and delete their own access keys.\r\n**The user can also retrieve information about when the specified access key was last used.**\r\n\r\n1. https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html\r\n\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\nHaving the self-management policy up to date with AWS recommendations. \r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -50,7 +50,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:CreateAccessKey\",\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n- \"iam:UpdateAccessKey\"\n+ \"iam:UpdateAccessKey\",\n+ \"iam:GetAccessKeyLastUsed\"\n ]\n \n resources = [\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -50,7 +50,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:CreateAccessKey\",\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n- \"iam:UpdateAccessKey\"\n+ \"iam:UpdateAccessKey\",\n+ \"iam:GetAccessKeyLastUsed\"\n ]\n \n resources = [\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -50,7 +50,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n = \"iam:CreateAccessKey\",\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n- \"iam:UpdateAccessKey\"\n+ \"iam:UpdateAccessKey\",\n+ \"iam:GetAccessKeyLastUsed\"\n ]\n \n resources = [\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -50,7 +50,8 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:CreateAccessKey\",\n \"iam:DeleteAccessKey\",\n \"iam:ListAccessKeys\",\n- \"iam:UpdateAccessKey\"\n+ \"iam:UpdateAccessKey\",\n+ \"iam:GetAccessKeyLastUsed\"\n ]\n \n resources = [\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nThis allows you to pass a list of CIDRs from where the role can be used. \r\nA non-required variable is introduced, that when it is set it will add a condition to the `aws_iam_policy_document` with the CIDR. \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/422\r\nThis enables more secure use of OIDC by allowing only a specified CIDR to use it. For example, for using self-hosted GitHub Actions runners and allowlisting them. \r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNot that I know of.\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-role/README.md\n@@ -83,6 +83,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allowed_cidrs\"></a> [allowed\\_cidrs](#input\\_allowed\\_cidrs) | List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0` | `list(string)` | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.allowed_cidrs) > 0 ? [1] : []\n+ content {\n+ test = \"IpAddress\"\n+ variable = \"aws:SourceIp\"\n+ values = var.allowed_cidrs\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -79,3 +79,9 @@ variable \"provider_url\" {\n type = string\n default \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"allowed_cidrs\" {\n+ description = \"List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0`\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-role/README.md\n@@ -83,6 +83,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allowed_cidrs\"></a> [allowed\\_cidrs](#input\\_allowed\\_cidrs) | List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0` | `list(string)` | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" <a {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.allowed_cidrs) > 0 ? [1] : []\n+ content {\n+ test = \"IpAddress\"\n+ variable = \"aws:SourceIp\"\n+ values = var.allowed_cidrs\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -79,3 +79,9 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"allowed_cidrs\" {\n+ description = \"List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0`\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-role/README.md\n@@ -83,6 +83,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allowed_cidrs\"></a> [allowed\\_cidrs](#input\\_allowed\\_cidrs) | List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0` | `list(string)` | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` \"aws_iam_policy_document\" normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.allowed_cidrs) > 0 ? [1] : []\n+ content {\n+ test = \"IpAddress\"\n+ variable = \"aws:SourceIp\"\n+ values = var.allowed_cidrs\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -79,3 +79,9 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"allowed_cidrs\" {\n+ description = \"List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0`\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-role/README.md\n@@ -83,6 +83,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_allowed_cidrs\"></a> [allowed\\_cidrs](#input\\_allowed\\_cidrs) | List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0` | `list(string)` | `[]` | no |\n | <a name=\"input_audience\"></a> [audience](#input\\_audience) | Audience to use for OIDC role. Defaults to `sts.amazonaws.com` for use with the [official AWS GitHub action](https://github.com/aws-actions/configure-aws-credentials) | `string` | `\"sts.amazonaws.com\"` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | IAM Role description | `string` | `null` | no |\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -47,6 +47,15 @@ data \"aws_iam_policy_document\" \"this\" {\n # Strip `repo:` to normalize for cases where users may prepend it\n values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.allowed_cidrs) > 0 ? [1] : []\n+ content {\n+ test = \"IpAddress\"\n+ variable = \"aws:SourceIp\"\n+ values = var.allowed_cidrs\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-github-oidc-role/variables.tf\n@@ -79,3 +79,9 @@ variable \"provider_url\" {\n type = string\n default = \"token.actions.githubusercontent.com\"\n }\n+\n+variable \"allowed_cidrs\" {\n+ description = \"List of CIDR blocks to allow access from. Defaults to `0.0.0.0/0`\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nWhen creating the `iam-user` module, it throws error as `for_each` is expecting a map or a set of string however the module defines the `policy_arns` variable as a `list(string)`.\r\n\r\n## Motivation and Context\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/408\r\n\r\nThere are two options to fix this issue. Option 1 is to cast the `policy_arns` into a map of string in runtime (like how it is done in https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/modules/iam-eks-role/main.tf#L78). Or option 2 is to replace `for_each` with `count`. For simplicity reason, I chose option 2.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\nexample remains the same as there is no change to the caller inputs\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-user/main.tf\n@@ -47,8 +47,8 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n }\n \n resource \"aws_iam_user_policy_attachment\" \"this\" {\n- for_each = var.create_user ? toset(var.policy_arns) : []\n+ count = var.create_user ? length(var.policy_arns) : 0\n \n user : = aws_iam_user.this[0].name\n- policy_arn = each.value\n+ policy_arn = element(var.policy_arns, count.index)\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/main.tf\n@@ -47,8 +47,8 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n }\n \n resource \"aws_iam_user_policy_attachment\" \"this\" {\n- for_each = var.create_user ? toset(var.policy_arns) : []\n+ count = var.create_user ? length(var.policy_arns) : 0\n \n modules/iam-user/main.tf\n@@ user = aws_iam_user.this[0].name\n- policy_arn = each.value\n+ policy_arn = element(var.policy_arns, count.index)\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/main.tf\n@@ -47,8 +47,8 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n }\n \n resource \"aws_iam_user_policy_attachment\" \"this\" {\n- for_each = var.create_user ? toset(var.policy_arns) : []\n+ count = var.create_user ? length(var.policy_arns) : 0\n \n user = aws_iam_user.this[0].name\n- policy_arn = each.value\n+ policy_arn -47,8 element(var.policy_arns, count.index)\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/main.tf\n@@ -47,8 +47,8 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n }\n \n resource \"aws_iam_user_policy_attachment\" \"this\" {\n- for_each = var.create_user ? toset(var.policy_arns) : []\n+ count = var.create_user ? length(var.policy_arns) : 0\n \n user = aws_iam_user.this[0].name\n- policy_arn = each.value\n+ policy_arn = element(var.policy_arns, count.index)\n }\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nFor `iam-assumable-role` the setting `role_requires_session_name = true` is ignored when `role_requires_mfa = false`.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nFor the case when MFA is not enforced, the option to set the condition `role_session_name` when assuming a role is missing. This was probably due to the confusion caused by unnecessary code duplication (two separate policies whether MFA is enabled or not) when the feature was implemented.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role/main.tf\n@@ -55,6 +55,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/main.tf\n@@ -55,6 +55,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/main.tf\n@@ -55,6 +55,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic }\n {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/main.tf\n@@ -55,6 +55,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ var.role_session_name\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis PR adds possibility to not only add AssumeRole to app or user but also for AWS services like s3.\r\n\r\n## Motivation and Context\r\nI have many use cases where I'm using one saml role with other AWs services like S3.\r\n\r\n## Breaking Changes\r\nNo\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-saml/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-saml | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-saml | n/a |\n+| <a name=\"module_iam_assumable_roles_with_saml_with_trusted_services\"></a> Run | ../../modules/iam-assumable-role-with-saml | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-saml/main.tf\n@@ -56,3 +56,18 @@ module \"iam_assumable_role_self_assume\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n }\n+\n+################################################\n+# IAM assumable roles with SAML with trusted services\n+################################################\n+module \"iam_assumable_roles_with_saml_with_trusted_services\" {\n+ source = \"../../modules/iam-assumable-role-with-saml\"\n+\n+ create_role = true\n+ role_name = \"Saml-with-trusted-service\"\n+ allow_self_assume_role = false\n+\n+ trusted_role_services = [\"batchoperations.s3.amazonaws.com\"]\n+\n+ provider_id = aws_iam_saml_provider.idp_saml.id\n+}\n---\nmodules/iam-assumable-role-with-saml/README.md\n@@ -53,6 +53,8 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional role actions | `list(string)` | <pre>[<br> \"sts:AssumeRoleWithSAML\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services_actions\"></a> [trusted\\_role\\_services\\_actions](#input\\_trusted\\_role\\_services\\_actions) | Additional trusted role services actions | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -47,6 +47,19 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n values = [var.aws_saml_endpoint]\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_services) > 0 ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ actions = compact(distinct(concat([\"sts:AssumeRole\"], var.trusted_role_services_actions)))\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -93,3 +93,15 @@ variable \"trusted_role_actions\" {\n type = list(string)\n default = [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"]\n }\n+\n+variable \"trusted_role_services_actions\" {\n+ description = \"Additional trusted role services actions\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-saml/main.tf\n@@ -19,4 +19,6 @@ module \"wrapper\" {\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"])\n+ trusted_role_services_actions = try(each.value.trusted_role_services_actions, var.defaults.trusted_role_services_actions, [])\n+ trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-saml/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-saml | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-saml | n/a |\n+| <a name=\"module_iam_assumable_roles_with_saml_with_trusted_services\"></a> [iam\\_assumable\\_roles\\_with\\_saml\\_with\\_trusted\\_services](#module\\_iam\\_assumable\\_roles\\_with\\_saml\\_with\\_trusted\\_services) | ../../modules/iam-assumable-role-with-saml | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-saml/main.tf\n@@ -56,3 +56,18 @@ module \"iam_assumable_role_self_assume\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n }\n+\n+################################################\n+# IAM assumable roles with SAML with trusted services\n+################################################\n+module \"iam_assumable_roles_with_saml_with_trusted_services\" {\n+ source = \"../../modules/iam-assumable-role-with-saml\"\n+\n+ create_role = true\n+ role_name = \"Saml-with-trusted-service\"\n+ allow_self_assume_role = false\n+\n+ trusted_role_services = [\"batchoperations.s3.amazonaws.com\"]\n+\n+ provider_id = aws_iam_saml_provider.idp_saml.id\n+}\n---\nmodules/iam-assumable-role-with-saml/README.md\n@@ -53,6 +53,8 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional role actions | `list(string)` | <pre>[<br> \"sts:AssumeRoleWithSAML\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` no |\n+| <a name=\"input_trusted_role_services_actions\"></a> [trusted\\_role\\_services\\_actions](#input\\_trusted\\_role\\_services\\_actions) | Additional trusted role services actions | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -47,6 +47,19 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n values = [var.aws_saml_endpoint]\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_services) > 0 ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ actions = compact(distinct(concat([\"sts:AssumeRole\"], var.trusted_role_services_actions)))\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -93,3 +93,15 @@ variable \"trusted_role_actions\" {\n type = list(string)\n default = [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"]\n }\n+\n+variable \"trusted_role_services_actions\" {\n+ description = \"Additional trusted role services actions\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-saml/main.tf\n@@ -19,4 +19,6 @@ module \"wrapper\" {\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"])\n+ trusted_role_services_actions = try(each.value.trusted_role_services_actions, var.defaults.trusted_role_services_actions, [])\n+ trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-saml/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-saml | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-saml | n/a |\n+| <a name=\"module_iam_assumable_roles_with_saml_with_trusted_services\"></a> [iam\\_assumable\\_roles\\_with\\_saml\\_with\\_trusted\\_services](#module\\_iam\\_assumable\\_roles\\_with\\_saml\\_with\\_trusted\\_services) | ../../modules/iam-assumable-role-with-saml | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-saml/main.tf\n@@ -56,3 +56,18 @@ module \"iam_assumable_role_self_assume\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n }\n+\n+################################################\n+# IAM assumable roles with SAML with trusted services\n+################################################\n+module \"iam_assumable_roles_with_saml_with_trusted_services\" {\n+ source = \"../../modules/iam-assumable-role-with-saml\"\n+\n+ create_role = true\n+ role_name = \"Saml-with-trusted-service\"\n+ allow_self_assume_role = false\n+\n+ trusted_role_services = [\"batchoperations.s3.amazonaws.com\"]\n+\n+ provider_id = aws_iam_saml_provider.idp_saml.id\n+}\n---\nmodules/iam-assumable-role-with-saml/README.md\n@@ -53,6 +53,8 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional role actions | `list(string)` | <pre>[<br> \"sts:AssumeRoleWithSAML\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services_actions\"></a> [trusted\\_role\\_services\\_actions](#input\\_trusted\\_role\\_services\\_actions) | Additional trusted role services actions | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -47,6 +47,19 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n values = [var.aws_saml_endpoint]\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_services) > 0 ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ actions = compact(distinct(concat([\"sts:AssumeRole\"], var.trusted_role_services_actions)))\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -93,3 +93,15 @@ variable \"trusted_role_actions\" {\n type = list(string)\n default = [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"]\n }\n+\n+variable \"trusted_role_services_actions\" {\n+ description = \"Additional trusted role services actions\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-saml/main.tf\n@@ -19,4 +19,6 @@ module \"wrapper\" {\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"])\n+ trusted_role_services_actions = try(each.value.trusted_role_services_actions, var.defaults.trusted_role_services_actions, [])\n+ trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-saml/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-saml | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-saml | n/a |\n+| <a name=\"module_iam_assumable_roles_with_saml_with_trusted_services\"></a> [iam\\_assumable\\_roles\\_with\\_saml\\_with\\_trusted\\_services](#module\\_iam\\_assumable\\_roles\\_with\\_saml\\_with\\_trusted\\_services) | ../../modules/iam-assumable-role-with-saml | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-saml/main.tf\n@@ -56,3 +56,18 @@ module \"iam_assumable_role_self_assume\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n }\n+\n+################################################\n+# IAM assumable roles with SAML with trusted services\n+################################################\n+module \"iam_assumable_roles_with_saml_with_trusted_services\" {\n+ source = \"../../modules/iam-assumable-role-with-saml\"\n+\n+ create_role = true\n+ role_name = \"Saml-with-trusted-service\"\n+ allow_self_assume_role = false\n+\n+ trusted_role_services = [\"batchoperations.s3.amazonaws.com\"]\n+\n+ provider_id = aws_iam_saml_provider.idp_saml.id\n+}\n---\nmodules/iam-assumable-role-with-saml/README.md\n@@ -53,6 +53,8 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Additional role actions | `list(string)` | <pre>[<br> \"sts:AssumeRoleWithSAML\",<br> \"sts:TagSession\"<br>]</pre> | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services_actions\"></a> [trusted\\_role\\_services\\_actions](#input\\_trusted\\_role\\_services\\_actions) | Additional trusted role services actions | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -47,6 +47,19 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n values = [var.aws_saml_endpoint]\n }\n }\n+\n+ dynamic \"statement\" | for_each = length(var.trusted_role_services) > 0 ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ actions = compact(distinct(concat([\"sts:AssumeRole\"], var.trusted_role_services_actions)))\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -93,3 +93,15 @@ variable \"trusted_role_actions\" {\n type = list(string)\n default = [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"]\n }\n+\n+variable \"trusted_role_services_actions\" {\n+ description = \"Additional trusted role services actions\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-saml/main.tf\n@@ -19,4 +19,6 @@ module \"wrapper\" {\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n trusted_role_actions = try(each.value.trusted_role_actions, var.defaults.trusted_role_actions, [\"sts:AssumeRoleWithSAML\", \"sts:TagSession\"])\n+ trusted_role_services_actions = try(each.value.trusted_role_services_actions, var.defaults.trusted_role_services_actions, [])\n+ trusted_role_services = try(each.value.trusted_role_services, var.defaults.trusted_role_services, [])\n }\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nInitial set of permissions (#414) was not sufficient. Checked the [source code](https://github.com/external-secrets/external-secrets/blob/main/pkg/provider/aws/secretsmanager/secretsmanager.go) of the secrets manager implementation of external-secrets and added remaining permissions.\r\n\r\n## Motivation and Context\r\nThere were errors on certain use cases, such as a secret changes and needs to be pushed again.\r\n\r\n## Breaking Changes\r\nNo\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n- [x] our setup\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,21 +501,34 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n+ actions = [\"kms:Decrypt\"]\n resources = var.external_secrets_kms_key_arns\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n content {\n actions = [\n- \"secretsmanager:CreateSecret\"\n+ \"secretsmanager:CreateSecret\",\n+ \"secretsmanager:PutSecretValue\",\n+ \"secretsmanager:TagResource\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\"secretsmanager:DeleteSecret\"]\n+ resources = var.external_secrets_secrets_manager_arns\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"secretsmanager:ResourceTag/managed-by\"\n+ values = [\"external-secrets\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,21 +501,34 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n+ actions = [\"kms:Decrypt\"]\n resources = var.external_secrets_kms_key_arns\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n content {\n actions = [\n- \"secretsmanager:CreateSecret\"\n+ \"secretsmanager:CreateSecret\",\n+ \"secretsmanager:PutSecretValue\",\n+ \"secretsmanager:TagResource\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\"secretsmanager:DeleteSecret\"]\n+ resources = var.external_secrets_secrets_manager_arns\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"secretsmanager:ResourceTag/managed-by\"\n+ values = [\"external-secrets\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,21 +501,34 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n+ actions = [\"kms:Decrypt\"]\n resources = var.external_secrets_kms_key_arns\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n content {\n actions = [\n- \"secretsmanager:CreateSecret\"\n+ \"secretsmanager:CreateSecret\",\n+ \"secretsmanager:PutSecretValue\",\n+ var.external_secrets_secrets_manager_create_permission \"secretsmanager:TagResource\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\"secretsmanager:DeleteSecret\"]\n+ resources = var.external_secrets_secrets_manager_arns\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"secretsmanager:ResourceTag/managed-by\"\n+ values = [\"external-secrets\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -501,21 +501,34 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n }\n \n statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n+ actions = [\"kms:Decrypt\"]\n resources = var.external_secrets_kms_key_arns\n }\n \n dynamic \"statement\" {\n for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n content {\n actions = [\n- \"secretsmanager:CreateSecret\"\n+ \"secretsmanager:CreateSecret\",\n+ \"secretsmanager:PutSecretValue\",\n+ \"secretsmanager:TagResource\",\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\"secretsmanager:DeleteSecret\"]\n+ resources = var.external_secrets_secrets_manager_arns\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"secretsmanager:ResourceTag/managed-by\"\n+ values = [\"external-secrets\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nMinor update to change the dynamic block for fully_qualified_audiences to StringEquals instead of StringLike\r\n\r\n## Motivation and Context\r\nComing from the documentations for adding assume roles for Github Actions:\r\n- [Github documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#configuring-the-role-and-trust-policy)\r\n- [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html#idp_oidc_Create_GitHub)\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,28 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+##############################################\n+# IAM assumable role with cross-account assume\n+##############################################\n+module \"iam_assumable_role_cross_account\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-cross-account\"\n+\n+ tags = {\n+ Role = \"role-with-oidc-cross-account\"\n+ }\n+\n+ provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\n+ = = [\"oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8\"]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+ oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,28 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+##############################################\n+# IAM assumable role with cross-account assume\n+##############################################\n+module \"iam_assumable_role_cross_account\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-cross-account\"\n+\n+ tags = {\n+ Role = \"role-with-oidc-cross-account\"\n+ }\n+\n+ provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\n+ provider_urls = [\"oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8\"]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+ oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,28 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+##############################################\n+# IAM assumable role with cross-account assume\n+##############################################\n+module \"iam_assumable_role_cross_account\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-cross-account\"\n+\n+ tags = {\n+ Role = \"role-with-oidc-cross-account\"\n+ }\n+\n+ provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\n+ provider_urls = [\"oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8\"]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+ oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,28 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+##############################################\n+# IAM assumable role with cross-account assume\n+##############################################\n+module \"iam_assumable_role_cross_account\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-cross-account\"\n+\n+ tags = {\n+ Role = \"role-with-oidc-cross-account\"\n+ }\n+\n+ provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\n+ provider_urls = [\"oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8\"]\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+ oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n\r\n## Description\r\nAdd variable for configuring additional permissions for the IRSA Role, in order to allow CreateSecret.\r\n\r\n\r\n## Motivation and Context\r\nAllow for usage of [PushSecret](https://external-secrets.io/v0.9.3/api/pushsecret/), which requires CreateSecret access to AWS Secret Manager.\r\n\r\n## Breaking Changes\r\n- No, added variable has a default.\r\n- Defaults to not adding additional permissions, which is the current behavior.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.81.0\n+ rev: v1.82.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -155,11 +155,12 @@ module \"external_dns_irsa_role\" {\n module \"external_secrets_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"external-secrets\"\n- attach_external_secrets_policy = true\n- external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n- external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n- external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ role_name = \"external-secrets\"\n+ attach_external_secrets_policy = true\n+ external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n+ external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ external_secrets_secrets_manager_create_permission = false\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -211,6 +211,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -506,6 +506,16 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_kms_key_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\n+ \"secretsmanager:CreateSecret\"\n+ ]\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -183,6 +183,12 @@ variable \"external_secrets_kms_key_arns\" {\n default = [\"arn:aws:kms:*:*:key/*\"]\n }\n \n+variable \"external_secrets_secrets_manager_create_permission\" {\n+ description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ type = bool\n+ default = false\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -32,6 +32,7 @@ module \"wrapper\" {\n external_secrets_ssm_parameter_arns = try(each.value.external_secrets_ssm_parameter_arns, var.defaults.external_secrets_ssm_parameter_arns, [\"arn:aws:ssm:*:*:parameter/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n external_secrets_kms_key_arns = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n+ external_secrets_secrets_manager_create_permission = try(each.value.external_secrets_secrets_manager_create_permission, var.defaults.external_secrets_secrets_manager_create_permission, false)\n attach_fsx_lustre_csi_policy = try(each.value.attach_fsx_lustre_csi_policy, var.defaults.attach_fsx_lustre_csi_policy, false)\n fsx_lustre_csi_service_role_arns = try(each.value.fsx_lustre_csi_service_role_arns, var.defaults.fsx_lustre_csi_service_role_arns, [\"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"])\n attach_karpenter_controller_policy = try(each.value.attach_karpenter_controller_policy, var.defaults.attach_karpenter_controller_policy, false)\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.81.0\n+ rev: v1.82.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -155,11 +155,12 @@ module \"external_dns_irsa_role\" {\n module \"external_secrets_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"external-secrets\"\n- attach_external_secrets_policy = true\n- external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n- external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n- external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ role_name = \"external-secrets\"\n+ attach_external_secrets_policy = true\n+ external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n+ external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ external_secrets_secrets_manager_create_permission = false\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -211,6 +211,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -506,6 +506,16 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_kms_key_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\n+ \"secretsmanager:CreateSecret\"\n+ ]\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -183,6 +183,12 @@ variable \"external_secrets_kms_key_arns\" {\n default = [\"arn:aws:kms:*:*:key/*\"]\n }\n \n+variable \"external_secrets_secrets_manager_create_permission\" {\n+ description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ type = bool\n+ default = false\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -32,6 +32,7 @@ module \"wrapper\" {\n external_secrets_ssm_parameter_arns = try(each.value.external_secrets_ssm_parameter_arns, var.defaults.external_secrets_ssm_parameter_arns, [\"arn:aws:ssm:*:*:parameter/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n external_secrets_kms_key_arns = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n+ external_secrets_secrets_manager_create_permission = try(each.value.external_secrets_secrets_manager_create_permission, var.defaults.external_secrets_secrets_manager_create_permission, false)\n attach_fsx_lustre_csi_policy = try(each.value.attach_fsx_lustre_csi_policy, var.defaults.attach_fsx_lustre_csi_policy, false)\n fsx_lustre_csi_service_role_arns = try(each.value.fsx_lustre_csi_service_role_arns, var.defaults.fsx_lustre_csi_service_role_arns, [\"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"])\n attach_karpenter_controller_policy = try(each.value.attach_karpenter_controller_policy, var.defaults.attach_karpenter_controller_policy, false)\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.81.0\n+ rev: v1.82.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -155,11 +155,12 @@ module \"external_dns_irsa_role\" {\n module \"external_secrets_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"external-secrets\"\n- attach_external_secrets_policy = true\n- external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n- external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n- external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ role_name = \"external-secrets\"\n+ attach_external_secrets_policy = true\n+ external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n+ external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ external_secrets_secrets_manager_create_permission = false\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -211,6 +211,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -506,6 +506,16 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_kms_key_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\n+ \"secretsmanager:CreateSecret\"\n+ ]\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -183,6 +183,12 @@ variable \"external_secrets_kms_key_arns\" {\n default = [\"arn:aws:kms:*:*:key/*\"]\n }\n \n+variable \"external_secrets_secrets_manager_create_permission\" {\n+ description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ type = bool\n+ default = false\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -32,6 +32,7 @@ module \"wrapper\" {\n external_secrets_ssm_parameter_arns = try(each.value.external_secrets_ssm_parameter_arns, var.defaults.external_secrets_ssm_parameter_arns, [\"arn:aws:ssm:*:*:parameter/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n external_secrets_kms_key_arns = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n+ external_secrets_secrets_manager_create_permission = try(each.value.external_secrets_secrets_manager_create_permission, var.defaults.external_secrets_secrets_manager_create_permission, false)\n attach_fsx_lustre_csi_policy = try(each.value.attach_fsx_lustre_csi_policy, var.defaults.attach_fsx_lustre_csi_policy, false)\n fsx_lustre_csi_service_role_arns = try(each.value.fsx_lustre_csi_service_role_arns, var.defaults.fsx_lustre_csi_service_role_arns, [\"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"])\n attach_karpenter_controller_policy = try(each.value.attach_karpenter_controller_policy, var.defaults.attach_karpenter_controller_policy, false)\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.81.0\n+ rev: v1.82.0\n hooks:\n - id: terraform_fmt\n using - id: terraform_wrapper_module_for_each\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -155,11 +155,12 @@ module \"external_dns_irsa_role\" {\n module \"external_secrets_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = \"external-secrets\"\n- attach_external_secrets_policy = true\n- external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n- external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n- external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ role_name = \"external-secrets\"\n+ attach_external_secrets_policy = true\n+ external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n+ external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n+ external_secrets_secrets_manager_create_permission = false\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -211,6 +211,7 @@ No modules.\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_secrets_manager_create_permission\"></a> [external\\_secrets\\_secrets\\_manager\\_create\\_permission](#input\\_external\\_secrets\\_secrets\\_manager\\_create\\_permission) | Determins whether External Secrets may use secretsmanager:CreateSecret | `bool` | `false` | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -506,6 +506,16 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_kms_key_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.external_secrets_secrets_manager_create_permission ? [1] : []\n+ content {\n+ actions = [\n+ \"secretsmanager:CreateSecret\"\n+ ]\n+ resources = var.external_secrets_secrets_manager_arns\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -183,6 +183,12 @@ variable \"external_secrets_kms_key_arns\" {\n default = [\"arn:aws:kms:*:*:key/*\"]\n }\n \n+variable \"external_secrets_secrets_manager_create_permission\" {\n+ description = \"Determins whether External Secrets may use secretsmanager:CreateSecret\"\n+ type = bool\n+ default = false\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -32,6 +32,7 @@ module \"wrapper\" {\n external_secrets_ssm_parameter_arns = try(each.value.external_secrets_ssm_parameter_arns, var.defaults.external_secrets_ssm_parameter_arns, [\"arn:aws:ssm:*:*:parameter/*\"])\n external_secrets_secrets_manager_arns = try(each.value.external_secrets_secrets_manager_arns, var.defaults.external_secrets_secrets_manager_arns, [\"arn:aws:secretsmanager:*:*:secret:*\"])\n external_secrets_kms_key_arns = try(each.value.external_secrets_kms_key_arns, var.defaults.external_secrets_kms_key_arns, [\"arn:aws:kms:*:*:key/*\"])\n+ external_secrets_secrets_manager_create_permission = try(each.value.external_secrets_secrets_manager_create_permission, var.defaults.external_secrets_secrets_manager_create_permission, false)\n attach_fsx_lustre_csi_policy = try(each.value.attach_fsx_lustre_csi_policy, var.defaults.attach_fsx_lustre_csi_policy, false)\n fsx_lustre_csi_service_role_arns = try(each.value.fsx_lustre_csi_service_role_arns, var.defaults.fsx_lustre_csi_service_role_arns, [\"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"])\n attach_karpenter_controller_policy = try(each.value.attach_karpenter_controller_policy, var.defaults.attach_karpenter_controller_policy, false)\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis implementation causes the VPC CNI policy to be updated to give fewer permissions and mitigate the possibilities of attacks using the policy.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nThe motivation is in this documentation: [ABUSING AMAZON VPC CNI PLUGIN FOR KUBERNETES](https://www.elttam.com/blog/amazon-vpc-cni/#content). Due to the wild card [\"Resource\": \"*\"](https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/modules/iam-role-for-service-accounts-eks/policies.tf#L1367) on the VPC CNI policy and lack of any restricting conditions, the policy allows manipulating the EC2 networking of all EC2 instances, not just those in the node groups for the EKS cluster that was created with eksctl.\r\nTherefore, the policy was modified so that it is only possible to manage EKS nodes within the EKS VPC.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -235,8 +235,10 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_cluster_name\"></a> [vpc\\_cni\\_cluster\\_name](#input\\_vpc\\_cni\\_cluster\\_name) | The name of the cluster that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n+| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy. | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_vpc_id\"></a> [vpc\\_cni\\_vpc\\_id](#input\\_vpc\\_cni\\_vpc\\_id) | The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n \n ## Outputs\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1369,27 +1369,104 @@ resource \"aws_iam_role_policy_attachment\" \"velero\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # https://www.elttam.com/blog/amazon-vpc-cni/\n+ # https://github.com/aws/amazon-vpc-cni-k8s/blob/master/docs/iam-policy.md#scope-down-iam-policy-per-eks-cluster\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n- sid = \"IPV4\"\n actions = [\n- \"ec2:AssignPrivateIpAddresses\",\n- \"ec2:AttachNetworkInterface\",\n- \"ec2:CreateNetworkInterface\",\n- \"ec2:DeleteNetworkInterface\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\",\n- \"ec2:DetachNetworkInterface\",\n- \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:DescribeInstanceTypes\"\n ]\n resources = [\"*\"]\n }\n }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateTags\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals \"\n+ variable = \"aws:RequestTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\n+ \"arn:aws:ec2:*:*:subnet/*\",\n+ \"arn:aws:ec2:*:*:security-group/*\"\n+ ]\n+ condition {\n+ test = \"ArnEquals\"\n+ variable = \"ec2:Vpc\"\n+ values = [\"arn:aws:ec2:*:*:vpc/${var.vpc_cni_vpc_id}\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:DeleteNetworkInterface\",\n+ \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:AssignPrivateIpAddresses\",\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:instance/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/kubernetes.io/cluster/${var.vpc_cni_cluster_name}\"\n+ values = [\"owned\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:security-group/*\"]\n+ }\n+ }\n \n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -321,11 +321,23 @@ variable \"attach_vpc_cni_policy\" {\n }\n \n variable \"vpc_cni_enable_ipv4\" {\n- description = \"Determines whether to enable IPv4 permissions for VPC CNI policy\"\n+ description = \"Determines whether to enable IPv4 permissions for VPC CNI policy.\"\n type = bool\n default = false\n }\n \n+variable \"vpc_cni_cluster_name\" {\n+ description = \"The name of the cluster that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n+variable \"vpc_cni_vpc_id\" {\n+ description = \"The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"vpc_cni_enable_ipv6\" {\n description = \"Determines whether to enable IPv6 permissions for VPC CNI policy\"\n type = bool\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,8 @@ module \"wrapper\" {\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n attach_vpc_cni_policy = try(each.value.attach_vpc_cni_policy, var.defaults.attach_vpc_cni_policy, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n+ vpc_cni_cluster_name = try(each.value.vpc_cni_cluster_name, var.defaults.vpc_cni_cluster_name, \"\")\n+ vpc_cni_vpc_id = try(each.value.vpc_cni_vpc_id, var.defaults.vpc_cni_vpc_id, \"\")\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n attach_node_termination_handler_policy = try(each.value.attach_node_termination_handler_policy, var.defaults.attach_node_termination_handler_policy, false)\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -235,8 +235,10 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_cluster_name\"></a> [vpc\\_cni\\_cluster\\_name](#input\\_vpc\\_cni\\_cluster\\_name) | The name of the cluster that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n+| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy. | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_vpc_id\"></a> [vpc\\_cni\\_vpc\\_id](#input\\_vpc\\_cni\\_vpc\\_id) | The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n \n ## Outputs\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1369,27 +1369,104 @@ resource \"aws_iam_role_policy_attachment\" \"velero\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # https://www.elttam.com/blog/amazon-vpc-cni/\n+ # https://github.com/aws/amazon-vpc-cni-k8s/blob/master/docs/iam-policy.md#scope-down-iam-policy-per-eks-cluster\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n- sid = \"IPV4\"\n actions = [\n- \"ec2:AssignPrivateIpAddresses\",\n- \"ec2:AttachNetworkInterface\",\n- \"ec2:CreateNetworkInterface\",\n- \"ec2:DeleteNetworkInterface\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\",\n- \"ec2:DetachNetworkInterface\",\n- \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:DescribeInstanceTypes\"\n ]\n resources = [\"*\"]\n }\n }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateTags\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals \"\n+ variable = \"aws:RequestTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\n+ \"arn:aws:ec2:*:*:subnet/*\",\n+ \"arn:aws:ec2:*:*:security-group/*\"\n+ ]\n+ condition {\n+ test = \"ArnEquals\"\n+ variable = \"ec2:Vpc\"\n+ values = [\"arn:aws:ec2:*:*:vpc/${var.vpc_cni_vpc_id}\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:DeleteNetworkInterface\",\n+ \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:AssignPrivateIpAddresses\",\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:instance/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/kubernetes.io/cluster/${var.vpc_cni_cluster_name}\"\n+ values = [\"owned\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:security-group/*\"]\n+ }\n+ }\n \n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -321,11 +321,23 @@ variable \"attach_vpc_cni_policy\" {\n }\n \n variable \"vpc_cni_enable_ipv4\" {\n- description = \"Determines whether to enable IPv4 permissions for VPC CNI policy\"\n+ description = \"Determines whether to enable IPv4 permissions for VPC CNI policy.\"\n type = bool\n default = false\n }\n \n+variable \"vpc_cni_cluster_name\" {\n+ description = \"The name of the cluster that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n+variable \"vpc_cni_vpc_id\" {\n+ description = \"The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"vpc_cni_enable_ipv6\" {\n description = \"Determines whether to enable IPv6 permissions for VPC CNI policy\"\n type = bool\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,8 @@ module \"wrapper\" {\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n attach_vpc_cni_policy = try(each.value.attach_vpc_cni_policy, var.defaults.attach_vpc_cni_policy, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n+ vpc_cni_cluster_name = try(each.value.vpc_cni_cluster_name, var.defaults.vpc_cni_cluster_name, \"\")\n+ vpc_cni_vpc_id = try(each.value.vpc_cni_vpc_id, var.defaults.vpc_cni_vpc_id, \"\")\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n attach_node_termination_handler_policy = try(each.value.attach_node_termination_handler_policy, var.defaults.attach_node_termination_handler_policy, false)\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -235,8 +235,10 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_cluster_name\"></a> [vpc\\_cni\\_cluster\\_name](#input\\_vpc\\_cni\\_cluster\\_name) | The name of the cluster that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n+| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy. | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_vpc_id\"></a> [vpc\\_cni\\_vpc\\_id](#input\\_vpc\\_cni\\_vpc\\_id) | The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n \n ## Outputs\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1369,27 +1369,104 @@ resource \"aws_iam_role_policy_attachment\" \"velero\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # https://www.elttam.com/blog/amazon-vpc-cni/\n+ # https://github.com/aws/amazon-vpc-cni-k8s/blob/master/docs/iam-policy.md#scope-down-iam-policy-per-eks-cluster\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n- sid = \"IPV4\"\n actions = [\n- \"ec2:AssignPrivateIpAddresses\",\n- \"ec2:AttachNetworkInterface\",\n- \"ec2:CreateNetworkInterface\",\n- \"ec2:DeleteNetworkInterface\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\",\n- \"ec2:DetachNetworkInterface\",\n- \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:DescribeInstanceTypes\"\n ]\n resources = [\"*\"]\n }\n }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateTags\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals \"\n+ variable = \"aws:RequestTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\n+ \"arn:aws:ec2:*:*:subnet/*\",\n+ \"arn:aws:ec2:*:*:security-group/*\"\n+ ]\n+ condition {\n+ test = \"ArnEquals\"\n+ variable = \"ec2:Vpc\"\n+ values = [\"arn:aws:ec2:*:*:vpc/${var.vpc_cni_vpc_id}\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:DeleteNetworkInterface\",\n+ \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:AssignPrivateIpAddresses\",\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:instance/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/kubernetes.io/cluster/${var.vpc_cni_cluster_name}\"\n+ values = [\"owned\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:security-group/*\"]\n+ }\n+ }\n \n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -321,11 +321,23 @@ variable \"attach_vpc_cni_policy\" {\n }\n \n variable \"vpc_cni_enable_ipv4\" {\n- description = \"Determines whether to enable IPv4 permissions for VPC CNI policy\"\n+ description = \"Determines whether to enable IPv4 permissions for VPC CNI policy.\"\n type = bool\n default = false\n }\n \n+variable \"vpc_cni_cluster_name\" {\n+ description = \"The name of the cluster that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n+variable \"vpc_cni_vpc_id\" {\n+ description = \"The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"vpc_cni_enable_ipv6\" {\n description = \"Determines whether to enable IPv6 permissions for VPC CNI policy\"\n type = bool\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,8 @@ module \"wrapper\" {\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n attach_vpc_cni_policy = try(each.value.attach_vpc_cni_policy, var.defaults.attach_vpc_cni_policy, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n+ vpc_cni_cluster_name = try(each.value.vpc_cni_cluster_name, var.defaults.vpc_cni_cluster_name, \"\")\n+ vpc_cni_vpc_id = try(each.value.vpc_cni_vpc_id, var.defaults.vpc_cni_vpc_id, \"\")\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n attach_node_termination_handler_policy = try(each.value.attach_node_termination_handler_policy, var.defaults.attach_node_termination_handler_policy, false)\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -235,8 +235,10 @@ No modules.\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n | <a name=\"input_velero_s3_bucket_arns\"></a> [velero\\_s3\\_bucket\\_arns](#input\\_velero\\_s3\\_bucket\\_arns) | List of S3 Bucket ARNs that Velero needs access to in order to backup and restore cluster resources | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_cluster_name\"></a> [vpc\\_cni\\_cluster\\_name](#input\\_vpc\\_cni\\_cluster\\_name) | The name of the cluster that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n+| <a name=\"input_vpc_cni_enable_ipv4\"></a> [vpc\\_cni\\_enable\\_ipv4](#input\\_vpc\\_cni\\_enable\\_ipv4) | Determines whether to enable IPv4 permissions for VPC CNI policy. | `bool` | `false` | no |\n | <a name=\"input_vpc_cni_enable_ipv6\"></a> [vpc\\_cni\\_enable\\_ipv6](#input\\_vpc\\_cni\\_enable\\_ipv6) | Determines whether to enable IPv6 permissions for VPC CNI policy | `bool` | `false` | no |\n+| <a name=\"input_vpc_cni_vpc_id\"></a> [vpc\\_cni\\_vpc\\_id](#input\\_vpc\\_cni\\_vpc\\_id) | The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy. | `string` | `\"\"` | no |\n \n ## Outputs\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1369,27 +1369,104 @@ resource \"aws_iam_role_policy_attachment\" \"velero\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # https://www.elttam.com/blog/amazon-vpc-cni/\n+ # https://github.com/aws/amazon-vpc-cni-k8s/blob/master/docs/iam-policy.md#scope-down-iam-policy-per-eks-cluster\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n- sid = \"IPV4\"\n actions = [\n- \"ec2:AssignPrivateIpAddresses\",\n- \"ec2:AttachNetworkInterface\",\n- \"ec2:CreateNetworkInterface\",\n- \"ec2:DeleteNetworkInterface\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\",\n- \"ec2:DetachNetworkInterface\",\n- \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:DescribeInstanceTypes\"\n ]\n resources = [\"*\"]\n }\n }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateTags\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals \"\n+ variable = \"aws:RequestTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:CreateNetworkInterface\"\n+ ]\n+ resources = [\n+ \"arn:aws:ec2:*:*:subnet/*\",\n+ \"arn:aws:ec2:*:*:security-group/*\"\n+ ]\n+ condition {\n+ test = \"ArnEquals\"\n+ variable = \"ec2:Vpc\"\n+ values = [\"arn:aws:ec2:*:*:vpc/${var.vpc_cni_vpc_id}\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:DeleteNetworkInterface\",\n+ \"ec2:UnassignPrivateIpAddresses\",\n+ \"ec2:AssignPrivateIpAddresses\",\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:network-interface/*\"]\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:ResourceTag/cluster.k8s.amazonaws.com/name\"\n+ values = [var.vpc_cni_cluster_name]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:AttachNetworkInterface\",\n+ \"ec2:DetachNetworkInterface\",\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:instance/*\"]\n+ condition {\n+ to = \"StringEquals\"\n+ variable = \"aws:ResourceTag/kubernetes.io/cluster/${var.vpc_cni_cluster_name}\"\n+ values = [\"owned\"]\n+ }\n+ }\n+ }\n+ dynamic \"statement\" {\n+ for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n+ content {\n+ actions = [\n+ \"ec2:ModifyNetworkInterfaceAttribute\"\n+ ]\n+ resources = [\"arn:aws:ec2:*:*:security-group/*\"]\n+ }\n+ }\n \n # https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy\n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -321,11 +321,23 @@ variable \"attach_vpc_cni_policy\" {\n }\n \n variable \"vpc_cni_enable_ipv4\" {\n- description = \"Determines whether to enable IPv4 permissions for VPC CNI policy\"\n+ description = \"Determines whether to enable IPv4 permissions for VPC CNI policy.\"\n type = bool\n default = false\n }\n \n+variable \"vpc_cni_cluster_name\" {\n+ description = \"The name of the cluster that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n+variable \"vpc_cni_vpc_id\" {\n+ description = \"The ID of the VPC that the VPC CNI gives permissions for VPC CNI policy.\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"vpc_cni_enable_ipv6\" {\n description = \"Determines whether to enable IPv6 permissions for VPC CNI policy\"\n type = bool\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -54,6 +54,8 @@ module \"wrapper\" {\n velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [\"*\"])\n attach_vpc_cni_policy = try(each.value.attach_vpc_cni_policy, var.defaults.attach_vpc_cni_policy, false)\n vpc_cni_enable_ipv4 = try(each.value.vpc_cni_enable_ipv4, var.defaults.vpc_cni_enable_ipv4, false)\n+ vpc_cni_cluster_name = try(each.value.vpc_cni_cluster_name, var.defaults.vpc_cni_cluster_name, \"\")\n+ vpc_cni_vpc_id = try(each.value.vpc_cni_vpc_id, var.defaults.vpc_cni_vpc_id, \"\")\n vpc_cni_enable_ipv6 = try(each.value.vpc_cni_enable_ipv6, var.defaults.vpc_cni_enable_ipv6, false)\n attach_node_termination_handler_policy = try(each.value.attach_node_termination_handler_policy, var.defaults.attach_node_termination_handler_policy, false)\n node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [\"*\"])\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nAdd the ability to provide additional principal ARNs which could assume the role.\r\n\r\n## Motivation and Context\r\n\r\nPlease check the additions to the README.md file. I've tested this one with my private project with the real AWS setup and Kubernetes cluster, and it works correctly. I tried to come up with some solution without modifying the upstream module and do all the changes in my private Git repository, but I don't really have any ideas how could I override the `assume_role_policy` value (of the `aws_iam_role` resource) in a nice way without copy'n'pasting half of this module. If you have better ideas, please let me know. Thank you!\r\n\r\n## Breaking Changes\r\n\r\nThere are no breaking changes. The proposed code and changes should be backward compatible with any kind of existing Terraform code that uses this module.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-eks-role/README.md\n@@ -74,6 +74,29 @@ module \"iam_eks_role\" {\n }\n ```\n \n+## Provide additional principal ARNs which could assume the managed role\n+\n+In some cases you might need to provide additional custom principal ARNs which should be able to assume the role.\n+This kind of principal ARNs must be provided only in the `assume_role_policy` of the `aws_iam_role` resource.\n+The example below shows the case when the existing role of the `my-service-b` is able to assume the `my-service-a`\n+role.\n+\n+```hcl\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-eks-role\"\n+\n+ role_name = \"my-service-a\"\n+\n+ cluster_service_accounts = {\n+ \"cluster1\" = [\"default:my-serviceaccount\"]\n+ }\n+\n+ assume_role_additional_principals = [\n+ \"arn:aws:iam::123456789012:role/my-service-b\"\n+ ]\n+}\n+```\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n@@ -120,6 +143,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n+| <a name=\"input_assume_role_additional_principals\"></a> [assume\\_role\\_additional\\_principals](#input\\_assume\\_role\\_additional\\_principals) | ARNs of additional AWS principals which should be allowed to assume the managed role | `list(string)` | `null` | no |\n \n ## Outputs\n \n---\nmodules/iam-eks-role/main.tf\n@@ -58,6 +58,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.assume_role_additional_principals) > 0 ? [1] : []\n+\n+ content {\n+ sid = \"AdditionalAssumptionPrincipals\"\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ the type = \"AWS\"\n+ identifiers = var.assume_role_additional_principals\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -75,3 +75,9 @@ variable \"assume_role_condition_test\" {\n type = string\n default = \"StringEquals\"\n }\n+\n+variable \"assume_role_additional_principals\" {\n+ description = \"Additional AWS principal ARNs which should be allowed to assume the managed role\"\n+ type = list(string)\n+ default = null\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/README.md\n@@ -74,6 +74,29 @@ module \"iam_eks_role\" {\n }\n ```\n \n+## Provide additional principal ARNs which could assume the managed role\n+\n+In some cases you might need to provide additional custom principal ARNs which should be able to assume the role.\n+This kind of principal ARNs must be provided only in the `assume_role_policy` of the `aws_iam_role` resource.\n+The example below shows the case when the existing role of the `my-service-b` is able to assume the `my-service-a`\n+role.\n+\n+```hcl\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-eks-role\"\n+\n+ role_name = \"my-service-a\"\n+\n+ cluster_service_accounts = {\n+ \"cluster1\" = [\"default:my-serviceaccount\"]\n+ }\n+\n+ assume_role_additional_principals = [\n+ \"arn:aws:iam::123456789012:role/my-service-b\"\n+ ]\n+}\n+```\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n@@ -120,6 +143,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n+| <a name=\"input_assume_role_additional_principals\"></a> [assume\\_role\\_additional\\_principals](#input\\_assume\\_role\\_additional\\_principals) | ARNs of additional AWS principals which should be allowed to assume the managed role | `list(string)` | `null` | no |\n \n ## Outputs\n \n---\nmodules/iam-eks-role/main.tf\n@@ -58,6 +58,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.assume_role_additional_principals) > 0 ? [1] : []\n+\n+ content {\n+ sid = \"AdditionalAssumptionPrincipals\"\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.assume_role_additional_principals\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -75,3 +75,9 @@ variable \"assume_role_condition_test\" {\n type = string\n default = \"StringEquals\"\n @@ \"assume_role_additional_principals\" {\n+ description = \"Additional AWS principal ARNs which should be allowed to assume the managed role\"\n+ type = list(string)\n+ default = null\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/README.md\n@@ -74,6 +74,29 @@ module \"iam_eks_role\" {\n }\n ```\n \n+## Provide additional principal ARNs which could assume the managed role\n+\n+In some cases you might need to provide additional custom principal ARNs which should be able to assume the role.\n+This kind of principal ARNs must be provided only in the `assume_role_policy` of the `aws_iam_role` resource.\n+The example below shows the case when the existing role of the `my-service-b` is able to assume the `my-service-a`\n+role.\n+\n+```hcl\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-eks-role\"\n+\n+ role_name = \"my-service-a\"\n+\n+ cluster_service_accounts = {\n+ \"cluster1\" = [\"default:my-serviceaccount\"]\n+ }\n+\n+ assume_role_additional_principals = [\n+ \"arn:aws:iam::123456789012:role/my-service-b\"\n+ ]\n+}\n+```\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n@@ -120,6 +143,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n+| <a name=\"input_assume_role_additional_principals\"></a> [assume\\_role\\_additional\\_principals](#input\\_assume\\_role\\_additional\\_principals) | ARNs of additional AWS principals which should be allowed to assume the managed role | `list(string)` | `null` | no |\n \n ## Outputs\n \n---\nmodules/iam-eks-role/main.tf\n@@ -58,6 +58,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.assume_role_additional_principals) > 0 ? [1] : []\n+\n+ content {\n+ sid = \"AdditionalAssumptionPrincipals\"\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.assume_role_additional_principals\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -75,3 +75,9 @@ variable \"assume_role_condition_test\" {\n type = string\n default = \"StringEquals\"\n }\n+\n+variable \"assume_role_additional_principals\" {\n+ role description = \"Additional AWS principal ARNs which should be allowed to assume the managed role\"\n+ type = list(string)\n+ default = null\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/README.md\n@@ -74,6 +74,29 @@ module \"iam_eks_role\" {\n }\n ```\n \n+## Provide additional principal ARNs which could assume the managed role\n+\n+In some cases you might need to provide additional custom principal ARNs which should be able to assume the role.\n+This kind of principal ARNs must be provided only in the `assume_role_policy` of the `aws_iam_role` resource.\n+The example below shows the case when the existing role of the `my-service-b` is able to assume the `my-service-a`\n+role.\n+\n+```hcl\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-eks-role\"\n+\n+ role_name = \"my-service-a\"\n+\n+ cluster_service_accounts = {\n+ \"cluster1\" = [\"default:my-serviceaccount\"]\n+ }\n+\n+ assume_role_additional_principals = [\n+ \"arn:aws:iam::123456789012:role/my-service-b\"\n+ ]\n+}\n+```\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n@@ -120,6 +143,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | ARNs of any policies to attach to the IAM role | `map(string)` | `{}` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add the the IAM role | `map(any)` | `{}` | no |\n+| <a name=\"input_assume_role_additional_principals\"></a> [assume\\_role\\_additional\\_principals](#input\\_assume\\_role\\_additional\\_principals) | ARNs of additional AWS principals which should be allowed to assume the managed role | `list(string)` | `null` | no |\n \n ## Outputs\n \n---\nmodules/iam-eks-role/main.tf\n@@ -58,6 +58,21 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.assume_role_additional_principals) > 0 ? [1] : []\n+\n+ content {\n+ sid = \"AdditionalAssumptionPrincipals\"\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.assume_role_additional_principals\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -75,3 +75,9 @@ variable \"assume_role_condition_test\" {\n type = string\n default = \"StringEquals\"\n }\n+\n+variable \"assume_role_additional_principals\" {\n+ description = \"Additional AWS principal ARNs which should be allowed to assume the managed role\"\n+ type = list(string)\n+ default = null\n+}\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nAdd github oidc provider thumbprints list sorting\r\n\r\n## Motivation and Context\r\nAfter the introduction of https://github.com/terraform-aws-modules/terraform-aws-iam/pull/403 we started facing terraform drift changes in our nightly workflow runs. \r\nIt tries to store the same thumbprints in a different order because [distinct](https://developer.hashicorp.com/terraform/language/functions/distinct) function preserves ordering:\r\n```\r\nTerraform will perform the following actions:\r\n\r\n # aws_iam_openid_connect_provider.this[0] will be updated in-place\r\n ~ resource \"aws_iam_openid_connect_provider\" \"this\" {\r\n id = \"arn:aws:iam::***:oidc-provider/token.actions.githubusercontent.com\"\r\n tags = {\r\n \"managedBy\" = \"terragrunt\"\r\n }\r\n ~ thumbprint_list = [\r\n - \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\",\r\n - \"f879abce0008e4eb126e0097e46620f5aaae26ad\",\r\n \"6938fd4d98bab03faadb97b34396831e3780aea1\",\r\n + \"f879abce0008e4eb126e0097e46620f5aaae26ad\",\r\n + \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\",\r\n ]\r\n # (4 unchanged attributes hidden)\r\n }\r\n\r\nPlan: 0 to add, 1 to change, 0 to destroy.\r\n```\r\nStoring the list in a sorted way should prevent this behavior.\r\n## Breaking Changes\r\nno\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n+ thumbprint_list = sort(distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints)))\n \n tags = var.tags\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n+ thumbprint_list = sort(distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints)))\n \n tags = var.tags\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n +15,7 client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n+ thumbprint_list = sort(distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints)))\n \n tags = var.tags\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n+ thumbprint_list = sort(distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints)))\n \n tags = var.tags\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nI would like to make optional the creation of the alias\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nIf someone does not want to enable alias, we dont have an option yet.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nno breaking change. I keep the default behavior.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nuser -13,3 +13,13 @@ module \"iam_account\" {\n minimum_password_length = 6\n require_numbers = false\n }\n+\n+module \"iam_account_no_alias\" {\n+ source = \"../../modules/iam-account\"\n+\n+ account_alias = \"\"\n+ create_account_alias = false\n+\n+ minimum_password_length = 6\n+ require_numbers = false\n+}\n---\nmodules/iam-account/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"this\" {\n }\n \n resource \"aws_iam_account_alias\" \"this\" {\n+ count = var.create_account_alias ? 1 : 0\n account_alias = var.account_alias\n }\n \n---\nmodules/iam-account/variables.tf\n@@ -15,6 +15,11 @@ variable \"create_account_password_policy\" {\n default = true\n }\n \n+variable \"create_account_alias\" {\n+ description = \"Whether to create AWS IAM account alias\"\n+ type = bool\n+ default = true\n+}\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n---\n\n\n---\n\nChoice B:\nexamples/iam-account/main.tf\n@@ -13,3 +13,13 @@ module \"iam_account\" {\n minimum_password_length = 6\n require_numbers = false\n }\n+\n+module \"iam_account_no_alias\" {\n+ source = \"../../modules/iam-account\"\n+\n+ account_alias = \"\"\n+ create_account_alias = false\n+\n+ minimum_password_length = 6\n+ require_numbers = false\n+}\n---\nmodules/iam-account/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"this\" {\n }\n \n resource \"aws_iam_account_alias\" \"this\" {\n+ count {\n+ = var.create_account_alias ? 1 : 0\n account_alias = var.account_alias\n }\n \n---\nmodules/iam-account/variables.tf\n@@ -15,6 +15,11 @@ variable \"create_account_password_policy\" {\n default = true\n }\n \n+variable \"create_account_alias\" {\n+ description = \"Whether to create AWS IAM account alias\"\n+ type = bool\n+ default = true\n+}\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n---\n\n\n---\n\nChoice C:\nexamples/iam-account/main.tf\n@@ -13,3 +13,13 @@ module \"iam_account\" {\n minimum_password_length = 6\n require_numbers = false\n }\n+\n+module \"iam_account_no_alias\" {\n+ source = \"../../modules/iam-account\"\n+\n+ account_alias = \"\"\n+ create_account_alias = false\n+\n+ minimum_password_length = 6\n+ require_numbers = false\n+}\n---\nmodules/iam-account/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"this\" {\n }\n \n resource \"aws_iam_account_alias\" \"this\" {\n+ count = var.create_account_alias ? 1 : 0\n account_alias = var.account_alias\n }\n \n---\nmodules/iam-account/variables.tf\n@@ -15,6 +15,11 @@ variable \"create_account_password_policy\" {\n default = true\n }\n \n+variable \"create_account_alias\" {\n+ description = \"Whether to create AWS IAM account alias\"\n+ type = bool\n+ default = true\n+}\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n---\n\n\n---\n\nChoice D:\nexamples/iam-account/main.tf\n@@ -13,3 +13,13 @@ module \"iam_account\" {\n minimum_password_length = 6\n require_numbers = false\n }\n+\n+module \"iam_account_no_alias\" {\n+ source = \"../../modules/iam-account\"\n+\n+ account_alias = \"\"\n+ create_account_alias = false\n+\n+ minimum_password_length = 6\n+ require_numbers = false\n+}\n---\nmodules/iam-account/main.tf\n@@ -3,6 +3,7 @@ data \"aws_caller_identity\" \"this\" {\n }\n \n resource \"aws_iam_account_alias\" \"this\" {\n+ count = var.create_account_alias ? 1 : 0\n account_alias = var.account_alias\n }\n \n---\nmodules/iam-account/variables.tf\n@@ -15,6 +15,11 @@ variable \"create_account_password_policy\" {\n default = true\n : \n+variable \"create_account_alias\" {\n+ description = \"Whether to create AWS IAM account alias\"\n+ type = bool\n+ default = true\n+}\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n---\n\n\n---\n"
}
] |
C
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\ncorrect spelling of the `enable_mfa_enforcement` option in `iam-group-with-policies`\r\n\r\n## Motivation and Context\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/377\r\nCloses #401 \r\n\r\n## Breaking Changes\r\nyes, anybody with the old spelling `enable_mfa_enforcment` will be required to update their code to the new option.\r\n\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ X ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\n```\r\nTerraform fmt............................................................Passed\r\nTerraform wrapper with for_each in module................................Passed\r\nTerraform validate.......................................................Passed\r\nTerraform docs...........................................................Passed\r\nTerraform validate with tflint...........................................Passed\r\ncheck for merge conflicts................................................Passed\r\nfix end of files.........................................................Passed\r\n```\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can of the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n |\n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 with @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nAdd additional thumbprint list as needed. \r\n\r\n## Motivation and Context\r\n- Resolves #400\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-provider/README.md\n@@ -48,6 +48,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_thumbprints\"></a> [additional\\_thumbprints](#input\\_additional\\_thumbprints) | List of additional thumbprints to add to the thumbprint list. | `list(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,13 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_thumbprints\" {\n+ description = \"List of additional thumbprints to add to the thumbprint list.\"\n+ type = list(string)\n+ # +21,13 default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ additional_thumbprints = try(each.value.additional_thumbprints, var.defaults.additional_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-provider/README.md\n@@ -48,6 +48,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_thumbprints\"></a> [additional\\_thumbprints](#input\\_additional\\_thumbprints) | List of additional thumbprints to add to the thumbprint list. | `list(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n @@ url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,13 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_thumbprints\" {\n+ description = \"List of additional thumbprints to add to the thumbprint list.\"\n+ type = list(string)\n+ # https://github.blog/changelog/2023-06-27-github-actions-update-on-oidc-integration-with-aws/\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ additional_thumbprints = try(each.value.additional_thumbprints, var.defaults.additional_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-provider/README.md\n@@ -48,6 +48,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_thumbprints\"></a> [additional\\_thumbprints](#input\\_additional\\_thumbprints) | List of additional thumbprints to add to the thumbprint list. | `list(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all Defaults | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,13 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_thumbprints\" {\n+ description = \"List of additional thumbprints to add to the thumbprint list.\"\n+ type = list(string)\n+ # https://github.blog/changelog/2023-06-27-github-actions-update-on-oidc-integration-with-aws/\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ additional_thumbprints = try(each.value.additional_thumbprints, var.defaults.additional_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-provider/README.md\n@@ -48,6 +48,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_additional_thumbprints\"></a> [additional\\_thumbprints](#input\\_additional\\_thumbprints) | List of additional thumbprints to add to the thumbprint list. | `list(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -15,7 +15,7 @@ resource \"aws_iam_openid_connect_provider\" \"this\" {\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = distinct(concat(data.tls_certificate.this[0].certificates[*].sha1_fingerprint, var.additional_thumbprints))\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,13 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"additional_thumbprints\" {\n+ description = \"List of additional thumbprints to add to the thumbprint list.\"\n+ type = list(string)\n+ # https://github.blog/changelog/2023-06-27-github-actions-update-on-oidc-integration-with-aws/\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ additional_thumbprints = try(each.value.additional_thumbprints, var.defaults.additional_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n-Aadded the ability to specify arn to update the target group binding of aws load balancer.\r\n\r\n## Motivation and Context\r\nI would like to set up an arn so that if I make a mistake in the target group I want to update, the iam policy will not allow me to update it.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -221,6 +221,7 @@ No modules.\n | <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n+| <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1003,13 +1003,20 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n- resources = [\"*\"]\n+ resources = var.load_balancer_controller_targetgroup_arns\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -261,6 +261,12 @@ variable \"attach_load_balancer_controller_targetgroup_binding_only_policy\" {\n default = false\n }\n \n+variable \"load_balancer_controller_targetgroup_arns\" {\n+ description = \"List of Target groups ARNs using Load Balancer Controller\"\n+ type = list(string)\n+ default = [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+}\n+\n # AWS Appmesh Controller\n variable \"attach_appmesh_controller_policy\" {\n description = \"Determines whether to attach the Appmesh Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -44,6 +44,7 @@ module \"wrapper\" {\n karpenter_sqs_queue_arn = try(each.value.karpenter_sqs_queue_arn, var.defaults.karpenter_sqs_queue_arn, null)\n attach_load_balancer_controller_policy = try(each.value.attach_load_balancer_controller_policy, var.defaults.attach_load_balancer_controller_policy, false)\n attach_load_balancer_controller_targetgroup_binding_only_policy = try(each.value.attach_load_balancer_controller_targetgroup_binding_only_policy, var.defaults.attach_load_balancer_controller_targetgroup_binding_only_policy, false)\n+ load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n attach_appmesh_controller_policy = try(each.value.attach_appmesh_controller_policy, var.defaults.attach_appmesh_controller_policy, false)\n attach_appmesh_envoy_proxy_policy = try(each.value.attach_appmesh_envoy_proxy_policy, var.defaults.attach_appmesh_envoy_proxy_policy, false)\n attach_amazon_managed_service_prometheus_policy = try(each.value.attach_amazon_managed_service_prometheus_policy, var.defaults.attach_amazon_managed_service_prometheus_policy, false)\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -221,6 +221,7 @@ No modules.\n | <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n+| <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1003,13 +1003,20 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n- resources = [\"*\"]\n+ resources = var.load_balancer_controller_targetgroup_arns\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -261,6 +261,12 @@ variable \"attach_load_balancer_controller_targetgroup_binding_only_policy\" {\n default = false\n }\n \n+variable \"load_balancer_controller_targetgroup_arns\" {\n+ description = \"List of Target groups ARNs using Load Balancer Controller\"\n+ type `string` = list(string)\n+ default = [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+}\n+\n # AWS Appmesh Controller\n variable \"attach_appmesh_controller_policy\" {\n description = \"Determines whether to attach the Appmesh Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -44,6 +44,7 @@ module \"wrapper\" {\n karpenter_sqs_queue_arn = try(each.value.karpenter_sqs_queue_arn, var.defaults.karpenter_sqs_queue_arn, null)\n attach_load_balancer_controller_policy = try(each.value.attach_load_balancer_controller_policy, var.defaults.attach_load_balancer_controller_policy, false)\n attach_load_balancer_controller_targetgroup_binding_only_policy = try(each.value.attach_load_balancer_controller_targetgroup_binding_only_policy, var.defaults.attach_load_balancer_controller_targetgroup_binding_only_policy, false)\n+ load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n attach_appmesh_controller_policy = try(each.value.attach_appmesh_controller_policy, var.defaults.attach_appmesh_controller_policy, false)\n attach_appmesh_envoy_proxy_policy = try(each.value.attach_appmesh_envoy_proxy_policy, var.defaults.attach_appmesh_envoy_proxy_policy, false)\n attach_amazon_managed_service_prometheus_policy = try(each.value.attach_amazon_managed_service_prometheus_policy, var.defaults.attach_amazon_managed_service_prometheus_policy, false)\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -221,6 +221,7 @@ No modules.\n | <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n+| <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1003,13 +1003,20 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n- resources = [\"*\"]\n+ resources = var.load_balancer_controller_targetgroup_arns\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -261,6 +261,12 @@ variable \"attach_load_balancer_controller_targetgroup_binding_only_policy\" {\n default = false\n }\n \n+variable \"load_balancer_controller_targetgroup_arns\" {\n+ description = \"List of Target groups ARNs using Load Balancer Controller\"\n+ type = list(string)\n+ default = [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+}\n+\n # AWS Appmesh Controller\n variable \"attach_appmesh_controller_policy\" {\n description = \"Determines whether to attach the Appmesh Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -44,6 +44,7 @@ module \"wrapper\" {\n karpenter_sqs_queue_arn = try(each.value.karpenter_sqs_queue_arn, var.defaults.karpenter_sqs_queue_arn, null)\n attach_load_balancer_controller_policy = try(each.value.attach_load_balancer_controller_policy, var.defaults.attach_load_balancer_controller_policy, false)\n attach_load_balancer_controller_targetgroup_binding_only_policy = try(each.value.attach_load_balancer_controller_targetgroup_binding_only_policy, var.defaults.attach_load_balancer_controller_targetgroup_binding_only_policy, false)\n+ load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n attach_appmesh_controller_policy = try(each.value.attach_appmesh_controller_policy, var.defaults.attach_appmesh_controller_policy, false)\n attach_appmesh_envoy_proxy_policy = try(each.value.attach_appmesh_envoy_proxy_policy, var.defaults.attach_appmesh_envoy_proxy_policy, false)\n attach_amazon_managed_service_prometheus_policy = try(each.value.attach_amazon_managed_service_prometheus_policy, var.defaults.attach_amazon_managed_service_prometheus_policy, false)\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -221,6 +221,7 @@ No modules.\n | <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n+| <a name=\"input_load_balancer_controller_targetgroup_arns\"></a> [load\\_balancer\\_controller\\_targetgroup\\_arns](#input\\_load\\_balancer\\_controller\\_targetgroup\\_arns) | List of Target groups ARNs using Load Balancer Controller | `list(string)` | <pre>[<br> \"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1003,13 +1003,20 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ actions = [\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n- resources = [\"*\"]\n+ resources = var.load_balancer_controller_targetgroup_arns\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -261,6 +261,12 @@ variable \"attach_load_balancer_controller_targetgroup_binding_only_policy\" {\n default = false\n }\n \n+variable \"load_balancer_controller_targetgroup_arns\" {\n+ description = \"List of Target groups ARNs using Load Balancer Controller\"\n+ type = list(string)\n+ default = [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+}\n+\n # AWS Appmesh Controller\n variable \"attach_appmesh_controller_policy\" {\n description = \"Determines whether to attach the Appmesh Controller policy to the role\"\n---\nwrappers/iam-role-for-service-accounts-eks/main.tf\n@@ -44,6 +44,7 @@ module \"wrapper\" {\n karpenter_sqs_queue_arn = try(each.value.karpenter_sqs_queue_arn, var.defaults.karpenter_sqs_queue_arn, null)\n attach_load_balancer_controller_policy = try(each.value.attach_load_balancer_controller_policy, var.defaults.attach_load_balancer_controller_policy, false)\n attach_load_balancer_controller_targetgroup_binding_only_policy = try(each.value.attach_load_balancer_controller_targetgroup_binding_only_policy, var.defaults.attach_load_balancer_controller_targetgroup_binding_only_policy, false)\n+ load_balancer_controller_targetgroup_arns = try(each.value.load_balancer_controller_targetgroup_arns, var.defaults.load_balancer_controller_targetgroup_arns, [\"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*\"])\n attach_appmesh_controller_policy = try(each.value.attach_appmesh_controller_policy, var.defaults.attach_appmesh_controller_policy, false)\n attach_appmesh_envoy_proxy_policy = try(each.value.attach_appmesh_envoy_proxy_policy, var.defaults.attach_appmesh_envoy_proxy_policy, false)\n attach_amazon_managed_service_prometheus_policy = try(each.value.attach_amazon_managed_service_prometheus_policy, var.defaults.attach_amazon_managed_service_prometheus_policy, false)\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n`enable_mfa_enforcment` should be `enable_mfa_enforcement`\r\n\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/blob/f537b20bb4d31f014c1c63a5b4151177aed694e0/modules/iam-group-with-policies/variables.tf#L37\r\n\r\n## Description\r\n\r\nAs far as I know, the word \"enforcment\" does not exist.\r\n\r\n## Motivation and Context\r\n\r\n It offends the editor's spell checker, etc., so I fixed it.\r\n\r\nIt is a minor correction and has not been issued.\r\n\r\n## Breaking Changes\r\n\r\nIf any user is already using this argument in this module, it may need to be modified.\r\n\r\n## How Has This Been Tested?\r\n\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies IAM = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/README.md\n@@ -44,7 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n-| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n+| <a name=\"input_enable_mfa_enforcement\"></a> [enable\\_mfa\\_enforcement](#input\\_enable\\_mfa\\_enforcement) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -146,7 +146,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n }\n \n dynamic \"statement\" {\n- for_each = var.enable_mfa_enforcment ? [1] : []\n+ for_each = var.enable_mfa_enforcement ? [1] : []\n \n content {\n sid = \"DenyAllExceptListedIfNoMFA\"\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -34,7 +34,7 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n-variable \"enable_mfa_enforcment\" {\n+variable \"enable_mfa_enforcement\" {\n description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n type = bool\n default = true\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -9,7 +9,7 @@ module \"wrapper\" {\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n- enable_mfa_enforcment | = try(each.value.enable_mfa_enforcment, var.defaults.enable_mfa_enforcment, true)\n+ enable_mfa_enforcement = try(each.value.enable_mfa_enforcement, var.defaults.enable_mfa_enforcement, true)\n attach_iam_self_management_policy = try(each.value.attach_iam_self_management_policy, var.defaults.attach_iam_self_management_policy, true)\n iam_self_management_policy_name_prefix = try(each.value.iam_self_management_policy_name_prefix, var.defaults.iam_self_management_policy_name_prefix, \"IAMSelfManagement-\")\n aws_account_id = try(each.value.aws_account_id, var.defaults.aws_account_id, \"\")\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nFollowing GitHub's announcement that can be found on their [blog](https://github.blog/changelog/2023-06-27-github-actions-update-on-oidc-integration-with-aws/) there are now multiple thumbprints that are required to integrate AWS with GitHub actions.\r\n\r\nWe have been running with this change for some time now and wanted to submit upstream in case others are having issues with their GitHub actions workflows assuming AWS roles.\r\n\r\n## Motivation and Context\r\nSolves errors where GitHub actions workflows are unable to assume an IAM role due to an invalid thumbprint.\r\n\r\n## Breaking Changes\r\nN/A - this change is additive and won't interfere with the current implementation.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s) (N/A)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n\r\nAs previously mentioned, we have been testing this change for a while. We vendored this change into our own Terraform workspace and have been running without issue for a while now. During the last couple of weeks, GitHub has changed thumbprints twice and our change detected when this occurred and showed up in a Terraform plan.\n\n---\n\nChoice A:\nmodules/iam-github-oidc-provider/README.md\n@@ -30,7 +30,6 @@ module \"iam_github_oidc_provider\" {\n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n-| <a name=\"provider_tls\"></a> [tls](#provider\\_tls) | >= 3.0 |\n \n ## Modules\n \n@@ -42,14 +41,14 @@ No modules.\n |------|------|\n | [aws_iam_openid_connect_provider.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n-| [tls_certificate.this](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/data-sources/certificate) | data source |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n+| <a name=\"input_github_intermediary_thumbprints\"></a> [github\\_intermediary\\_thumbprints](#input\\_github\\_intermediary\\_thumbprints) | GitHub actions SSL intermeidary thumbprints | `set(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n \n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -4,18 +4,12 @@ data \"aws_partition\" \"current\" {}\n # GitHub OIDC Provider\n ################################################################################\n \n-data \"tls_certificate\" \"this\" {\n- count = var.create ? 1 : 0\n-\n- url = var.url\n-}\n-\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = var.github_intermediary_thumbprints\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,12 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"github_intermediary_thumbprints\" {\n+ description = \"GitHub actions SSL intermeidary thumbprints\"\n+ type = set(string)\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ github_intermediary_thumbprints = try(each.value.github_intermediary_thumbprints, var.defaults.github_intermediary_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-provider/README.md\n@@ -30,7 +30,6 @@ module \"iam_github_oidc_provider\" {\n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n-| <a name=\"provider_tls\"></a> [tls](#provider\\_tls) | >= 3.0 |\n \n ## Modules\n \n@@ -42,14 +41,14 @@ No modules.\n |------|------|\n | [aws_iam_openid_connect_provider.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n-| [tls_certificate.this](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/data-sources/certificate) | data source |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n+| <a name=\"input_github_intermediary_thumbprints\"></a> [github\\_intermediary\\_thumbprints](#input\\_github\\_intermediary\\_thumbprints) | GitHub actions SSL intermeidary thumbprints | `set(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n \n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -4,18 +4,12 @@ data \"aws_partition\" \"current\" {}\n # GitHub OIDC Provider\n ################################################################################\n \n-data \"tls_certificate\" \"this\" {\n- count = var.create ? 1 : 0\n-\n- url = var.url\n-}\n-\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = var.github_intermediary_thumbprints\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,12 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"github_intermediary_thumbprints\" {\n+ description = \"GitHub actions SSL intermeidary thumbprints\"\n+ type = set(string)\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags |\n = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ github_intermediary_thumbprints = try(each.value.github_intermediary_thumbprints, var.defaults.github_intermediary_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-provider/README.md\n@@ -30,7 +30,6 @@ module \"iam_github_oidc_provider\" {\n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n-| <a name=\"provider_tls\"></a> [tls](#provider\\_tls) | >= 3.0 |\n \n ## Modules\n \n@@ -42,14 +41,14 @@ No modules.\n |------|------|\n | [aws_iam_openid_connect_provider.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n-| [tls_certificate.this](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/data-sources/certificate) | data source |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n+| <a name=\"input_github_intermediary_thumbprints\"></a> [github\\_intermediary\\_thumbprints](#input\\_github\\_intermediary\\_thumbprints) | GitHub actions SSL intermeidary thumbprints | `set(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n \n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -4,18 +4,12 @@ data \"aws_partition\" \"current\" {}\n # OIDC Provider\n ################################################################################\n \n-data \"tls_certificate\" \"this\" {\n- count = var.create ? 1 : 0\n-\n- url = var.url\n-}\n-\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n url = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = var.github_intermediary_thumbprints\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,12 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"github_intermediary_thumbprints\" {\n+ description = \"GitHub actions SSL intermeidary thumbprints\"\n+ type = set(string)\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ github_intermediary_thumbprints = try(each.value.github_intermediary_thumbprints, var.defaults.github_intermediary_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-provider/README.md\n@@ -30,7 +30,6 @@ module \"iam_github_oidc_provider\" {\n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n-| <a name=\"provider_tls\"></a> [tls](#provider\\_tls) | >= 3.0 |\n \n ## Modules\n \n@@ -42,14 +41,14 @@ No modules.\n |------|------|\n | [aws_iam_openid_connect_provider.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n-| [tls_certificate.this](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/data-sources/certificate) | data source |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_client_id_list\"></a> [client\\_id\\_list](#input\\_client\\_id\\_list) | List of client IDs (also known as audiences) for the IAM OIDC provider. Defaults to STS service if not values are provided | `list(string)` | `[]` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |\n+| <a name=\"input_github_intermediary_thumbprints\"></a> [github\\_intermediary\\_thumbprints](#input\\_github\\_intermediary\\_thumbprints) | GitHub actions SSL intermeidary thumbprints | `set(string)` | <pre>[<br> \"6938fd4d98bab03faadb97b34396831e3780aea1\",<br> \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to the resources created | `map(any)` | `{}` | no |\n | <a name=\"input_url\"></a> [url](#input\\_url) | The URL of the identity provider. Corresponds to the iss claim | `string` | `\"https://token.actions.githubusercontent.com\"` | no |\n \n---\nmodules/iam-github-oidc-provider/main.tf\n@@ -4,18 +4,12 @@ data \"aws_partition\" \"current\" {}\n # GitHub OIDC Provider\n ################################################################################\n \n-data \"tls_certificate\" \"this\" {\n- count = var.create ? 1 : 0\n-\n- url = var.url\n-}\n-\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n url var.github_intermediary_thumbprints\n = var.url\n client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ thumbprint_list = var.github_intermediary_thumbprints\n \n tags = var.tags\n }\n---\nmodules/iam-github-oidc-provider/variables.tf\n@@ -21,3 +21,12 @@ variable \"url\" {\n type = string\n default = \"https://token.actions.githubusercontent.com\"\n }\n+\n+variable \"github_intermediary_thumbprints\" {\n+ description = \"GitHub actions SSL intermeidary thumbprints\"\n+ type = set(string)\n+ default = [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ]\n+}\n---\nwrappers/iam-github-oidc-provider/main.tf\n@@ -7,4 +7,8 @@ module \"wrapper\" {\n tags = try(each.value.tags, var.defaults.tags, {})\n client_id_list = try(each.value.client_id_list, var.defaults.client_id_list, [])\n url = try(each.value.url, var.defaults.url, \"https://token.actions.githubusercontent.com\")\n+ github_intermediary_thumbprints = try(each.value.github_intermediary_thumbprints, var.defaults.github_intermediary_thumbprints, [\n+ \"6938fd4d98bab03faadb97b34396831e3780aea1\",\n+ \"1c58a3a8518e8759bf075b76b750d4f2df264fcd\"\n+ ])\n }\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nWhen using the `--aws-zone-tags` filter feature of external-dns, `route53:ListTagsForResource` permissions are required.\r\n\r\nWithout it, external-dns will fail to start.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nThis change adds the necessary permissions required for external-dns to start when using the `--aws-zone-tags` filter.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNo breaking changes.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have applied the changes from my fork and confirmed external-dns starts successfully\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -439,6 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n+ \"route53:ListTagsForResource\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -439,6 +439,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n+ \"route53:ListTagsForResource\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -439,6 +439,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n+ \"route53:ListTagsForResource\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -439,6 +439,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n actions = [\n \"route53:ListHostedZones\",\n \"route53:ListResourceRecordSets\",\n+ \"route53:ListTagsForResource\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n"
}
] |
B
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -397,6 +397,27 @@ module \"iam_eks_role\" {\n }\n }\n \n+module \"kasten_irsa\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ version = \"~> v5.3.1\"\n+\n+ role_name = format(\"bea-babbage-eks-%s-kasten-irsa\", local.region)\n+ role_permissions_boundary_arn = format(\"arn:aws:iam::%s:policy/bea-platform-boundary-iam-policy\", data.aws_caller_identity.current.account_id)\n+\n+ oidc_providers = {\n+ main = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"kasten-io:kasten-sa\"]\n+ }\n+ }\n+ role_policy_arns = {\n+ policy = data.aws_iam_policy.kasten_access_policy.arn\n+ }\n+ tags = local.tags\n+}\n+\n+\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -397,6 +397,27 @@ module \"iam_eks_role\" {\n }\n }\n \n+module \"kasten_irsa\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ version = \"~> v5.3.1\"\n+\n+ role_name = format(\"bea-babbage-eks-%s-kasten-irsa\", local.region)\n+ role_permissions_boundary_arn = format(\"arn:aws:iam::%s:policy/bea-platform-boundary-iam-policy\", data.aws_caller_identity.current.account_id)\n+\n+ oidc_providers = {\n+ main = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"kasten-io:kasten-sa\"]\n+ }\n+ }\n+ role_policy_arns = {\n+ policy = data.aws_iam_policy.kasten_access_policy.arn\n+ }\n+ tags = local.tags\n+}\n+\n+\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -397,6 +397,27 @@ module \"iam_eks_role\" {\n }\n }\n \n+module \"kasten_irsa\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ version = \"~> v5.3.1\"\n+\n+ role_name = format(\"bea-babbage-eks-%s-kasten-irsa\", local.region)\n+ role_permissions_boundary_arn = format(\"arn:aws:iam::%s:policy/bea-platform-boundary-iam-policy\", data.aws_caller_identity.current.account_id)\n+\n+ oidc_providers = {\n+ main = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"kasten-io:kasten-sa\"]\n+ }\n+ }\n+ role_policy_arns = {\n+ policy = data.aws_iam_policy.kasten_access_policy.arn\n+ }\n+ tags = local.tags\n+}\n+\n+\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -397,6 +397,27 @@ module \"iam_eks_role\" {\n }\n }\n \n+module \"kasten_irsa\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ version = \"~> v5.3.1\"\n+\n+ role_name = format(\"bea-babbage-eks-%s-kasten-irsa\", local.region)\n+ role_permissions_boundary_arn = format(\"arn:aws:iam::%s:policy/bea-platform-boundary-iam-policy\", data.aws_caller_identity.current.account_id)\n+\n+ oidc_providers = {\n+ main = {\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"kasten-io:kasten-sa\"]\n+ }\n+ }\n+ role_policy_arns = {\n+ policy = data.aws_iam_policy.kasten_access_policy.arn\n+ }\n+ tags = local.tags\n+}\n+\n+\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\n\n\n---\n"
}
] |
A
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\nThis adds the variable `path` to `iam-group-with-policies`. \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nThis was seemingly left out as an oversight since `iam-group-with-assumable-roles-policy` does include `path` as a variable.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-group-with-policies/main.tf\n@@ -45,6 +45,7 @@ module \"iam_group_with_custom_policies\" {\n source = \"../../modules/iam-group-with-policies\"\n \n name = \"custom\"\n+ path = \"/custom/\"\n \n group_users = [\n module.iam_user1.iam_user_name,\n---\nmodules/iam-group-with-policies/README.md\n@@ -48,6 +48,7 @@ No modules.\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n+| <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-policies/main.tf\n@@ -6,6 +6,7 @@ resource \"aws_iam_group\" \"this\" {\n count = var.create_group ? 1 : 0\n \n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_membership\" \"this\" {\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -10,6 +10,12 @@ variable \"name\" {\n default = \"\"\n }\n \n+variable \"path\" {\n+ description = \"Desired path for the IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_group = try(each.value.create_group, var.defaults.create_group, true)\n name = try(each.value.name, var.defaults.name, \"\")\n+ path @@ = try(each.value.path, var.defaults.path, \"/\")\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n---\n\n\n---\n\nChoice B:\nexamples/iam-group-with-policies/main.tf\n@@ -45,6 +45,7 @@ module \"iam_group_with_custom_policies\" {\n source = \"../../modules/iam-group-with-policies\"\n \n name = \"custom\"\n+ path = \"/custom/\"\n \n group_users = [\n module.iam_user1.iam_user_name,\n---\nmodules/iam-group-with-policies/README.md\n@@ -48,6 +48,7 @@ No modules.\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n+| <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-policies/main.tf\n@@ -6,6 +6,7 @@ resource \"aws_iam_group\" \"this\" {\n count = var.create_group ? 1 : 0\n \n name = var.name\n+ path = var.path\n }\n \n \"aws_iam_group_membership\" \"this\" {\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -10,6 +10,12 @@ variable \"name\" {\n default = \"\"\n }\n \n+variable \"path\" {\n+ description = \"Desired path for the IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_group = try(each.value.create_group, var.defaults.create_group, true)\n name = try(each.value.name, var.defaults.name, \"\")\n+ path = try(each.value.path, var.defaults.path, \"/\")\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n---\n\n\n---\n\nChoice C:\nexamples/iam-group-with-policies/main.tf\n@@ -45,6 +45,7 @@ module \"iam_group_with_custom_policies\" {\n source = \"../../modules/iam-group-with-policies\"\n \n name = \"custom\"\n+ path = \"/custom/\"\n \n group_users = [\n module.iam_user1.iam_user_name,\n---\nmodules/iam-group-with-policies/README.md\n@@ -48,6 +48,7 @@ No modules.\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with | self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n+| <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-policies/main.tf\n@@ -6,6 +6,7 @@ resource \"aws_iam_group\" \"this\" {\n count = var.create_group ? 1 : 0\n \n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_membership\" \"this\" {\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -10,6 +10,12 @@ variable \"name\" {\n default = \"\"\n }\n \n+variable \"path\" {\n+ description = \"Desired path for the IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_group = try(each.value.create_group, var.defaults.create_group, true)\n name = try(each.value.name, var.defaults.name, \"\")\n+ path = try(each.value.path, var.defaults.path, \"/\")\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n---\n\n\n---\n\nChoice D:\nexamples/iam-group-with-policies/main.tf\n@@ -45,6 +45,7 @@ module \"iam_group_with_custom_policies\" {\n source = \"../../modules/iam-group-with-policies\"\n \n name = \"custom\"\n+ path = \"/custom/\"\n \n group_users = [\n module.iam_user1.iam_user_name,\n---\nmodules/iam-group-with-policies/README.md\n@@ -48,6 +48,7 @@ No modules.\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n+| <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-policies/main.tf\n@@ -6,6 +6,7 @@ resource \"aws_iam_group\" \"this\" {\n count = var.create_group ? 1 : 0\n \n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_membership\" \"this\" {\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -10,6 +10,12 @@ variable \"name\" {\n default = \"\"\n }\n \n+variable \"path\" {\n+ description = \"Desired path for the IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"group_users\" {\n description = \"List of IAM users to have in an IAM group which can assume the role\"\n type = list(string)\n---\nwrappers/iam-group-with-policies/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_group = try(each.value.create_group, var.defaults.create_group, true)\n name = try(each.value.name, var.defaults.name, \"\")\n+ path = try(each.value.path, var.defaults.path, \"/\")\n group_users = try(each.value.group_users, var.defaults.group_users, [])\n custom_group_policy_arns = try(each.value.custom_group_policy_arns, var.defaults.custom_group_policy_arns, [])\n custom_group_policies = try(each.value.custom_group_policies, var.defaults.custom_group_policies, [])\n---\n\n\n---\n"
}
] |
D
|
[
{
"role": "system",
"content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter."
},
{
"role": "user",
"content": "Task Description:\n## Description\r\n\r\nWhen using the `iam-role-for-service-accounts-eks` module with the `allow_self_assume_role` set to `true` a dynamic statement is generated for the policy. This policy uses a local role_name_condition computed using the coalesce function as follows:\r\n`coalesce(var.role_name, \"${var.role_name_prefix}*\")`\r\nThe issue comes from the fact that the `var.role_name_prefix` is `null` by default, and cannot be included in a string template. The error generated is:\r\n`The expression result is null. Cannot include a null value in a string template.`\r\n\r\n\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\nThis change solves the issue generated when the `allow_self_assume_role` set to `true`. It is a fix to handle the different cases properly\r\n- Resolves #383 \r\n\r\n\r\n## Breaking Changes\r\nThe PR does not introduce any breaking changes. \r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\nChanges have been tested by creating a new example taking the `module.cert_manager_irsa_role` as a base and setting `allow_self_assume_role` to `true`. The new example is included in the PR to make sure this case is always properly handled, it is under `module.cert_manager_irsa_role_self_assume`\r\nThe original example has been tested with the new changes to make sure nothing is broken. \r\n\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -31,7 +31,8 @@ module \"disabled\" {\n module \"irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = local.name\n+ role_name = = local.name\n+ allow_self_assume_role = true\n \n oidc_providers = {\n one = {\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -7,7 +7,7 @@ locals {\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n- role_name_condition = try(coalesce(var.role_name, \"${var.role_name_prefix}*\"), null)\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -31,7 +31,8 @@ module \"disabled\" {\n module \"irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = local.name\n+ role_name = local.name\n+ allow_self_assume_role = true\n \n oidc_providers = {\n one = {\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -7,7 +7,7 @@ locals {\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n- role_name_condition = try(coalesce(var.role_name, \"${var.role_name_prefix}*\"), null)\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -31,7 +31,8 @@ module \"disabled\" {\n module \"irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = data.aws_partition.current.dns_suffix\n role_name = local.name\n+ allow_self_assume_role = true\n \n oidc_providers = {\n one = {\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -7,7 +7,7 @@ locals {\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n region = data.aws_region.current.name\n- role_name_condition = try(coalesce(var.role_name, \"${var.role_name_prefix}*\"), null)\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -31,7 +31,8 @@ module \"disabled\" {\n module \"irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n- role_name = local.name\n+ role_name = local.name\n+ allow_self_assume_role = true\n \n oidc_providers = {\n one = {\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -7,7 +7,7 @@ locals {\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n region = = data.aws_region.current.name\n- role_name_condition = try(coalesce(var.role_name, \"${var.role_name_prefix}*\"), null)\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n data \"aws_iam_policy_document\" \"this\" {\n---\n\n\n---\n"
}
] |
B
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.