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\nAdd ability for controlling whether or not to create a policy\r\n\r\n## Motivation and Context\r\nIn certain scenarios can be useful to decide which specific policy should be created or not. Let's imagine that we create a module from this module for creating a set of policies that might change depending on the account you are targeting. This change allows you to do that.\r\n\r\n## Breaking Changes\r\nThere is no breaking change as the module still behaving the same by default.\r\n\r\n## How Has This Been Tested?\r\n- [βœ…] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [βœ…] Tested over my own AWS account.\n\n---\n\nChoice A:\nexamples/iam-policy/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | |\n | <a name=\"module_iam_policy_from_data_source\"></a> [iam\\_policy\\_from\\_data\\_source](#module\\_iam\\_policy\\_from\\_data\\_source) | ../../modules/iam-policy | |\n+| <a name=\"module_iam_policy_optional\"></a> [iam\\_policy\\_optional](#module\\_iam\\_policy\\_optional) | ../../modules/iam-policy | |\n \n ## Resources\n \n---\nexamples/iam-policy/main.tf\n@@ -53,3 +53,9 @@ module \"iam_policy_from_data_source\" {\n PolicyDescription = \"Policy created using example from data source\"\n }\n }\n+\n+module \"iam_policy_optional\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ create_policy = false\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create the IAM policy | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create_policy ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n@@ -7,4 +9,3 @@ resource \"aws_iam_policy\" \"policy\" {\n \n tags = var.tags\n }\n-\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,29 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create_policy\" {\n+ description = \"Whether to create the IAM policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n---\n\n\n---\n\nChoice B:\nexamples/iam-policy/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | |\n | <a name=\"module_iam_policy_from_data_source\"></a> [iam\\_policy\\_from\\_data\\_source](#module\\_iam\\_policy\\_from\\_data\\_source) | ../../modules/iam-policy | |\n+| <a name=\"module_iam_policy_optional\"></a> [iam\\_policy\\_optional](#module\\_iam\\_policy\\_optional) | ../../modules/iam-policy | |\n \n ## Resources\n \n---\nexamples/iam-policy/main.tf\n@@ -53,3 +53,9 @@ module \"iam_policy_from_data_source\" {\n PolicyDescription = \"Policy created using example from data source\"\n }\n }\n+\n+module \"iam_policy_optional\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ create_policy = false\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create the IAM policy | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" +1,6 {\n+ count = var.create_policy ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n@@ -7,4 +9,3 @@ resource \"aws_iam_policy\" \"policy\" {\n \n tags = var.tags\n }\n-\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,29 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create_policy\" {\n+ description = \"Whether to create the IAM policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n---\n\n\n---\n\nChoice C:\nexamples/iam-policy/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | |\n | <a name=\"module_iam_policy_from_data_source\"></a> [iam\\_policy\\_from\\_data\\_source](#module\\_iam\\_policy\\_from\\_data\\_source) | ../../modules/iam-policy | |\n+| <a name=\"module_iam_policy_optional\"></a> [iam\\_policy\\_optional](#module\\_iam\\_policy\\_optional) | ../../modules/iam-policy | |\n \n ## Resources\n \n---\nexamples/iam-policy/main.tf\n@@ -53,3 +53,9 @@ module \"iam_policy_from_data_source\" {\n PolicyDescription = \"Policy created using example from data source\"\n }\n }\n+\n+module \"iam_policy_optional\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ create_policy = false\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create the IAM policy | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create_policy ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n@@ -7,4 +9,3 @@ resource \"aws_iam_policy\" \"policy\" {\n \n tags = var.tags\n }\n-\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,29 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value \n---\nexamples/iam-policy/main.tf\n@@ = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create_policy\" {\n+ description = \"Whether to create the IAM policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n---\n\n\n---\n\nChoice D:\nexamples/iam-policy/README.md\n@@ -34,6 +34,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | |\n | <a name=\"module_iam_policy_from_data_source\"></a> [iam\\_policy\\_from\\_data\\_source](#module\\_iam\\_policy\\_from\\_data\\_source) | ../../modules/iam-policy | |\n+| <a name=\"module_iam_policy_optional\"></a> [iam\\_policy\\_optional](#module\\_iam\\_policy\\_optional) | ../../modules/iam-policy | |\n \n ## Resources\n \n---\nexamples/iam-policy/main.tf\n@@ -53,3 +53,9 @@ module \"iam_policy_from_data_source\" {\n PolicyDescription = \"Policy created using example from data source\"\n }\n }\n+\n+module \"iam_policy_optional\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ create_policy = false\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_create_policy\"></a> [create\\_policy](#input\\_create\\_policy) | Whether to create the IAM policy | `bool` | `true` | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create_policy ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n@@ -7,4 +9,3 @@ resource \"aws_iam_policy\" \"policy\" {\n \n tags = var.tags\n }\n-\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,29 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the }\n-\n---\nmodules/iam-policy/outputs.tf\n@@ in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create_policy\" {\n+ description = \"Whether to create the IAM policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\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\nUpdate version constraints to prevent from (theoretical) problems when copy pasting examples...\r\n\r\n## Motivation and Context\r\n\r\nSomeone (!) could copy paste and have errors difficult to interpret:\r\n```\r\nβ”‚ Error: Unsupported attribute\r\nβ”‚\r\nβ”‚ on roles.tf line 186, in module \"iam_group_with_assumable_roles_policy\":\r\nβ”‚ 186: module.iam_assumable_role_custom.iam_role_arn\r\nβ”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€\r\nβ”‚ β”‚ module.iam_assumable_role_custom is a object, known only after apply\r\nβ”‚\r\nβ”‚ This object does not have an attribute named \"iam_role_arn\".\r\n``` \r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n\r\nCopy pasted and it worked. :)\n\n---\n\nChoice A:\nREADME.md\n@@ -12,7 +12,7 @@\n ```hcl\n module \"iam_account\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-account\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n account_alias = \"awesome-company\"\n \n@@ -26,7 +26,7 @@ module \"iam_account\" {\n ```hcl\n module \"iam_assumable_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -51,7 +51,7 @@ module \"iam_assumable_role\" {\n ```hcl\n module \"iam_assumable_role_with_oidc\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -75,7 +75,7 @@ module \"iam_assumable_role_with_oidc\" {\n ```hcl\n module \"iam_assumable_role_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -99,7 +99,7 @@ module \"iam_assumable_role_with_saml\" {\n ```hcl\n module \"iam_assumable_roles\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -121,7 +121,7 @@ module \"iam_assumable_roles\" {\n ```hcl\n module \"iam_assumable_roles_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_admin_role = true\n \n@@ -139,7 +139,7 @@ module \"iam_assumable_roles_with_saml\" {\n ```hcl\n module \"iam_user\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-user\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"vasya.pupkin\"\n force_destroy = true\n@@ -155,7 +155,7 @@ module \"iam_user\" {\n ```hcl\n module \"iam_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"example\"\n path = \"/\"\n@@ -183,7 +183,7 @@ EOF\n ```hcl\n module \"iam_group_with_assumable_roles_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-assumable-roles-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"production-readonly\"\n \n@@ -203,7 +203,7 @@ module \"iam_group_with_assumable_roles_policy\" {\n ```hcl\n module \"iam_group_with_policies\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-policies\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"superadmins\"\n \n@@ -285,4 +285,4 @@ Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with he\n \n ## License\n \n-Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details.\n+Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details. \n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -12,7 +12,7 @@\n ```hcl\n module \"iam_account\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-account\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n account_alias = \"awesome-company\"\n \n@@ -26,7 +26,7 @@ module \"iam_account\" {\n ```hcl\n module \"iam_assumable_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -51,7 +51,7 @@ module \"iam_assumable_role\" {\n ```hcl\n module \"iam_assumable_role_with_oidc\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -75,7 +75,7 @@ module \"iam_assumable_role_with_oidc\" {\n ```hcl\n module \"iam_assumable_role_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -99,7 +99,7 @@ module \"iam_assumable_role_with_saml\" {\n ```hcl\n module \"iam_assumable_roles\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -121,7 +121,7 @@ module \"iam_assumable_roles\" {\n ```hcl\n module \"iam_assumable_roles_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_admin_role = true\n \n@@ -139,7 +139,7 @@ module \"iam_assumable_roles_with_saml\" {\n ```hcl\n module \"iam_user\" {\n version source = \"terraform-aws-modules/iam/aws//modules/iam-user\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"vasya.pupkin\"\n force_destroy = true\n@@ -155,7 +155,7 @@ module \"iam_user\" {\n ```hcl\n module \"iam_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"example\"\n path = \"/\"\n@@ -183,7 +183,7 @@ EOF\n ```hcl\n module \"iam_group_with_assumable_roles_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-assumable-roles-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"production-readonly\"\n \n@@ -203,7 +203,7 @@ module \"iam_group_with_assumable_roles_policy\" {\n ```hcl\n module \"iam_group_with_policies\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-policies\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"superadmins\"\n \n@@ -285,4 +285,4 @@ Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with he\n \n ## License\n \n-Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details.\n+Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details. \n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -12,7 +12,7 @@\n ```hcl\n module \"iam_account\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-account\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n account_alias = \"awesome-company\"\n \n@@ -26,7 +26,7 @@ module \"iam_account\" {\n ```hcl\n module \"iam_assumable_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -51,7 +51,7 @@ module \"iam_assumable_role\" {\n ```hcl\n module \"iam_assumable_role_with_oidc\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -75,7 +75,7 @@ module \"iam_assumable_role_with_oidc\" {\n ```hcl\n module \"iam_assumable_role_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -99,7 +99,7 @@ module \"iam_assumable_role_with_saml\" {\n ```hcl\n module \"iam_assumable_roles\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -121,7 +121,7 @@ module \"iam_assumable_roles\" {\n ```hcl\n module \"iam_assumable_roles_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_admin_role = true\n \n@@ -139,7 +139,7 @@ module \"iam_assumable_roles_with_saml\" {\n ```hcl\n module \"iam_user\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-user\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"vasya.pupkin\"\n force_destroy = true\n@@ -155,7 +155,7 @@ module \"iam_user\" {\n ```hcl\n module \"iam_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"example\"\n path = \"/\"\n@@ -183,7 +183,7 @@ EOF\n ```hcl\n module \"iam_group_with_assumable_roles_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-assumable-roles-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"production-readonly\"\n \n@@ -203,7 +203,7 @@ module \"iam_group_with_assumable_roles_policy\" {\n ```hcl\n module \"iam_group_with_policies\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-policies\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"superadmins\"\n \n@@ -285,4 +285,4 @@ Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with he\n \n ## License\n \n-Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details.\n+Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details. \n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -12,7 +12,7 @@\n ```hcl\n module \"iam_account\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-account\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n account_alias = \"awesome-company\"\n \n@@ -26,7 +26,7 @@ module \"iam_account\" {\n ```hcl\n module \"iam_assumable_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -51,7 +51,7 @@ module \"iam_assumable_role\" {\n ```hcl\n module \"iam_assumable_role_with_oidc\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -75,7 +75,7 @@ module \"iam_assumable_role_with_oidc\" {\n ```hcl\n module \"iam_assumable_role_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_role = true\n \n@@ -99,7 +99,7 @@ module \"iam_assumable_role_with_saml\" {\n ```hcl\n module \"iam_assumable_roles\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n trusted_role_arns = [\n \"arn:aws:iam::307990089504:root\",\n@@ -121,7 +121,7 @@ module \"iam_assumable_roles\" {\n ```hcl\n module \"iam_assumable_roles_with_saml\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-roles-with-saml\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n create_admin_role = true\n \n@@ -139,7 +139,7 @@ module \"iam_assumable_roles_with_saml\" {\n ```hcl\n module \"iam_user\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-user\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"vasya.pupkin\"\n force_destroy = true\n@@ -155,7 +155,7 @@ module \"iam_user\" {\n ```hcl\n module \"iam_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n- version = \"~> 3.0\"\n+ \"superadmins\"\n version = \"~> 4.3\"\n \n name = \"example\"\n path = \"/\"\n@@ -183,7 +183,7 @@ EOF\n ```hcl\n module \"iam_group_with_assumable_roles_policy\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-assumable-roles-policy\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"production-readonly\"\n \n@@ -203,7 +203,7 @@ module \"iam_group_with_assumable_roles_policy\" {\n ```hcl\n module \"iam_group_with_policies\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-group-with-policies\"\n- version = \"~> 3.0\"\n+ version = \"~> 4.3\"\n \n name = \"superadmins\"\n \n@@ -285,4 +285,4 @@ Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with he\n \n ## License\n \n-Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details.\n+Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/LICENSE) for full details. \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:\nFixes #154 \r\nFixes #129\n\n---\n\nChoice A:\nexamples/iam-assumable-role/main.tf\n@@ -75,7 +75,7 @@ module \"iam_assumable_role_sts\" {\n create_role = true\n \n role_name = \"custom_sts\"\n- role_requires_mfa = false\n+ role_requires_mfa = true\n \n role_sts_externalid = [\n \"some-id-goes-here\",\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n@@ -56,6 +56,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 = length(local.role_sts_externalid) != 0 ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = local.role_sts_externalid\n+ }\n+ }\n values }\n }\n \n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role/main.tf\n@@ -75,7 +75,7 @@ module \"iam_assumable_role_sts\" {\n create_role = true\n \n role_name = \"custom_sts\"\n- role_requires_mfa = false\n+ role_requires_mfa = true\n \n role_sts_externalid = [\n \"some-id-goes-here\",\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n@@ -56,6 +56,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 = != 0 ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = local.role_sts_externalid\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role/main.tf\n@@ -75,7 +75,7 @@ module \"iam_assumable_role_sts\" {\n create_role = true\n \n role_name = \"custom_sts\"\n- role_requires_mfa = false\n+ role_requires_mfa = true\n \n role_sts_externalid = [\n \"some-id-goes-here\",\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n@@ -56,6 +56,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 = length(local.role_sts_externalid) != 0 ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = local.role_sts_externalid\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role/main.tf\n@@ -75,7 +75,7 @@ module \"iam_assumable_role_sts\" {\n create_role = true\n \n role_name = \"custom_sts\"\n- role_requires_mfa = false\n+ role_requires_mfa = true\n \n role_sts_externalid = [\n \"some-id-goes-here\",\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n@@ -56,6 +56,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 = length(local.role_sts_externalid) != 0 ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = local.role_sts_externalid\n+ }\n+ }\n }\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\nThis adds support for cross-account assumable role with OIDC\r\n\r\n## Motivation and Context\r\nWe have a use-case where a EKS service account in an account should be able to assume a role in a EKS cluster in another account.\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/157\r\n\r\n## Breaking Changes\r\nIt doesn't bring a breaking change.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nIn my environment, the module `iam-assumable-role-with-oidc` is used as a submodule in our custom irsa terraform module. \r\nI created a new irsa module, calling my updated `terraform-aws-iam//modules/iam-assumable-role-with-oidc`.\r\nAs a variable, I've set `oidc_fully_qualified_audience` to `sts.amazonaws.com` and then ran `tf apply`\r\n\r\nBelow the relevant part of it:\r\n``` \r\n# module.k8s_crossaccount_irsa.module.iam_assumable_role_with_oidc.aws_iam_role.this[0] will be created\r\n + resource \"aws_iam_role\" \"this\" {\r\n + arn = (known after apply)\r\n + assume_role_policy = jsonencode(\r\n {\r\n + Statement = [\r\n + {\r\n + Action = \"sts:AssumeRoleWithWebIdentity\"\r\n + Condition = {\r\n + StringLike = {\r\n + oidc.eks.eu-west-1.amazonaws.com/id/my_oidc_provider_id:aud = [\r\n + \"sts.amazonaws.com\",\r\n ]\r\n }\r\n }\r\n + Effect = \"Allow\"\r\n + Principal = {\r\n + Federated = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.eu-west-1.amazonaws.com/id/my_oidc_provider_id\"\r\n }\r\n + Sid = \"\"\r\n },\r\n ]\r\n + Version = \"2012-10-17\"\r\n }\r\n )\r\n + create_date = (known after apply)\r\n + force_detach_policies = false\r\n + id = (known after apply)\r\n + managed_policy_arns = (known after apply)\r\n + max_session_duration = 3600\r\n + name = \"cluster-a-test-role\"\r\n + path = \"/\"\r\n + tags = {\r\n + \"Role\" = \"role-with-oidc\"\r\n }\r\n + unique_id = (known after apply)\r\n\r\n + inline_policy {\r\n + name = (known after apply)\r\n + policy = (known after apply)\r\n }\r\n }\r\n\r\n # module.k8s_crossaccount_irsa.module.iam_assumable_role_with_oidc.aws_iam_role_policy_attachment.custom[0] will be created\r\n + resource \"aws_iam_role_policy_attachment\" \"custom\" {\r\n + id = (known after apply)\r\n + policy_arn = (known after apply)\r\n + role = \"cluster-a-test-role\"\r\n }\r\n```\r\n\r\nterraform version: `v0.14.6` \r\naws provider version: `v3.37.0`\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -43,6 +43,7 @@ No modules.\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` | `false` | 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_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 | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_fully_qualified_audiences\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,12 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise.\"\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---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -43,6 +43,7 @@ No modules.\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` | `false` | 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_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 | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? policy. : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_fully_qualified_audiences\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,12 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise.\"\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---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -43,6 +43,7 @@ No modules.\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` | `false` | 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_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The audience to be added to the role policy. role 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 | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_fully_qualified_audiences\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,12 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise.\"\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---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -43,6 +43,7 @@ No modules.\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` | `false` | 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_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 | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:aud\"\n+ values = var.oidc_fully_qualified_audiences\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,12 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The audience to be added to the role policy. Set to sts.amazonaws.com for cross-account assumable role. Leave empty otherwise.\"\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---\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 \"sensitive\" flag to output \"pgp_key\" for module iam-user. \r\nFix `Error: Output refers to sensitive values`.\r\n\r\n## Motivation and Context\r\n\r\nFix `Error: Output refers to sensitive values`.\r\n\r\n## Breaking Changes\r\n\r\nNone\r\n\r\n## How Has This Been Tested?\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/outputs.tf\n@@ -83,6 +83,7 @@ output \"iam_access_key_status\" {\n \n output \"pgp_key\" {\n description = \"PGP key used to encrypt sensitive data for this user (if empty - secrets secrets not encrypted)\"\n+ sensitive = true\n value = var.pgp_key\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-user/outputs.tf\n@@ -83,6 +83,7 @@ output \"iam_access_key_status\" {\n \n output \"pgp_key\" {\n description = \"PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted)\"\n+ sensitive = true\n value = var.pgp_key\n }\n \n---\n\n\n---\n\nChoice C:\noutput -83,6 +83,7 @@ output \"iam_access_key_status\" {\n \n output \"pgp_key\" {\n description = \"PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted)\"\n+ sensitive = true\n value = var.pgp_key\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-user/outputs.tf\n@@ -83,6 +83,7 @@ this \"iam_access_key_status\" {\n \n output \"pgp_key\" {\n description = \"PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted)\"\n+ sensitive = true\n value = var.pgp_key\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<!--- Describe your changes in detail -->\r\n\r\nAdd `oidc_fully_qualified_audiences` and `oidc_audiences_with_wildcards` options work like `oidc_fully_qualified_subjects` and `oidc_subjects_with_wildcards`.\r\n\r\nFor example, input\r\n```\r\noidc_fully_qualified_audiences = [\"sts.amazonaws.com\", \"test-records\"]\r\n``` \r\nwill output\r\n```\r\n ~ resource \"aws_iam_role\" \"this\" {\r\n ~ assume_role_policy = jsonencode(\r\n ~ {\r\n ~ Statement = [\r\n ~ {\r\n ~ Condition = {\r\n ~ StringEquals = {\r\n ~ oidc.eks.ap-southeast-1.amazonaws.com/id/XXXXXXXX:aud = \"sts.amazonaws.com\" -> [\r\n + \"sts.amazonaws.com\",\r\n + \"test-records\",\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\nEnable [IRSA option](https://github.com/terraform-aws-modules/terraform-aws-eks#input_enable_irsa) in EKS module will create a OIDC provider with `sts.amazonaws.com` audience. It's need to be configured for making service account association works. \r\n\r\nEKS module version: `v.16.1.0`\r\n\r\n## Breaking Changes\r\nNone.\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 tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -45,6 +45,8 @@ No modules.\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_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+| <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The fully qualified OIDC audiences to be added to the role policy | `set(string)` | `[]` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The OIDC audience using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | <a name=\"input_provider_urls\"></a> [provider\\_urls](#input\\_provider\\_urls) | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,27 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\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 }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,18 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The fully qualified OIDC audiences to be added to the role policy\"\n+ type = set(string)\n+ default = []\n+}\n+\n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The OIDC 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---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -45,6 +45,8 @@ No modules.\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_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+| <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The fully qualified OIDC audiences to be added to the role policy | `set(string)` | `[]` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The OIDC audience using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | <a name=\"input_provider_urls\"></a> [provider\\_urls](#input\\_provider\\_urls) | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,27 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"${statement.value}:aud\"\n+ = 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 }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,18 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The fully qualified OIDC audiences to be added to the role policy\"\n+ type = set(string)\n+ default = []\n+}\n+\n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The OIDC 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---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -45,6 +45,8 @@ No modules.\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_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+| <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The fully qualified OIDC audiences to be added to the role policy | `set(string)` | `[]` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The OIDC audience using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to several URLs. | `string` | `\"\"` | no |\n | <a name=\"input_provider_urls\"></a> [provider\\_urls](#input\\_provider\\_urls) | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,27 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\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 }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,18 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The fully qualified OIDC audiences to be added to the role policy\"\n+ type = set(string)\n+ default = []\n+}\n+\n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The OIDC 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---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -45,6 +45,8 @@ No modules.\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_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+| <a name=\"input_oidc_fully_qualified_audiences\"></a> [oidc\\_fully\\_qualified\\_audiences](#input\\_oidc\\_fully\\_qualified\\_audiences) | The fully qualified OIDC audiences to be added to the role policy | `set(string)` | `[]` | no |\n+| <a name=\"input_oidc_audiences_with_wildcards\"></a> [oidc\\_audiences\\_with\\_wildcards](#input\\_oidc\\_audiences\\_with\\_wildcards) | The OIDC audience using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | <a name=\"input_provider_url\"></a> [provider\\_url](#input\\_provider\\_url) | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | <a name=\"input_provider_urls\"></a> [provider\\_urls](#input\\_provider\\_urls) | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -48,6 +48,27 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_subjects_with_wildcards\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n+\n+ content {\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 }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -89,6 +89,18 @@ variable \"oidc_subjects_with_wildcards\" {\n default = []\n }\n \n+variable \"oidc_fully_qualified_audiences\" {\n+ description = \"The fully qualified OIDC audiences to be added to the role policy\"\n+ type = set(string)\n+ default = []\n+}\n+\n+variable \"oidc_audiences_with_wildcards\" {\n+ description = \"The OIDC 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---\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:\nFixes #146\n\n---\n\nChoice A:\nexamples/iam-user/outputs.tf\n@@ -41,11 +41,13 @@ output \"this_iam_access_key_encrypted_secret\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = module.iam_user.this_iam_access_key_secret\n+ sensitive = true\n }\n \n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password\"\n value = module.iam_user.this_iam_access_key_ses_smtp_password_v4\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -43,6 +43,7 @@ output \"this_iam_access_key_id\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ sensitive = true\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -65,6 +66,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" ),\n 0\n )\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\n\n\n---\n\nChoice B:\nexamples/iam-user/outputs.tf\n@@ -41,11 +41,13 @@ output \"this_iam_access_key_encrypted_secret\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = module.iam_user.this_iam_access_key_secret\n+ sensitive = true\n }\n \n \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password\"\n value = module.iam_user.this_iam_access_key_ses_smtp_password_v4\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -43,6 +43,7 @@ output \"this_iam_access_key_id\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ sensitive = true\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -65,6 +66,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n ),\n 0\n )\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\n\n\n---\n\nChoice C:\nexamples/iam-user/outputs.tf\n@@ -41,11 +41,13 @@ output \"this_iam_access_key_encrypted_secret\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = module.iam_user.this_iam_access_key_secret\n+ sensitive = true\n }\n \n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password\"\n value = module.iam_user.this_iam_access_key_ses_smtp_password_v4\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -43,6 +43,7 @@ output \"this_iam_access_key_id\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ sensitive = true\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -65,6 +66,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n ),\n 0\n )\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\n\n\n---\n\nChoice D:\nexamples/iam-user/outputs.tf\n@@ -41,11 +41,13 @@ output \"this_iam_access_key_encrypted_secret\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n value = module.iam_user.this_iam_access_key_secret\n+ sensitive = true\n }\n \n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password\"\n value = module.iam_user.this_iam_access_key_ses_smtp_password_v4\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -43,6 +43,7 @@ output \"this_iam_access_key_id\" {\n output \"this_iam_access_key_secret\" {\n description = \"The access key value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ sensitive = true\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -65,6 +66,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n ),\n 0\n )\n+ sensitive = true\n }\n \n output \"this_iam_access_key_status\" {\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\nTerraform release v0.15.0 several old function have been removed.\r\nhttps://www.hashicorp.com/blog/announcing-hashicorp-terraform-0-15-general-availability\r\nhttps://github.com/hashicorp/terraform/releases/tag/v0.15.0\r\nhttps://www.terraform.io/upgrade-guides/0-15.html\r\n\r\n\r\n\r\nThe outputs of the `aws_iam_access_key.this_no_pgp` resource is consider as sensitive and creating the following error\r\n```\r\nβ”‚ Expressions used in outputs can only refer to sensitive values if the\r\nβ”‚ sensitive attribute is true.\r\n```\r\n\r\nI have wrapped the outputs this resource(s) in the `nonsensitive` function, however I could not tested.\r\n**I need support in the testing before merging**\n\n---\n\nChoice A:\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -33,7 +33,7 @@ output \"this_iam_access_key_id\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.id,\n- aws_iam_access_key.this_no_pgp.*.id,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.id),\n [\"\"],\n ),\n 0\n@@ -42,7 +42,7 @@ output \"this_iam_access_key_id\" {\n \n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n- value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ value = element(concat(nonsensitive(aws_iam_access_key.this_no_pgp.*.secret), [\"\"]), 0)\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -60,7 +60,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.ses_smtp_password_v4,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4),\n [\"\"],\n ),\n 0\n@@ -72,7 +72,7 @@ output \"this_iam_access_key_status\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.status,\n- aws_iam_access_key.this_no_pgp.*.status,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.status),\n [\"\"],\n ),\n 0\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -33,7 +33,7 @@ output \"this_iam_access_key_id\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.id,\n- aws_iam_access_key.this_no_pgp.*.id,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.id),\n [\"\"],\n ),\n 0\n@@ -42,7 +42,7 @@ output \"this_iam_access_key_id\" {\n \n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n- value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ value = element(concat(nonsensitive(aws_iam_access_key.this_no_pgp.*.secret), [\"\"]), 0)\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -60,7 +60,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.ses_smtp_password_v4,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4),\n [\"\"],\n ),\n 0\n@@ -72,7 +72,7 @@ output \"this_iam_access_key_status\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.status,\n- aws_iam_access_key.this_no_pgp.*.status,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.status),\n [\"\"],\n ),\n 0\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid = flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -33,7 +33,7 @@ output \"this_iam_access_key_id\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.id,\n- aws_iam_access_key.this_no_pgp.*.id,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.id),\n [\"\"],\n ),\n 0\n@@ -42,7 +42,7 @@ output \"this_iam_access_key_id\" {\n \n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n- value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ value = element(concat(nonsensitive(aws_iam_access_key.this_no_pgp.*.secret), [\"\"]), 0)\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -60,7 +60,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.ses_smtp_password_v4,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4),\n [\"\"],\n ),\n 0\n@@ -72,7 +72,7 @@ output \"this_iam_access_key_status\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.status,\n- aws_iam_access_key.this_no_pgp.*.status,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.status),\n [\"\"],\n ),\n 0\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- role_sts_externalid flatten(list(var.role_sts_externalid))\n+ role_sts_externalid = flatten(tolist(var.role_sts_externalid))\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n---\nmodules/iam-user/outputs.tf\n@@ -33,7 +33,7 @@ output \"this_iam_access_key_id\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.id,\n- aws_iam_access_key.this_no_pgp.*.id,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.id),\n [\"\"],\n ),\n 0\n@@ -42,7 +42,7 @@ output \"this_iam_access_key_id\" {\n \n output \"this_iam_access_key_secret\" {\n description = \"The access key secret\"\n- value = element(concat(aws_iam_access_key.this_no_pgp.*.secret, [\"\"]), 0)\n+ value = element(concat(nonsensitive(aws_iam_access_key.this_no_pgp.*.secret), [\"\"]), 0)\n }\n \n output \"this_iam_access_key_key_fingerprint\" {\n@@ -60,7 +60,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.ses_smtp_password_v4,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4),\n [\"\"],\n ),\n 0\n@@ -72,7 +72,7 @@ output \"this_iam_access_key_status\" {\n value = element(\n concat(\n aws_iam_access_key.this.*.status,\n- aws_iam_access_key.this_no_pgp.*.status,\n+ nonsensitive(aws_iam_access_key.this_no_pgp.*.status),\n [\"\"],\n ),\n 0\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 will support adding tags to an IAM policy.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nIt solves the issue of not being able to tag policies with the current module. In a high compliance/cost control environment this is necessary.\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\nNo the default value is an empty map.\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 tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Please describe in detail how you tested your changes. -->\r\nI have forked the repo, referenced it in a project and deployed tags against a policy.\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n```\r\nmodule \"generic_instance_policy\" {\r\n source = \"git@github.com:dogfish182/terraform-aws-iam.git//modules/iam-policy\"\r\n // version = \"~> 3.0\"\r\n name = \"generic-instance\"\r\n path = \"/\"\r\n description = \"permissions to do things\"\r\n policy = data.aws_iam_policy_document.generic_instance_policy.json\r\n tags = merge(var.organisational_tags, var.project_tags)\r\n}\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\n\n---\n\nChoice A:\nmodules/iam-policy/main.tf\n@@ -2,7 +2,6 @@ resource \"aws_iam_policy\" \"policy\" {\n name = var.name\n path = var.path\n description = var.description\n-\n policy = var.policy\n+ tags = var.tags\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to IAM policy resources\"\n+ type = map(string)\n+ default = {}\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-policy/main.tf\n@@ -2,7 +2,6 @@ resource \"aws_iam_policy\" \"policy\" {\n name = var.name\n path = var.path\n description = var.description\n-\n policy = var.policy\n+ tags = var.tags\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to IAM policy resources\"\n+ type = map(string)\n+ default = {}\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-policy/main.tf\n@@ policy +2,6 @@ resource \"aws_iam_policy\" \"policy\" {\n name = var.name\n path = var.path\n description = var.description\n-\n policy = var.policy\n+ tags = var.tags\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to IAM policy resources\"\n+ type = map(string)\n+ default = {}\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-policy/main.tf\n@@ -2,7 +2,6 @@ resource \"aws_iam_policy\" \"policy\" {\n name = var.name\n path = var.path\n -22,3 = var.description\n-\n policy = var.policy\n+ tags = var.tags\n }\n-\n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to IAM policy resources\"\n+ type = map(string)\n+ default = {}\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 `tags` variable:\r\n\r\n`aws_iam_instance_profile` [released in TerraformAWS provider v3.34](https://github.com/hashicorp/terraform-provider-aws/blob/v3.34.0/CHANGELOG.md) on PR [#17962](https://github.com/hashicorp/terraform-provider-aws/pull/17962)\r\n`aws_iam_policy` [released in terraform-aws-provider v3.35](https://github.com/hashicorp/terraform-provider-aws/blob/v3.35.0/CHANGELOG.md) on PR [#18276](https://github.com/hashicorp/terraform-provider-aws/pull/18276)\r\n\r\n## Motivation and Context\r\nI need to tag all (or at least I would like that) resources provisioned, Its help me with cost management and organization\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\n\n---\n\nChoice A:\nexamples/iam-policy/main.tf\n@@ -34,6 +34,10 @@ module \"iam_policy\" {\n ]\n }\n EOF\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using heredoc policy\"\n+ }\n }\n \n module \"iam_policy_from_data_source\" {\n@@ -44,4 +48,8 @@ module \"iam_policy_from_data_source\" {\n description = \"My example policy\"\n \n policy = data.aws_iam_policy_document.bucket_policy.json\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using example from data source\"\n+ }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -10,13 +10,13 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.34 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.34 |\n \n ## Modules\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -108,4 +108,6 @@ resource \"aws_iam_instance_profile\" \"this\" {\n name = var.role_name\n path = var.role_path\n role = aws_iam_role.this[0].name\n+\n+ tags = var.tags\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.34\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -37,6 +37,7 @@ No modules.\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_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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -10,6 +10,8 @@ resource \"aws_iam_policy\" \"this\" {\n name = var.name\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_group\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,3 +15,9 @@ variable \"group_users\" {\n default = []\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n---\nmodules/iam-group-with-policies/README.md\n@@ -47,6 +47,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-policies/main.tf\n@@ -48,6 +48,8 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n@@ -56,5 +58,7 @@ resource \"aws_iam_policy\" \"custom\" {\n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n description = lookup(var.custom_group_policies[count.index], \"description\", null)\n+\n+ of tags = var.tags\n }\n \n---\nmodules/iam-group-with-policies/variables.tf\n@@ -46,3 +46,8 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/README.md\n@@ -8,13 +8,13 @@ Creates IAM policy.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.35 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.35 |\n \n ## Modules\n \n@@ -34,6 +34,7 @@ No modules.\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | The path of the policy in IAM (tpl file) | `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 \n---\nmodules/iam-policy/main.tf\n@@ -4,5 +4,7 @@ resource \"aws_iam_policy\" \"policy\" {\n description = var.description\n \n policy = var.policy\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.35\"\n }\n }\n---\nmodules/iam-user/main.tf\n@@ -5,7 +5,8 @@ resource \"aws_iam_user\" \"this\" {\n path = var.path\n force_destroy = var.force_destroy\n permissions_boundary = var.permissions_boundary\n- tags = var.tags\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_user_login_profile\" \"this\" {\n---\n\n\n---\n\nChoice B:\nexamples/iam-policy/main.tf\n@@ -34,6 +34,10 @@ module \"iam_policy\" {\n ]\n }\n EOF\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using heredoc policy\"\n+ }\n }\n \n module \"iam_policy_from_data_source\" {\n@@ -44,4 +48,8 @@ module \"iam_policy_from_data_source\" {\n description = \"My example policy\"\n \n policy = data.aws_iam_policy_document.bucket_policy.json\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using example from data source\"\n+ }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -10,13 +10,13 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.34 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.34 |\n \n ## Modules\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -108,4 +108,6 @@ resource \"aws_iam_instance_profile\" \"this\" {\n name = var.role_name\n path = var.role_path\n role = aws_iam_role.this[0].name\n+\n+ tags = var.tags\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.34\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -37,6 +37,7 @@ No modules.\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_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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -10,6 +10,8 @@ resource \"aws_iam_policy\" \"this\" {\n name = var.name\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_group\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,3 +15,9 @@ variable \"group_users\" {\n default = []\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n---\nmodules/iam-group-with-policies/README.md\n@@ -47,6 +47,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-policies/main.tf\n@@ -48,6 +48,8 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n@@ -56,5 +58,7 @@ resource \"aws_iam_policy\" \"custom\" {\n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n description = lookup(var.custom_group_policies[count.index], \"description\", null)\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-group-with-policies/variables.tf\n@@ -46,3 +46,8 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/README.md\n@@ -8,13 +8,13 @@ Creates IAM policy.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.35 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.35 |\n \n ## Modules\n \n@@ -34,6 +34,7 @@ No modules.\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | The path of the policy in IAM (tpl file) | `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 \n---\nmodules/iam-policy/main.tf\n@@ -4,5 +4,7 @@ resource \"aws_iam_policy\" \"policy\" {\n description = var.description\n \n policy = var.policy\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.35\"\n }\n }\n---\nmodules/iam-user/main.tf\n@@ -5,7 +5,8 @@ resource \"aws_iam_user\" \"this\" {\n path = var.path\n force_destroy = var.force_destroy\n permissions_boundary = var.permissions_boundary\n- tags = var.tags\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_user_login_profile\" \"this\" {\n---\n\n\n---\n\nChoice C:\nexamples/iam-policy/main.tf\n@@ -34,6 +34,10 @@ module \"iam_policy\" {\n ]\n }\n EOF\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using heredoc policy\"\n+ }\n }\n \n module \"iam_policy_from_data_source\" {\n@@ -44,4 +48,8 @@ module \"iam_policy_from_data_source\" {\n description = \"My example policy\"\n \n policy = data.aws_iam_policy_document.bucket_policy.json\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using example from data source\"\n+ }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -10,13 +10,13 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.34 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.34 |\n \n ## Modules\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -108,4 +108,6 @@ resource \"aws_iam_instance_profile\" \"this\" {\n name = var.role_name\n path = var.role_path\n role = aws_iam_role.this[0].name\n+\n+ tags = var.tags\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.34\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -37,6 +37,7 @@ No modules.\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_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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -10,6 +10,8 @@ resource \"aws_iam_policy\" \"this\" {\n name = var.name\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_group\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,3 +15,9 @@ variable \"group_users\" {\n default = []\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n---\nmodules/iam-group-with-policies/README.md\n@@ -47,6 +47,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-policies/main.tf\n@@ -48,6 +48,8 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n@@ -56,5 +58,7 @@ resource \"aws_iam_policy\" \"custom\" {\n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n description = lookup(var.custom_group_policies[count.index], \"description\", null)\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-group-with-policies/variables.tf\n@@ -46,3 +46,8 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/README.md\n@@ -8,13 +8,13 @@ Creates IAM policy.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.35 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.35 |\n \n ## Modules\n \n@@ -34,6 +34,7 @@ No modules.\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | The path of the policy in IAM (tpl file) | `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 \n---\nmodules/iam-policy/main.tf\n@@ -4,5 +4,7 @@ resource \"aws_iam_policy\" \"policy\" {\n description = var.description\n \n policy = var.policy\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ 2.23 = {}\n+}\n---\nmodules/iam-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.35\"\n }\n }\n---\nmodules/iam-user/main.tf\n@@ -5,7 +5,8 @@ resource \"aws_iam_user\" \"this\" {\n path = var.path\n force_destroy = var.force_destroy\n permissions_boundary = var.permissions_boundary\n- tags = var.tags\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_user_login_profile\" \"this\" {\n---\n\n\n---\n\nChoice D:\nexamples/iam-policy/main.tf\n@@ -34,6 +34,10 @@ module \"iam_policy\" {\n ]\n }\n EOF\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using heredoc policy\"\n+ }\n }\n \n module \"iam_policy_from_data_source\" {\n@@ -44,4 +48,8 @@ }\n \"iam_policy_from_data_source\" {\n description = \"My example policy\"\n \n policy = data.aws_iam_policy_document.bucket_policy.json\n+\n+ tags = {\n+ PolicyDescription = \"Policy created using example from data source\"\n+ }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -10,13 +10,13 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.34 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.34 |\n \n ## Modules\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -108,4 +108,6 @@ resource \"aws_iam_instance_profile\" \"this\" {\n name = var.role_name\n path = var.role_path\n role = aws_iam_role.this[0].name\n+\n+ tags = var.tags\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.34\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -37,6 +37,7 @@ No modules.\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_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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -10,6 +10,8 @@ resource \"aws_iam_policy\" \"this\" {\n name = var.name\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_group\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -15,3 +15,9 @@ variable \"group_users\" {\n default = []\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n---\nmodules/iam-group-with-policies/README.md\n@@ -47,6 +47,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n \n---\nmodules/iam-group-with-policies/main.tf\n@@ -48,6 +48,8 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n \n name_prefix = var.iam_self_management_policy_name_prefix\n policy = data.aws_iam_policy_document.iam_self_management.json\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n@@ -56,5 +58,7 @@ resource \"aws_iam_policy\" \"custom\" {\n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\n description = lookup(var.custom_group_policies[count.index], \"description\", null)\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-group-with-policies/variables.tf\n@@ -46,3 +46,8 @@ variable \"aws_account_id\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/README.md\n@@ -8,13 +8,13 @@ Creates IAM policy.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.23 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.35 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.35 |\n \n ## Modules\n \n@@ -34,6 +34,7 @@ No modules.\n | <a name=\"input_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `\"\"` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | The path of the policy in IAM (tpl file) | `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 \n---\nmodules/iam-policy/main.tf\n@@ -4,5 +4,7 @@ resource \"aws_iam_policy\" \"policy\" {\n description = var.description\n \n policy = var.policy\n+\n+ tags = var.tags\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -22,3 +22,8 @@ variable \"policy\" {\n default = \"\"\n }\n \n+variable \"tags\" {\n+ description = \"A map of tags to add to all resources.\"\n+ type = map(string)\n+ default = {}\n+}\n---\nmodules/iam-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 3.35\"\n }\n }\n---\nmodules/iam-user/main.tf\n@@ -5,7 +5,8 @@ resource \"aws_iam_user\" \"this\" {\n path = var.path\n force_destroy = var.force_destroy\n permissions_boundary = var.permissions_boundary\n- tags = var.tags\n+\n+ tags = var.tags\n }\n \n resource \"aws_iam_user_login_profile\" \"this\" {\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\nAdds a new output (`iam role unique-id`) to module `iam-assumable-role`\r\n\r\n## Motivation and Context\r\n\r\nWe are using HashiCorp Vault version 1.2 and at this version, the only metadata we have to craft policies is the IAM Role Unique ID.\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 these changes using one or more of the provided `examples/*` projects\r\n\r\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -7,30 +7,30 @@ on:\n - master\n \n jobs:\n-# Min Terraform version(s)\n+ # Min Terraform version(s)\n getDirectories:\n- name: Get root directories\n- runs-on: ubuntu-latest\n- steps:\n- - name: Checkout\n- uses: actions/checkout@v2\n- - name: Install Python\n- uses: actions/setup-python@v2\n- - name: Build matrix\n- id: matrix\n- run: |\n- DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n- echo \"::set-output name=directories::$DIRS\"\n- outputs:\n- directories: ${{ steps.matrix.outputs.directories }}\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n preCommitMinVersions:\n name: Min TF validate\n needs: getDirectories\n runs-on: ubuntu-latest\n name=\"output_this_iam_role_name\"></a> strategy:\n- matrix:\n- directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -59,7 +59,7 @@ jobs:\n pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n \n \n-# Max Terraform version\n+ # Max Terraform version\n getBaseVersion:\n name: Module max TF version\n runs-on: ubuntu-latest\n@@ -94,7 +94,7 @@ jobs:\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n- curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12.0-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12\\..+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n---\nmodules/iam-assumable-role/README.md\n@@ -75,4 +75,5 @@ No modules.\n | <a name=\"output_this_iam_role_arn\"></a> [this\\_iam\\_role\\_arn](#output\\_this\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_this_iam_role_name\"></a> [this\\_iam\\_role\\_name](#output\\_this\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_this_iam_role_path\"></a> [this\\_iam\\_role\\_path](#output\\_this\\_iam\\_role\\_path) | Path of IAM role |\n+| <a name=\"output_this_iam_role_unique_id\"></a> [this\\_iam\\_role\\_unique\\_id](#output\\_this\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -13,6 +13,11 @@ output \"this_iam_role_path\" {\n value = element(concat(aws_iam_role.this.*.path, [\"\"]), 0)\n }\n \n+output \"this_iam_role_unique_id\" {\n+ description = \"Unique ID of IAM role\"\n+ value = element(concat(aws_iam_role.this.*.unique_id, [\"\"]), 0)\n+}\n+\n output \"role_requires_mfa\" {\n description = \"Whether IAM role requires MFA\"\n value = var.role_requires_mfa\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -7,30 +7,30 @@ on:\n - master\n \n jobs:\n-# Min Terraform version(s)\n+ # Min Terraform version(s)\n getDirectories:\n- name: Get root directories\n- runs-on: ubuntu-latest\n- steps:\n- - name: Checkout\n- uses: actions/checkout@v2\n- - name: Install Python\n- uses: actions/setup-python@v2\n- - name: Build matrix\n- id: matrix\n- run: |\n- DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n- echo \"::set-output name=directories::$DIRS\"\n- outputs:\n- directories: ${{ steps.matrix.outputs.directories }}\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n preCommitMinVersions:\n name: Min TF validate\n needs: getDirectories\n runs-on: ubuntu-latest\n strategy:\n- matrix:\n- directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -59,7 +59,7 @@ jobs:\n pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n \n \n-# Max Terraform version\n+ # Max Terraform version\n getBaseVersion:\n name: Module max TF version\n runs-on: ubuntu-latest\n@@ -94,7 +94,7 @@ jobs:\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n- curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest grep -o -E \"https://.+?-v0.12.0-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12\\..+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n---\nmodules/iam-assumable-role/README.md\n@@ -75,4 +75,5 @@ No modules.\n | <a name=\"output_this_iam_role_arn\"></a> [this\\_iam\\_role\\_arn](#output\\_this\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_this_iam_role_name\"></a> [this\\_iam\\_role\\_name](#output\\_this\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_this_iam_role_path\"></a> [this\\_iam\\_role\\_path](#output\\_this\\_iam\\_role\\_path) | Path of IAM role |\n+| <a name=\"output_this_iam_role_unique_id\"></a> [this\\_iam\\_role\\_unique\\_id](#output\\_this\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -13,6 +13,11 @@ output \"this_iam_role_path\" {\n value = element(concat(aws_iam_role.this.*.path, [\"\"]), 0)\n }\n \n+output \"this_iam_role_unique_id\" {\n+ description = \"Unique ID of IAM role\"\n+ value = element(concat(aws_iam_role.this.*.unique_id, [\"\"]), 0)\n+}\n+\n output \"role_requires_mfa\" {\n description = \"Whether IAM role requires MFA\"\n value = var.role_requires_mfa\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -7,30 +7,30 @@ on:\n - master\n \n jobs:\n-# Min Terraform version(s)\n+ # Min Terraform version(s)\n getDirectories:\n- name: Get root directories\n- runs-on: ubuntu-latest\n- steps:\n- - name: Checkout\n- uses: actions/checkout@v2\n- - name: Install Python\n- uses: actions/setup-python@v2\n- - name: Build matrix\n- id: matrix\n- run: |\n- DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n- echo \"::set-output name=directories::$DIRS\"\n- outputs:\n- directories: ${{ steps.matrix.outputs.directories }}\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n preCommitMinVersions:\n name: Min TF validate\n needs: getDirectories\n runs-on: ubuntu-latest\n strategy:\n- matrix:\n- directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -59,7 +59,7 @@ jobs:\n pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n \n \n-# Max Terraform version\n+ # Max Terraform version\n getBaseVersion:\n name: Module max TF version\n runs-on: ubuntu-latest\n@@ -94,7 +94,7 @@ jobs:\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n- curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12.0-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12\\..+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n---\nmodules/iam-assumable-role/README.md\n@@ -75,4 +75,5 @@ No modules.\n | <a name=\"output_this_iam_role_arn\"></a> [this\\_iam\\_role\\_arn](#output\\_this\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_this_iam_role_name\"></a> [this\\_iam\\_role\\_name](#output\\_this\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_this_iam_role_path\"></a> [this\\_iam\\_role\\_path](#output\\_this\\_iam\\_role\\_path) | Path of IAM role |\n+| <a name=\"output_this_iam_role_unique_id\"></a> [this\\_iam\\_role\\_unique\\_id](#output\\_this\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -13,6 +13,11 @@ output \"this_iam_role_path\" {\n value = element(concat(aws_iam_role.this.*.path, [\"\"]), 0)\n }\n \n+output \"this_iam_role_unique_id\" {\n+ description = \"Unique ID of IAM role\"\n+ value = element(concat(aws_iam_role.this.*.unique_id, [\"\"]), 0)\n+}\n+\n output \"role_requires_mfa\" {\n description = \"Whether IAM role requires MFA\"\n value = var.role_requires_mfa\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -7,30 +7,30 @@ on:\n - master\n \n jobs:\n-# Min Terraform version(s)\n+ # Min Terraform version(s)\n getDirectories:\n- name: Get root directories\n- runs-on: ubuntu-latest\n- steps:\n- - name: Checkout\n- uses: actions/checkout@v2\n- - name: Install Python\n- uses: actions/setup-python@v2\n- - name: Build matrix\n- id: matrix\n- run: |\n- DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') value x in glob.glob('./**/versions.tf', recursive=True)]))\")\n- echo \"::set-output name=directories::$DIRS\"\n- outputs:\n- directories: ${{ steps.matrix.outputs.directories }}\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n preCommitMinVersions:\n name: Min TF validate\n needs: getDirectories\n runs-on: ubuntu-latest\n strategy:\n- matrix:\n- directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -59,7 +59,7 @@ jobs:\n pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n \n \n-# Max Terraform version\n+ # Max Terraform version\n getBaseVersion:\n name: Module max TF version\n runs-on: ubuntu-latest\n@@ -94,7 +94,7 @@ jobs:\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n- curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12.0-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-v0.12\\..+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n---\nmodules/iam-assumable-role/README.md\n@@ -75,4 +75,5 @@ No modules.\n | <a name=\"output_this_iam_role_arn\"></a> [this\\_iam\\_role\\_arn](#output\\_this\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_this_iam_role_name\"></a> [this\\_iam\\_role\\_name](#output\\_this\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_this_iam_role_path\"></a> [this\\_iam\\_role\\_path](#output\\_this\\_iam\\_role\\_path) | Path of IAM role |\n+| <a name=\"output_this_iam_role_unique_id\"></a> [this\\_iam\\_role\\_unique\\_id](#output\\_this\\_iam\\_role\\_unique\\_id) | Unique ID of IAM role |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -13,6 +13,11 @@ output \"this_iam_role_path\" {\n value = element(concat(aws_iam_role.this.*.path, [\"\"]), 0)\n }\n \n+output \"this_iam_role_unique_id\" {\n+ description = \"Unique ID of IAM role\"\n+ value = element(concat(aws_iam_role.this.*.unique_id, [\"\"]), 0)\n+}\n+\n output \"role_requires_mfa\" {\n description = \"Whether IAM role requires MFA\"\n value = var.role_requires_mfa\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\nThere are use cases when encryption is not possible and these are not handled properly right now.\r\n\r\n## Motivation and Context\r\nSometimes internal accounts are created and they never leave Terraform and encryption is not possible due to the lack of decryption functionality within Terraform.\r\n\r\n## Breaking Changes\r\nWhen not appropriate, Keybase commands will just be null, which could be extended further to check if a regular PGP key is used and not a Keybase one.\n\n---\n\nChoice A:\nmodules/iam-user/outputs.tf\n@@ -1,3 +1,8 @@\n+locals {\n+ has_encrypted_password = length(compact(aws_iam_user_login_profile.this.*.encrypted_password)) > 0\n+ has_encrypted_secret = length(compact(aws_iam_access_key.this.*.encrypted_secret)) > 0\n+}\n+\n output \"this_iam_user_name\" {\n description = \"The user's name\"\n value = element(concat(aws_iam_user.this.*.name, [\"\"]), 0)\n@@ -15,18 +20,12 @@ output \"this_iam_user_unique_id\" {\n \n output \"this_iam_user_login_profile_key_fingerprint\" {\n description = \"The fingerprint of the PGP key used to encrypt the password\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]), 0)\n }\n \n output \"this_iam_user_login_profile_encrypted_password\" {\n description = \"The encrypted password, base64 encoded\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)\n }\n \n output \"this_iam_access_key_id\" {\n@@ -37,7 +36,7 @@ output \"this_iam_access_key_id\" {\n aws_iam_access_key.this_no_pgp.*.id,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -64,7 +63,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -76,7 +75,7 @@ output \"this_iam_access_key_status\" {\n aws_iam_access_key.this_no_pgp.*.status,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -87,42 +86,36 @@ output \"pgp_key\" {\n \n output \"keybase_password_decrypt_command\" {\n description = \"Decrypt user password command\"\n- value = <<EOF\n-echo \"${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\" | base64 --decode | keybase pgp decrypt\n+ value = !local.has_encrypted_password ? null : <<EOF\n+echo \"${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_password_pgp_message\" {\n description = \"Encrypted password\"\n- value = <<EOF\n+ value = !local.has_encrypted_password ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n \n-${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\n+${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\n -----END PGP MESSAGE-----\n EOF\n \n }\n \n output \"keybase_secret_key_decrypt_command\" {\n description = \"Decrypt access secret key command\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n echo \"${element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n@@ -135,14 +128,10 @@ EOF\n \n output \"this_iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n- value = element(\n- concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]), 0)\n }\n \n output \"this_iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = element(concat(aws_iam_user_ssh_key.this.*.fingerprint, [\"\"]), 0)\n }\n-\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/outputs.tf\n@@ -1,3 +1,8 @@\n+locals {\n+ has_encrypted_password = length(compact(aws_iam_user_login_profile.this.*.encrypted_password)) > 0\n+ has_encrypted_secret = length(compact(aws_iam_access_key.this.*.encrypted_secret)) > 0\n+}\n+\n output \"this_iam_user_name\" {\n description = \"The user's name\"\n value = element(concat(aws_iam_user.this.*.name, [\"\"]), 0)\n@@ -15,18 +20,12 @@ output \"this_iam_user_unique_id\" {\n \n output \"this_iam_user_login_profile_key_fingerprint\" {\n description = \"The fingerprint of the PGP key used to encrypt the password\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]), 0)\n }\n \n output \"this_iam_user_login_profile_encrypted_password\" {\n description = \"The encrypted password, base64 encoded\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)\n }\n \n output \"this_iam_access_key_id\" {\n@@ -37,7 +36,7 @@ output \"this_iam_access_key_id\" {\n aws_iam_access_key.this_no_pgp.*.id,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -64,7 +63,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -76,7 +75,7 @@ output \"this_iam_access_key_status\" {\n aws_iam_access_key.this_no_pgp.*.status,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -87,42 +86,36 @@ output \"pgp_key\" {\n \n output \"keybase_password_decrypt_command\" {\n description = \"Decrypt user password command\"\n- value = <<EOF\n-echo \"${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\" | base64 --decode | keybase pgp decrypt\n+ value = !local.has_encrypted_password ? null : <<EOF\n+echo \"${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_password_pgp_message\" {\n description = \"Encrypted password\"\n- value = <<EOF\n+ value = !local.has_encrypted_password ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n \n-${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\n+${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\n -----END PGP MESSAGE-----\n EOF\n \n }\n \n output \"keybase_secret_key_decrypt_command\" {\n description = \"Decrypt access secret key command\"\n- value = <<EOF\n+ value value = !local.has_encrypted_secret ? null : <<EOF\n echo \"${element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n@@ -135,14 +128,10 @@ EOF\n \n output \"this_iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n- value = element(\n- concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]), 0)\n }\n \n output \"this_iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = element(concat(aws_iam_user_ssh_key.this.*.fingerprint, [\"\"]), 0)\n }\n-\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/outputs.tf\n@@ -1,3 +1,8 @@\n+locals {\n+ has_encrypted_password = length(compact(aws_iam_user_login_profile.this.*.encrypted_password)) > 0\n+ has_encrypted_secret = length(compact(aws_iam_access_key.this.*.encrypted_secret)) > 0\n+}\n+\n output \"this_iam_user_name\" {\n description = \"The user's name\"\n value = element(concat(aws_iam_user.this.*.name, [\"\"]), 0)\n@@ -15,18 +20,12 @@ output \"this_iam_user_unique_id\" {\n \n output \"this_iam_user_login_profile_key_fingerprint\" {\n description = \"The fingerprint of the PGP key used to encrypt the password\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]), 0)\n }\n \n output \"this_iam_user_login_profile_encrypted_password\" {\n description = \"The encrypted password, base64 encoded\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)\n }\n \n output \"this_iam_access_key_id\" {\n@@ -37,7 +36,7 @@ output \"this_iam_access_key_id\" {\n aws_iam_access_key.this_no_pgp.*.id,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -64,7 +63,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -76,7 +75,7 @@ output \"this_iam_access_key_status\" {\n aws_iam_access_key.this_no_pgp.*.status,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -87,42 +86,36 @@ output \"pgp_key\" {\n \n output \"keybase_password_decrypt_command\" {\n )\n+ description = \"Decrypt user password command\"\n- value = <<EOF\n-echo \"${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\" | base64 --decode | keybase pgp decrypt\n+ value = !local.has_encrypted_password ? null : <<EOF\n+echo \"${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_password_pgp_message\" {\n description = \"Encrypted password\"\n- value = <<EOF\n+ value = !local.has_encrypted_password ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n \n-${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\n+${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\n -----END PGP MESSAGE-----\n EOF\n \n }\n \n output \"keybase_secret_key_decrypt_command\" {\n description = \"Decrypt access secret key command\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n echo \"${element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n@@ -135,14 +128,10 @@ EOF\n \n output \"this_iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n- value = element(\n- concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]), 0)\n }\n \n output \"this_iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = element(concat(aws_iam_user_ssh_key.this.*.fingerprint, [\"\"]), 0)\n }\n-\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/outputs.tf\n@@ -1,3 +1,8 @@\n+locals {\n+ has_encrypted_password = length(compact(aws_iam_user_login_profile.this.*.encrypted_password)) > 0\n+ has_encrypted_secret = length(compact(aws_iam_access_key.this.*.encrypted_secret)) > 0\n+}\n+\n output \"this_iam_user_name\" {\n description = \"The user's name\"\n value = element(concat(aws_iam_user.this.*.name, [\"\"]), 0)\n@@ -15,18 +20,12 @@ output \"this_iam_user_unique_id\" {\n \n output \"this_iam_user_login_profile_key_fingerprint\" {\n description = \"The fingerprint of the PGP key used to encrypt the password\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.key_fingerprint, [\"\"]),\n- 0,\n- )\n+ value = \"this_iam_access_key_status\" [\"\"]), 0)\n }\n \n output \"this_iam_user_login_profile_encrypted_password\" {\n description = \"The encrypted password, base64 encoded\"\n- value = element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)\n }\n \n output \"this_iam_access_key_id\" {\n@@ -37,7 +36,7 @@ output \"this_iam_access_key_id\" {\n aws_iam_access_key.this_no_pgp.*.id,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -64,7 +63,7 @@ output \"this_iam_access_key_ses_smtp_password_v4\" {\n aws_iam_access_key.this_no_pgp.*.ses_smtp_password_v4,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -76,7 +75,7 @@ output \"this_iam_access_key_status\" {\n aws_iam_access_key.this_no_pgp.*.status,\n [\"\"],\n ),\n- 0,\n+ 0\n )\n }\n \n@@ -87,42 +86,36 @@ output \"pgp_key\" {\n \n output \"keybase_password_decrypt_command\" {\n description = \"Decrypt user password command\"\n- value = <<EOF\n-echo \"${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\" | base64 --decode | keybase pgp decrypt\n+ value = !local.has_encrypted_password ? null : <<EOF\n+echo \"${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_password_pgp_message\" {\n description = \"Encrypted password\"\n- value = <<EOF\n+ value = !local.has_encrypted_password ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n \n-${element(\n- concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]),\n- 0,\n-)}\n+${element(concat(aws_iam_user_login_profile.this.*.encrypted_password, [\"\"]), 0)}\n -----END PGP MESSAGE-----\n EOF\n \n }\n \n output \"keybase_secret_key_decrypt_command\" {\n description = \"Decrypt access secret key command\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n echo \"${element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n- value = <<EOF\n+ value = !local.has_encrypted_secret ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n@@ -135,14 +128,10 @@ EOF\n \n output \"this_iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n- value = element(\n- concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]),\n- 0,\n- )\n+ value = element(concat(aws_iam_user_ssh_key.this.*.ssh_public_key_id, [\"\"]), 0)\n }\n \n output \"this_iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = element(concat(aws_iam_user_ssh_key.this.*.fingerprint, [\"\"]), 0)\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<!--- Describe your changes in detail -->\r\n\r\nAllows more than one STS External ID to be provided to an assumable role.\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\nWe need to pass multiple External IDs allowing one role for multiple external ids.\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\nNo\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\r\nI have added the `role_sts_external_ids` field to the `iam-assumable-role` example.\r\n\r\n### Using a string\r\n```\r\n # module.iam_assumable_role_custom.aws_iam_role.this[0] will be created\r\n + resource \"aws_iam_role\" \"this\" {\r\n + arn = (known after apply)\r\n + assume_role_policy = jsonencode(\r\n {\r\n + Statement = [\r\n + {\r\n + Action = \"sts:AssumeRole\"\r\n + Condition = {\r\n + StringEquals = {\r\n + sts:ExternalId = [\r\n + \"some-id-goes-here\",\r\n ]\r\n }\r\n }\r\n + Effect = \"Allow\"\r\n + Principal = {\r\n + AWS = \"arn:aws:iam::307990089504:root\"\r\n + Service = \"codedeploy.amazonaws.com\"\r\n }\r\n + Sid = \"\"\r\n },\r\n ]\r\n + Version = \"2012-10-17\"\r\n }\r\n )\r\n + create_date = (known after apply)\r\n + force_detach_policies = false\r\n + id = (known after apply)\r\n + managed_policy_arns = (known after apply)\r\n + max_session_duration = 3600\r\n + name = \"custom\"\r\n + path = \"/\"\r\n + unique_id = (known after apply)\r\n\r\n + inline_policy {\r\n + name = (known after apply)\r\n + policy = (known after apply)\r\n }\r\n }\r\n```\r\n\r\n### Using a list(string)\r\n```\r\n # module.iam_assumable_role_sts.aws_iam_role.this[0] will be created\r\n + resource \"aws_iam_role\" \"this\" {\r\n + arn = (known after apply)\r\n + assume_role_policy = jsonencode(\r\n {\r\n + Statement = [\r\n + {\r\n + Action = \"sts:AssumeRole\"\r\n + Condition = {\r\n + StringEquals = {\r\n + sts:ExternalId = [\r\n + \"some-id-goes-here\",\r\n + \"another-id-goes-here\",\r\n ]\r\n }\r\n }\r\n + Effect = \"Allow\"\r\n + Principal = {\r\n + AWS = \"arn:aws:iam::307990089504:root\"\r\n + Service = \"codedeploy.amazonaws.com\"\r\n }\r\n + Sid = \"\"\r\n },\r\n ]\r\n + Version = \"2012-10-17\"\r\n }\r\n )\r\n + create_date = (known after apply)\r\n + force_detach_policies = false\r\n + id = (known after apply)\r\n + managed_policy_arns = (known after apply)\r\n + max_session_duration = 3600\r\n + name = \"custom_sts\"\r\n + path = \"/\"\r\n + unique_id = (known after apply)\r\n\r\n + inline_policy {\r\n + name = (known after apply)\r\n + policy = (known after apply)\r\n }\r\n }\r\n```\n\n---\n\nChoice A:\nexamples/iam-assumable-role/README.md\n@@ -34,6 +34,7 @@ No provider.\n |------|--------|---------|\n | iam_assumable_role_admin | ../../modules/iam-assumable-role | |\n | iam_assumable_role_custom | ../../modules/iam-assumable-role | |\n+| iam_assumable_role_sts | ../../modules/iam-assumable-role | |\n | iam_policy | ../../modules/iam-policy | |\n \n ## Resources\n---\nexamples/iam-assumable-role/main.tf\n@@ -58,6 +58,38 @@ module \"iam_assumable_role_custom\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+####################################################\n+# IAM assumable role with multiple sts external ids\n+####################################################\n+module \"iam_assumable_role_sts\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_services = [\n+ \"codedeploy.amazonaws.com\"\n+ ]\n+\n+ create_role = true\n+\n+ role_name = \"custom_sts\"\n+ role_requires_mfa = false\n+\n+ role_sts_externalid = [\n+ \"some-id-goes-here\",\n+ \"another-id-goes-here\",\n+ ]\n+\n+ custom_role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n+ ]\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -53,7 +53,7 @@ No Modules.\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n-| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,3 +1,7 @@\n+locals {\n+ role_sts_externalid = flatten(list(var.role_sts_externalid))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n effect = \"Allow\"\n@@ -15,11 +19,11 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n dynamic \"condition\" {\n- for_each = var.role_sts_externalid != null ? [true] : []\n+ for_each = length(local.role_sts_externalid) != 0 ? [true] : []\n content {\n test = \"StringEquals\"\n variable = \"sts:ExternalId\"\n- values = [var.role_sts_externalid]\n+ values = local.role_sts_externalid\n }\n }\n }\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -37,4 +37,3 @@ output \"role_sts_externalid\" {\n description = \"STS ExternalId condition value to use with a role\"\n value = var.role_sts_externalid\n }\n-\n---\nmodules/iam-assumable-role/variables.tf\n@@ -132,8 +132,7 @@ variable \"role_description\" {\n }\n \n variable \"role_sts_externalid\" {\n- description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n- type = string\n- default = null\n+ description = \"STS ExternalId condition values to use with a role (when MFA is not required)\"\n+ type = any\n+ default = []\n }\n-\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role/README.md\n@@ -34,6 +34,7 @@ No provider.\n |------|--------|---------|\n | iam_assumable_role_admin | ../../modules/iam-assumable-role | |\n | iam_assumable_role_custom | ../../modules/iam-assumable-role | |\n+| iam_assumable_role_sts | ../../modules/iam-assumable-role | |\n | iam_policy | ../../modules/iam-policy | |\n \n ## Resources\n---\nexamples/iam-assumable-role/main.tf\n@@ -58,6 +58,38 @@ module \"iam_assumable_role_custom\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+####################################################\n+# IAM assumable role with multiple sts external ids\n+####################################################\n+module \"iam_assumable_role_sts\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_services = [\n+ \"codedeploy.amazonaws.com\"\n+ ]\n+\n+ create_role = true\n+\n+ role_name = \"custom_sts\"\n+ role_requires_mfa = false\n+\n+ role_sts_externalid = [\n+ \"some-id-goes-here\",\n+ \"another-id-goes-here\",\n+ ]\n+\n+ custom_role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n+ ]\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -53,7 +53,7 @@ No Modules.\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` var.role_sts_externalid `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n-| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,3 +1,7 @@\n+locals {\n+ role_sts_externalid = flatten(list(var.role_sts_externalid))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n effect = \"Allow\"\n@@ -15,11 +19,11 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n dynamic \"condition\" {\n- for_each = var.role_sts_externalid != null ? [true] : []\n+ for_each = length(local.role_sts_externalid) != 0 ? [true] : []\n content {\n test = \"StringEquals\"\n variable = \"sts:ExternalId\"\n- values = [var.role_sts_externalid]\n+ values = local.role_sts_externalid\n }\n }\n }\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -37,4 +37,3 @@ output \"role_sts_externalid\" {\n description = \"STS ExternalId condition value to use with a role\"\n value = var.role_sts_externalid\n }\n-\n---\nmodules/iam-assumable-role/variables.tf\n@@ -132,8 +132,7 @@ variable \"role_description\" {\n }\n \n variable \"role_sts_externalid\" {\n- description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n- type = string\n- default = null\n+ description = \"STS ExternalId condition values to use with a role (when MFA is not required)\"\n+ type = any\n+ default = []\n }\n-\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role/README.md\n@@ -34,6 +34,7 @@ No provider.\n |------|--------|---------|\n | iam_assumable_role_admin | ../../modules/iam-assumable-role | |\n | iam_assumable_role_custom | ../../modules/iam-assumable-role | |\n+| iam_assumable_role_sts | ../../modules/iam-assumable-role | |\n | iam_policy | ../../modules/iam-policy | |\n \n ## Resources\n---\nexamples/iam-assumable-role/main.tf\n@@ -58,6 +58,38 @@ module \"iam_assumable_role_custom\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+####################################################\n+# IAM assumable role with multiple sts external ids\n+####################################################\n+module \"iam_assumable_role_sts\" = source = \"../../modules/iam-assumable-role\"\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_services = [\n+ \"codedeploy.amazonaws.com\"\n+ ]\n+\n+ create_role = true\n+\n+ role_name = \"custom_sts\"\n+ role_requires_mfa = false\n+\n+ role_sts_externalid = [\n+ \"some-id-goes-here\",\n+ \"another-id-goes-here\",\n+ ]\n+\n+ custom_role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n+ ]\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -53,7 +53,7 @@ No Modules.\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n-| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,3 +1,7 @@\n+locals {\n+ role_sts_externalid = flatten(list(var.role_sts_externalid))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n effect = \"Allow\"\n@@ -15,11 +19,11 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n dynamic \"condition\" {\n- for_each = var.role_sts_externalid != null ? [true] : []\n+ for_each = length(local.role_sts_externalid) != 0 ? [true] : []\n content {\n test = \"StringEquals\"\n variable = \"sts:ExternalId\"\n- values = [var.role_sts_externalid]\n+ values = local.role_sts_externalid\n }\n }\n }\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -37,4 +37,3 @@ output \"role_sts_externalid\" {\n description = \"STS ExternalId condition value to use with a role\"\n value = var.role_sts_externalid\n }\n-\n---\nmodules/iam-assumable-role/variables.tf\n@@ -132,8 +132,7 @@ variable \"role_description\" {\n }\n \n variable \"role_sts_externalid\" {\n- description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n- type = string\n- default = null\n+ description = \"STS ExternalId condition values to use with a role (when MFA is not required)\"\n+ type = any\n+ default = []\n }\n-\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role/README.md\n@@ -34,6 +34,7 @@ No provider.\n |------|--------|---------|\n | iam_assumable_role_admin | ../../modules/iam-assumable-role | |\n | iam_assumable_role_custom | ../../modules/iam-assumable-role | |\n+| iam_assumable_role_sts | ../../modules/iam-assumable-role | |\n | iam_policy | ../../modules/iam-policy | |\n \n ## Resources\n---\nexamples/iam-assumable-role/main.tf\n@@ -58,6 +58,38 @@ module \"iam_assumable_role_custom\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+####################################################\n+# IAM assumable role with multiple sts external ids\n+####################################################\n+module \"iam_assumable_role_sts\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ trusted_role_arns = [\n+ \"arn:aws:iam::307990089504:root\",\n+ ]\n+\n+ trusted_role_services = [\n+ \"codedeploy.amazonaws.com\"\n+ ]\n+\n+ create_role = true\n+\n+ role_name = \"custom_sts\"\n+ role_requires_mfa = false\n+\n+ role_sts_externalid = [\n+ \"some-id-goes-here\",\n+ \"another-id-goes-here\",\n+ ]\n+\n+ custom_role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n+ \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n+ ]\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -53,7 +53,7 @@ No Modules.\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n-| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -1,3 +1,7 @@\n+locals {\n+ role_sts_externalid = flatten(list(var.role_sts_externalid))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n effect = \"Allow\"\n@@ -15,11 +19,11 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n dynamic \"condition\" {\n- for_each = var.role_sts_externalid != null ? [true] : []\n+ for_each = length(local.role_sts_externalid) != 0 ? [true] : []\n content {\n test = \"StringEquals\"\n variable = \"sts:ExternalId\"\n- values = [var.role_sts_externalid]\n+ values = local.role_sts_externalid\n }\n }\n }\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -37,4 +37,3 @@ output \"role_sts_externalid\" {\n description = \"STS ExternalId condition value to use with a role\"\n value = var.role_sts_externalid\n }\n-\n---\nmodules/iam-assumable-role/variables.tf\n@@ -132,8 +132,7 @@ variable \"role_description\" {\n }\n \n variable \"role_sts_externalid\" {\n- description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n- type = string\n- default = null\n+ description = \"STS ExternalId condition values to use with a role (when MFA is not required)\"\n+ type any\n+ default = []\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- update ci-cd workflow to allow for pulling min version from each directory\r\n\r\n## Motivation and Context\r\n- update to workflow to allow modules/examples use different min terraform versions\r\n\r\n## Breaking Changes\r\n- no\r\n\r\n## How Has This Been Tested?\r\n- ci-cd static checks\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install actions/setup-python@v2\n-\n uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/terraform-min-max@v1.0.1\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/terraform-min-max@v1.0.1\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/terraform-min-max@v1.0.1\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/terraform-min-max@v1.0.1\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\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 ci-cd workflow for pre-commit checks\r\n\r\n## Motivation and Context\r\n- provide static checks for pull requests\r\n\r\n## Breaking Changes\r\n- no\r\n\r\n## How Has This Been Tested?\r\n- copy of what is implemented in SQS module repository\r\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ tflint - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" if: terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate name: check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\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\nAdds the ability to manage the IAM group memberships on an IAM user using the `user_groups` variable within the `iam-user` module. This uses an existing [resource](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_group_membership) of the provider.\r\n\r\n## Motivation and Context\r\nThis has the ability to make initial IAM group memberships easier by combining the memberships with the user. This will be especially true for few well established groups that don't change much and a large user list that could make assigning IAM groups to IAM users cumbersome.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\nThis has been tested on a AWS test account. A plan can also be used to confirm that edits to IAM users previously created create just the memberships and don't affect the established user i.e. regenerating keys\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -50,6 +50,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | ssh\\_public\\_key | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | tags | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | either | Whether to upload a public ssh key to the IAM user | `bool` | `false` | no |\n+| user\\_groups | List of IAM groups to the IAM user should be a member of | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-user/main.tf\n@@ -38,3 +38,9 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n public_key = var.ssh_public_key\n }\n \n+resource \"aws_iam_user_group_membership\" \"this\" {\n+ count = length(var.user_groups) > 0 ? 1 : 0\n+\n+ user = aws_iam_user.this[0].name\n+ groups = var.user_groups\n+}\n---\nmodules/iam-user/variables.tf\n@@ -80,3 +80,10 @@ variable \"tags\" {\n type = map(string)\n default = {}\n }\n+\n+variable \"user_groups\" {\n+ description = \"List of IAM groups a IAM user should be a memeber of.\"\n+ type = list(string)\n+ default = []\n+}\n+\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -50,6 +50,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | ssh\\_public\\_key | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | tags | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | upload\\_iam\\_user\\_ssh\\_key | Whether to upload a public ssh key to the IAM user should `bool` | `false` | no |\n+| user\\_groups | List of IAM groups to the IAM user should be a member of | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-user/main.tf\n@@ -38,3 +38,9 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n public_key = var.ssh_public_key\n }\n \n+resource \"aws_iam_user_group_membership\" \"this\" {\n+ count = length(var.user_groups) > 0 ? 1 : 0\n+\n+ user = aws_iam_user.this[0].name\n+ groups = var.user_groups\n+}\n---\nmodules/iam-user/variables.tf\n@@ -80,3 +80,10 @@ variable \"tags\" {\n type = map(string)\n default = {}\n }\n+\n+variable \"user_groups\" {\n+ description = \"List of IAM groups a IAM user should be a memeber of.\"\n+ type = list(string)\n+ default = []\n+}\n+\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -50,6 +50,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | ssh\\_public\\_key | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | tags | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | upload\\_iam\\_user\\_ssh\\_key | Whether to upload a public ssh key to the IAM user | `bool` | `false` ssh-rsa no |\n+| user\\_groups | List of IAM groups to the IAM user should be a member of | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-user/main.tf\n@@ -38,3 +38,9 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n public_key = var.ssh_public_key\n }\n \n+resource \"aws_iam_user_group_membership\" \"this\" {\n+ count = length(var.user_groups) > 0 ? 1 : 0\n+\n+ user = aws_iam_user.this[0].name\n+ groups = var.user_groups\n+}\n---\nmodules/iam-user/variables.tf\n@@ -80,3 +80,10 @@ variable \"tags\" {\n type = map(string)\n default = {}\n }\n+\n+variable \"user_groups\" {\n+ description = \"List of IAM groups a IAM user should be a memeber of.\"\n+ type = list(string)\n+ default = []\n+}\n+\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -50,6 +50,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | ssh\\_public\\_key | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | tags | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | upload\\_iam\\_user\\_ssh\\_key | Whether to upload a public ssh key to the IAM user | `bool` | `false` | no |\n+| user\\_groups | List of IAM groups to the IAM user should be a member of | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-user/main.tf\n@@ -38,3 +38,9 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n public_key = var.ssh_public_key\n }\n \n+resource \"aws_iam_user_group_membership\" \"this\" {\n+ count = length(var.user_groups) > 0 ? 1 : 0\n+\n+ user = aws_iam_user.this[0].name\n+ groups = var.user_groups\n+}\n---\nmodules/iam-user/variables.tf\n@@ -80,3 +80,10 @@ variable \"tags\" {\n type = map(string)\n default = {}\n }\n+\n+variable \"user_groups\" {\n+ description = \"List of IAM groups a IAM user should be a memeber of.\"\n+ type = list(string)\n+ default = []\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\nExternal ID was supported without MFA, this support to work with MFA as well.\r\nThis is merely a copy/paste of the condition block from the IAM policy document above it.\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\nWe delegate the management of a subset of our services to a third-party company, we want to ensure that their users have MFA enable in their AWS account and assume the IAM role for the right customer (avoid confused deputy problem)\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<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\r\nYes, used `role_requires_mfa = true` and `sts_externalid = var.sts_externalid` together.\n\n---\n\nChoice A:\nmodules/iam-assumable-role/main.tf\n@@ -52,6 +52,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_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/main.tf\n@@ -52,6 +52,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_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/main.tf\n@@ -52,6 +52,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_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/main.tf\n@@ -52,6 +52,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_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ : = [var.role_sts_externalid]\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\nExport arn of created groups\r\n\r\n## Motivation and Context\r\nWe have multiple AWS accounts across our org. IAM user are kept centrally in one account, are put into groups and the groups get permission to `assumeRole` in other accounts. We need the group arn for the trustee relationship between the accounts.\r\n\r\n## How Has This Been Tested?\r\nI run Terraform from my branch and compared the result.\r\n\r\nBefore:\r\n```\r\nUnsupported attribute\r\n\r\n on outputs.tf line 5, in output \"groups\":\r\n 5: arn = module.iam-groups[name]. group_arn\r\n |----------------\r\n | module.iam-groups is object with 3 attributes\r\n\r\nThis object does not have an attribute named \"group_arn\".\r\n```\r\n\r\nAfter:\r\n```\r\nChanges to Outputs:\r\n + groups = [\r\n + {\r\n + arn = (known after apply)\r\n + name = \"data-services-admin\"\r\n },\r\n + {\r\n + arn = (known after apply)\r\n + name = \"data-services-developer\"\r\n },\r\n + {\r\n + arn = (known after apply)\r\n + name = \"zeppelin-admin\"\r\n },\r\n ]\r\n```\n\n---\n\nChoice A:\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -28,6 +28,7 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Description |\n |------|-------------|\n+| group\\_arn | IAM group arn |\n | group\\_name | IAM group name |\n | this\\_assumable\\_roles | List of ARNs of IAM roles which members of IAM group can assume |\n | this\\_group\\_users | List of IAM users in IAM group |\n---\nmodules/iam-group-with-assumable-roles-policy/outputs.tf\n@@ -18,3 +18,8 @@ output \"group_name\" {\n value = aws_iam_group.this.name\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = aws_iam_group.this.arn\n+}\n+\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -28,6 +28,7 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Description |\n |------|-------------|\n+| group\\_arn | IAM group arn |\n | group\\_name | IAM group name |\n | this\\_assumable\\_roles | List of ARNs of IAM roles which members of IAM group can assume |\n | this\\_group\\_users | List of IAM users in IAM group |\n---\nmodules/iam-group-with-assumable-roles-policy/outputs.tf\n@@ -18,3 +18,8 @@ output \"group_name\" {\n value = aws_iam_group.this.name\n }\n \n+output \"group_arn\" {\n+ are description = \"IAM group arn\"\n+ value = aws_iam_group.this.arn\n+}\n+\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -28,6 +28,7 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Description |\n |------|-------------|\n+| group\\_arn | IAM group arn |\n | group\\_name | IAM group name |\n | this\\_assumable\\_roles | List of ARNs of IAM roles which members of IAM group can assume |\n | this\\_group\\_users | List of IAM users in IAM group |\n---\nmodules/iam-group-with-assumable-roles-policy/outputs.tf\n@@ -18,3 +18,8 @@ output \"group_name\" {\n group value = aws_iam_group.this.name\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = aws_iam_group.this.arn\n+}\n+\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -28,6 +28,7 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Description |\n |------|-------------|\n+| group\\_arn | IAM group arn |\n | group\\_name | IAM group name |\n | this\\_assumable\\_roles | List of ARNs of IAM roles which members of IAM group can assume |\n | this\\_group\\_users | List of IAM users in IAM group |\n---\nmodules/iam-group-with-assumable-roles-policy/outputs.tf\n@@ -18,3 +18,8 @@ output \"group_name\" {\n value = aws_iam_group.this.name\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = aws_iam_group.this.arn\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<!--- Describe your changes in detail -->\r\n\r\nAdds a `create` flag to the iam-policy module allowing calling modules to exclude a policy's creation.\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\nSome of our modules use \"feature flags\" to determine whether items are created or not. The other iam modules have create flags we can make use of; however, the policy module does not.\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 will not necessarily break compatibility; however, it will cause a new change to appear on the next plan. The `aws_iam_policy.policy` has now moved to `aws_iam_policy.policy[0]`. As such, one can avoid a change in the plan by using the terraform state mv functionality. That is, assuming the target path to the iam_policy is on the root and the module is called `my_iam_policy`:\r\n\r\n```bash\r\nterraform state mv module.my_iam_policy.aws_iam_policy.policy 'module.my_iam_policy.aws_iam_policy.policy[0]'\r\n```\r\n\r\nIt might be better to consider this a breaking change as it will cause a change to the plan.\r\n\r\n## How Has This Been Tested?\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\r\nHoping over to the iam-policy examples, setting `create = false` on both examples, and running a terraform plan results in a blank plan.\r\n\r\n```\r\nRefreshing Terraform state in-memory prior to plan...\r\nThe refreshed state will be used to calculate this plan, but will not be\r\npersisted to local or remote state storage.\r\n\r\ndata.aws_iam_policy_document.bucket_policy: Refreshing state...\r\n\r\n------------------------------------------------------------------------\r\n\r\nNo changes. Infrastructure is up-to-date.\r\n\r\nThis means that Terraform did not detect any differences between your\r\nconfiguration and real physical resources that exist. As a result, no\r\nactions need to be performed.\r\n```\r\n\n\n---\n\nChoice A:\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No Modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| create | Whether to create a policy | `bool` | `true` | no |\n | description | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | name | The name of the policy | `string` | `\"\"` | no |\n | path | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,30 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create\" {\n+ description = \"Whether to create a policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type of string\n---\n\n\n---\n\nChoice B:\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No Modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| create | Whether to create a policy | `bool` | `true` | no |\n | description | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | name | The name of the policy | `string` | `\"\"` | no |\n | path | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ aws_iam_policy.policy.path\n+ +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,30 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create\" {\n+ description = \"Whether to create a policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n---\n\n\n---\n\nChoice C:\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No Modules.\n \n | Name | \"create\" | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| create | Whether to create a policy | `bool` | `true` | no |\n | description | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | name | The name of the policy | `string` | `\"\"` | no |\n | path | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,30 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create\" {\n+ description = \"Whether to create a policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n---\n\n\n---\n\nChoice D:\nmodules/iam-policy/README.md\n@@ -30,6 +30,7 @@ No Modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| create | Whether to create a policy | `bool` | `true` | no |\n | description | The description of the policy | `string` | `\"IAM Policy\"` | no |\n | name | The name of the policy | `string` | `\"\"` | no |\n | path | The path of the policy in IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-policy/main.tf\n@@ -1,4 +1,6 @@\n resource \"aws_iam_policy\" \"policy\" {\n+ count = var.create ? 1 : 0\n+\n name = var.name\n path = var.path\n description = var.description\n---\nmodules/iam-policy/outputs.tf\n@@ -1,30 +1,30 @@\n output \"id\" {\n description = \"The policy's ID\"\n- value = aws_iam_policy.policy.id\n+ value = element(concat(aws_iam_policy.policy.*.id, [\"\"]), 0)\n }\n \n output \"arn\" {\n description = \"The ARN assigned by AWS to this policy\"\n- value = aws_iam_policy.policy.arn\n+ value = element(concat(aws_iam_policy.policy.*.arn, [\"\"]), 0)\n }\n \n output \"description\" {\n description = \"The description of the policy\"\n- value = aws_iam_policy.policy.description\n+ value = element(concat(aws_iam_policy.policy.*.description, [\"\"]), 0)\n }\n \n output \"name\" {\n description = \"The name of the policy\"\n- value = aws_iam_policy.policy.name\n+ value = element(concat(aws_iam_policy.policy.*.name, [\"\"]), 0)\n }\n \n output \"path\" {\n description = \"The path of the policy in IAM\"\n- value = aws_iam_policy.policy.path\n+ value = element(concat(aws_iam_policy.policy.*.path, [\"\"]), 0)\n }\n \n output \"policy\" {\n description = \"The policy document\"\n- value = aws_iam_policy.policy.policy\n+ value = element(concat(aws_iam_policy.policy.*.policy, [\"\"]), 0)\n }\n \n---\nmodules/iam-policy/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"create\" {\n+ description = \"Whether to create a policy\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\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- Updating required_providers flag on multiple modules to support aws >= 2.25\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ @@\n = \">= 2.23\"\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \"0.13.5\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \"~> 0.12.6\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23\"\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- update pre-commit hook versions utilized\r\n- add GitHub action workflows for running static checks using pre-commit\r\n\r\n## Motivation and Context\r\n- introducing static check CI/CD workflow to project repositories\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- No material changes to source code\r\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,55 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\")\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.44.0\n+ rev: v1.45.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -21,6 +21,6 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.3.0\n+ rev: v3.4.0\n hooks:\n - id: check-merge-conflict\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,55 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\")\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.44.0\n+ rev: v1.45.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -21,6 +21,6 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.3.0\n+ rev: v3.4.0\n hooks:\n - id: check-merge-conflict\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,55 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\")\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.44.0\n+ rev: v1.45.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -21,6 +21,6 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.3.0\n+ rev: v3.4.0\n hooks:\n - id: check-merge-conflict\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,55 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/terraform-min-max@v1.0.1\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\")\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.44.0\n+ rev: v1.45.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -21,6 +21,6 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.3.0\n+ rev: v3.4.0\n hooks:\n - id: check-merge-conflict\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:\nCloses #116 \n\n---\n\nChoice A:\nexamples/iam-assumable-role/main.tf\n@@ -53,6 +53,33 @@ module \"iam_assumable_role_custom\" {\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n ]\n- number_of_custom_role_policy_arns = 2\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n+#########################################\n+# IAM policy\n+#########################################\n+module \"iam_policy\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ name = \"example\"\n+ path = \"/\"\n+ description = \"My example policy\"\n+\n+ policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": [\n+ \"ec2:Describe*\"\n+ ],\n+ \"Effect\": \"Allow\",\n+ \"Resource\": \"*\"\n+ }\n+ ]\n+}\n+EOF\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -32,7 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n-| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -79,7 +79,7 @@ variable \"custom_role_policy_arns\" {\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n # Pre-defined policies\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role/main.tf\n@@ -53,6 +53,33 @@ module \"iam_assumable_role_custom\" {\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n ]\n- number_of_custom_role_policy_arns = 2\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n+#########################################\n+# IAM | \"iam_policy\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ name = \"example\"\n+ path = \"/\"\n+ description = \"My example policy\"\n+\n+ policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": [\n+ \"ec2:Describe*\"\n+ ],\n+ \"Effect\": \"Allow\",\n+ \"Resource\": \"*\"\n+ }\n+ ]\n+}\n+EOF\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -32,7 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n-| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -79,7 +79,7 @@ variable \"custom_role_policy_arns\" {\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n # Pre-defined policies\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role/main.tf\n@@ -53,6 +53,33 @@ module \"iam_assumable_role_custom\" {\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n ]\n- number_of_custom_role_policy_arns = 2\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n+#########################################\n+# IAM policy\n+#########################################\n+module \"iam_policy\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ name = \"example\"\n+ path = \"/\"\n+ description = \"My example policy\"\n+\n+ policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": [\n+ \"ec2:Describe*\"\n+ ],\n+ \"Effect\": \"Allow\",\n+ \"Resource\": \"*\"\n+ }\n+ ]\n+}\n+EOF\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -32,7 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n-| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -79,7 +79,7 @@ variable \"custom_role_policy_arns\" {\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n # Pre-defined policies\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role/main.tf\n@@ -53,6 +53,33 @@ module \"iam_assumable_role_custom\" {\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n+ module.iam_policy.arn\n ]\n- number_of_custom_role_policy_arns = 2\n+ # number_of_custom_role_policy_arns = 3\n+}\n+\n+#########################################\n+# IAM policy\n+#########################################\n+module \"iam_policy\" {\n+ source = \"../../modules/iam-policy\"\n+\n+ name = \"example\"\n+ path = \"/\"\n+ description = \"My example policy\"\n+\n+ policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": [\n+ \"ec2:Describe*\"\n+ ],\n+ \"Effect\": \"Allow\",\n+ \"Resource\": \"*\"\n+ }\n+ ]\n+}\n+EOF\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -32,7 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n-| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? coalesce(var.number_of_custom_role_policy_arns, length(var.custom_role_policy_arns)) : 0\n \n role to = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -79,7 +79,7 @@ variable \"custom_role_policy_arns\" {\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n # Pre-defined policies\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\nChanged to automatically calculate `number_of_role_policy_arns` even if you omit this.\r\n\r\nAdded backward compatibility to #116\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\nBy default the `number_of_role_policy_arns` should be calculated automatically, but it can be also specified explicitly as 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\nProbably not\r\n\r\n## How Has This Been Tested?\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\nUse new example.\n\n---\n\nChoice A:\n.gitignore\n@@ -2,3 +2,4 @@\n terraform.tfstate\n *.tfstate*\n terraform.tfvars\n+.terraform.lock.hcl\n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,7 +22,6 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n- number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,7 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n-| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -9,6 +9,7 @@ locals {\n for url in local.urls :\n \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n ]\n+ number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n Number \"aws_caller_identity\" \"current\" {}\n@@ -68,7 +69,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -73,7 +73,7 @@ variable \"role_policy_arns\" {\n variable \"number_of_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n \n---\n\n\n---\n\nChoice B:\n.gitignore\n@@ -2,3 +2,4 @@\n terraform.tfstate\n *.tfstate*\n terraform.tfvars\n+.terraform.lock.hcl\n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,7 +22,6 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n- number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,7 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n-| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role OIDC | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -9,6 +9,7 @@ locals {\n for url in local.urls :\n \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n ]\n+ number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -68,7 +69,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -73,7 +73,7 @@ variable \"role_policy_arns\" {\n variable \"number_of_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n \n---\n\n\n---\n\nChoice C:\n.gitignore\n@@ -2,3 +2,4 @@\n terraform.tfstate\n *.tfstate*\n terraform.tfvars\n+.terraform.lock.hcl\n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,7 +22,6 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n- number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,7 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n-| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -9,6 +9,7 @@ locals {\n for url in local.urls :\n \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n ]\n+ number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -68,7 +69,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -73,7 +73,7 @@ variable \"role_policy_arns\" {\n variable \"number_of_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\n \n \n---\n\n\n---\n\nChoice D:\n.gitignore\n@@ -2,3 +2,4 @@\n terraform.tfstate\n *.tfstate*\n terraform.tfvars\n+.terraform.lock.hcl\n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,7 +22,6 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n- number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,7 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n-| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `0` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of IAM policies to attach to IAM role | `number` | `null` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -9,6 +9,7 @@ locals {\n for url in local.urls :\n \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n ]\n+ number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -68,7 role @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -73,7 +73,7 @@ variable \"role_policy_arns\" {\n variable \"number_of_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n- default = 0\n+ default = null\n }\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\nchanges the `number_of_policy_arns` from a var to a local to remove the need to set this value manually\r\n\r\nThis is for your consideration, feel free to toss.\r\n\r\n## Motivation and Context\r\nhaving to declare a count of policies is error prone for the end user as well as a breaking change in version from previous versions. By moving this value into a local, we can calculate the number with length() before the resource is created avoiding the potential race condition that caused the previous error to occur while maintaining legacy compatibility.\r\n\r\n## Breaking Changes\r\nThis reverts the latest change by allowing it to behave predicatbly and thus the extra variables unnessisary. We could leave the old var in place as a \"do nothing\", but I figured that would confuse things worse.\r\n\r\n## How Has This Been Tested?\r\nThis has been tested in a local fork, albiet at a small scale (only 6 resources across 3 clusters use this module currently).\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_role_policy_arns = length(var.role_policy_arns)\n+}\n\\ No resource at end of file\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,13 +70,6 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n-variable \"number_of_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = 0\n-}\n-\n-\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_custom_role_policy_arns = length(var.custom_role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,12 +76,6 @@ variable \"custom_role_policy_arns\" {\n default = []\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 = 0\n-}\n-\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_role_policy_arns = length(var.role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,13 +70,6 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n-variable \"number_of_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = 0\n-}\n-\n-\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_custom_role_policy_arns = length(var.custom_role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,12 +76,6 @@ variable \"custom_role_policy_arns\" {\n -70,13 default = []\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 = 0\n-}\n-\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_role_policy_arns = length(var.role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,13 +70,6 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n-variable \"number_of_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = 0\n-}\n-\n-\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_custom_role_policy_arns = length(var.custom_role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,12 +76,6 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n-variable role {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = 0\n-}\n-\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_role_policy_arns = length(var.role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,13 +70,6 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n-variable \"number_of_role_policy_arns\" {\n- description = \"Number of IAM policies to attach to IAM role\"\n- type = number\n- default = 0\n-}\n-\n-\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/locals.tf\n@@ -0,0 +1,3 @@\n+locals {\n+ number_of_custom_role_policy_arns = length(var.custom_role_policy_arns)\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n+ count = var.create_role ? local.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,12 +76,6 @@ variable \"custom_role_policy_arns\" {\n default = []\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 = 0\n-}\n-\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\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\nfix #114 \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 #114 \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<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\nThis PR was tested by extending the example provided with the module (examples/iam-assumable-role-with-oidc).\r\nAlso see **expected output** in #114\r\n\r\n#### Terraform plan output\r\n\r\n```\r\n # module.iam_assumable_role_admin.aws_iam_role.this[0] will be created\r\n + resource \"aws_iam_role\" \"this\" {\r\n + arn = (known after apply)\r\n + assume_role_policy = jsonencode(\r\n {\r\n + Statement = [\r\n + {\r\n + Action = \"sts:AssumeRoleWithWebIdentity\"\r\n + Condition = {\r\n + StringEquals = {\r\n + oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8:sub = [\r\n + \"system:serviceaccount:default:sa2\",\r\n + \"system:serviceaccount:default:sa1\",\r\n ]\r\n }\r\n }\r\n + Effect = \"Allow\"\r\n + Principal = {\r\n + Federated = \"arn:aws:iam::530488130478:oidc-provider/oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8\"\r\n }\r\n + Sid = \"\"\r\n },\r\n + {\r\n + Action = \"sts:AssumeRoleWithWebIdentity\"\r\n + Condition = {\r\n + StringEquals = {\r\n + oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8:sub = [\r\n + \"system:serviceaccount:default:sa2\",\r\n + \"system:serviceaccount:default:sa1\",\r\n ]\r\n }\r\n }\r\n + Effect = \"Allow\"\r\n + Principal = {\r\n + Federated = \"arn:aws:iam::530488130478:oidc-provider/oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\r\n }\r\n + Sid = \"\"\r\n },\r\n ]\r\n + Version = \"2012-10-17\"\r\n }\r\n )\r\n + create_date = (known after apply)\r\n + force_detach_policies = false\r\n + id = (known after apply)\r\n + max_session_duration = 3600\r\n + name = \"role-with-oidc\"\r\n + path = \"/\"\r\n + tags = {\r\n + \"Role\" = \"role-with-oidc\"\r\n }\r\n + unique_id = (known after apply)\r\n }\r\n```\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -5,10 +5,6 @@ locals {\n for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n- identifiers = [\n- for url in local.urls :\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n- ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n@@ -19,33 +15,38 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n- statement {\n- effect = \"Allow\"\n+ dynamic \"statement\" {\n+ for_each = local.urls\n \n- actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+ content {\n+ effect = \"Allow\"\n \n- principals {\n- type = \"Federated\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n \n- identifiers = local.identifiers\n- }\n+ principals {\n+ }\n type = \"Federated\"\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n- content {\n- test = \"StringEquals\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_fully_qualified_subjects\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_fully_qualified_subjects\n+ }\n }\n- }\n \n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n- content {\n- test = \"StringLike\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_subjects_with_wildcards\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_subjects_with_wildcards\n+ }\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -5,10 +5,6 @@ locals {\n for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n- identifiers = [\n- for url in local.urls :\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n- ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n@@ -19,33 +15,38 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n- statement {\n- effect = \"Allow\"\n+ dynamic \"statement\" {\n+ for_each = local.urls\n \n- actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+ content {\n+ effect = \"Allow\"\n \n- principals {\n- type = \"Federated\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n \n- identifiers = local.identifiers\n- }\n+ principals {\n+ type = \"Federated\"\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n- content {\n- test = \"StringEquals\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_fully_qualified_subjects\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_fully_qualified_subjects\n+ }\n }\n- }\n \n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n- content {\n- test = \"StringLike\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_subjects_with_wildcards\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_subjects_with_wildcards\n+ }\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -5,10 +5,6 @@ locals {\n for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n- identifiers = [\n- for url in local.urls :\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n- ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n@@ -19,33 +15,38 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n- statement {\n- effect = \"Allow\"\n+ dynamic \"statement\" {\n+ for_each = local.urls\n \n- actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+ content {\n+ effect = \"Allow\"\n \n- principals {\n- type = \"Federated\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n \n- identifiers = local.identifiers\n- }\n+ principals {\n+ type = \"Federated\"\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n- content {\n- test = \"StringEquals\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_fully_qualified_subjects\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_fully_qualified_subjects\n+ }\n }\n- }\n \n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n- content {\n- test = \"StringLike\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_subjects_with_wildcards\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_subjects_with_wildcards\n+ }\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -5,10 +5,6 @@ locals {\n for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n- identifiers = [\n- for url in local.urls :\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n- ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n }\n \n@@ -19,33 +15,38 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n- statement {\n- effect = \"Allow\"\n+ dynamic \"statement\" {\n+ for_each = local.urls\n \n- actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+ content {\n+ effect = \"Allow\"\n \n- principals {\n- type = \"Federated\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n \n- identifiers = local.identifiers\n- }\n+ principals {\n+ type = \"Federated\"\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n- content {\n- test = \"StringEquals\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_fully_qualified_subjects\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_fully_qualified_subjects\n+ }\n }\n- }\n \n+ dynamic \"condition\" {\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n \n- dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n- content {\n- test = \"StringLike\"\n- variable = \"${condition.value}:sub\"\n- values = var.oidc_subjects_with_wildcards\n+ content {\n+ test = \"StringLike\"\n+ variable = \"${statement.value}:sub\"\n+ values = var.oidc_subjects_with_wildcards\n+ }\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\nThe aws_iam_policy_document has support for specifying multiple principle federated identifiers like this:\r\n```\r\n\"Principal\": {\r\n \"Federated\": [\r\n \"arn:aws:iam::012345678912:saml-provider/first\",\r\n \"arn:aws:iam::012345678912:saml-provider/second\"\r\n ]\r\n},\r\n```\r\n\r\nCurrently, this module only supports specifying one provider_id:\r\n```\r\nprincipals {\r\n type = \"Federated\"\r\n identifiers = [var.provider_id]\r\n}\r\n```\r\n\r\n## Motivation and Context\r\nSolves issue #109 \r\n\r\n## Breaking Changes\r\n-\r\n\r\n## How Has This Been Tested?\r\nNot yet tested\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-roles-with-saml/main.tf\n@@ -7,6 +7,11 @@ resource \"aws_iam_saml_provider\" \"idp_saml\" {\n saml_metadata_document = file(\"saml-metadata.xml\")\n }\n \n+resource \"aws_iam_saml_provider\" \"second_idp_saml\" {\n+ name = \"second_idp_saml\"\n+ saml_metadata_document = file(\"saml-metadata.xml\")\n+}\n+\n ###############################\n # IAM assumable roles with SAML\n ###############################\n@@ -24,6 +29,23 @@ module \"iam_assumable_roles_with_saml\" {\n provider_id = aws_iam_saml_provider.idp_saml.id\n }\n \n+###############################\n+# IAM assumable roles with SAML\n+###############################\n+\n+module \"iam_assumable_roles_with_saml_second_provider\" {\n+ source = \"../../modules/iam-assumable-roles-with-saml\"\n+\n+ create_admin_role = true\n+\n+ create_poweruser_role = true\n+ poweruser_role_name = \"developer\"\n+\n+ create_readonly_role = true\n+\n+ provider_ids = [aws_iam_saml_provider.idp_saml.id, aws_iam_saml_provider.second_idp_saml.id]\n+}\n+\n #################################################################\n # Create custom role with SAML idp trust and additional policies\n #################################################################\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -40,7 +40,8 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n | poweruser\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for poweruser role | `string` | `\"\"` | no |\n | poweruser\\_role\\_policy\\_arns | List of policy ARNs to use for poweruser role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/PowerUserAccess\"<br>]</pre> | no |\n | poweruser\\_role\\_tags | A map of tags to add to poweruser role resource. | `map(string)` | `{}` | no |\n-| provider\\_id | ID of the SAML Provider | `string` | n/a | yes |\n+| provider\\_id | ID of the SAML Provider. Use provider\\_ids to specify several IDs. | `string` | `\"\"` | no |\n+| provider\\_ids | List of SAML Provider IDs | `list(string)` | `[]` | no |\n | readonly\\_role\\_name | IAM role with readonly access | `string` | `\"readonly\"` | no |\n | readonly\\_role\\_path | Path of readonly IAM role | `string` | `\"/\"` | no |\n | readonly\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for readonly role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-roles-with-saml/main.tf\n@@ -1,12 +1,17 @@\n+locals {\n+ identifiers = compact(distinct(concat(var.provider_ids, [var.provider_id])))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n statement {\n effect = \"Allow\"\n \n actions = [\"sts:AssumeRoleWithSAML\"]\n \n principals {\n- type = SAML identifiers = [var.provider_id]\n+ type = \"Federated\"\n+\n+ identifiers = local.identifiers\n }\n \n condition {\n---\nmodules/iam-assumable-roles-with-saml/variables.tf\n@@ -1,6 +1,13 @@\n variable \"provider_id\" {\n- description = \"ID of the SAML Provider\"\n+ description = \"ID of the SAML Provider. Use provider_ids to specify several IDs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_ids\" {\n+ description = \"List of SAML Provider IDs\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_saml_endpoint\" {\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-roles-with-saml/main.tf\n@@ -7,6 +7,11 @@ resource \"aws_iam_saml_provider\" \"idp_saml\" {\n saml_metadata_document = file(\"saml-metadata.xml\")\n }\n \n+resource \"aws_iam_saml_provider\" \"second_idp_saml\" {\n+ name = \"second_idp_saml\"\n+ saml_metadata_document = file(\"saml-metadata.xml\")\n+}\n+\n ###############################\n # IAM assumable roles with SAML\n ###############################\n@@ -24,6 +29,23 @@ module \"iam_assumable_roles_with_saml\" {\n provider_id = aws_iam_saml_provider.idp_saml.id\n }\n \n+###############################\n+# IAM assumable roles with SAML\n+###############################\n+\n+module \"iam_assumable_roles_with_saml_second_provider\" {\n+ source = \"../../modules/iam-assumable-roles-with-saml\"\n+\n+ create_admin_role = true\n+\n+ create_poweruser_role = true\n+ poweruser_role_name = \"developer\"\n+\n+ create_readonly_role = true\n+\n+ provider_ids = [aws_iam_saml_provider.idp_saml.id, aws_iam_saml_provider.second_idp_saml.id]\n+}\n+\n #################################################################\n # Create custom role with SAML idp trust and additional policies\n #################################################################\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -40,7 +40,8 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n | poweruser\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for poweruser role | `string` | `\"\"` | no |\n | poweruser\\_role\\_policy\\_arns | List of policy ARNs to use for poweruser role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/PowerUserAccess\"<br>]</pre> | no |\n | poweruser\\_role\\_tags | A map of tags to add to poweruser role resource. | `map(string)` | `{}` | no |\n-| provider\\_id | ID of the SAML Provider | `string` | n/a | yes |\n+| provider\\_id | ID of the SAML Provider. Use provider\\_ids to specify several IDs. | `string` | `\"\"` | no |\n+| provider\\_ids | List of SAML Provider IDs | `list(string)` | `[]` | no |\n | readonly\\_role\\_name | IAM role with readonly access | `string` | `\"readonly\"` | no |\n | readonly\\_role\\_path | Path of readonly IAM role | `string` | `\"/\"` | no |\n | readonly\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for readonly role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-roles-with-saml/main.tf\n@@ -1,12 +1,17 @@\n+locals {\n+ identifiers = compact(distinct(concat(var.provider_ids, [var.provider_id])))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n statement {\n effect = \"Allow\"\n \n actions = [\"sts:AssumeRoleWithSAML\"]\n \n principals {\n- type = \"Federated\"\n- identifiers = [var.provider_id]\n+ type = \"Federated\"\n+\n+ identifiers = local.identifiers\n }\n \n type {\n---\nmodules/iam-assumable-roles-with-saml/variables.tf\n@@ -1,6 +1,13 @@\n variable \"provider_id\" {\n- description = \"ID of the SAML Provider\"\n+ description = \"ID of the SAML Provider. Use provider_ids to specify several IDs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_ids\" {\n+ description = \"List of SAML Provider IDs\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_saml_endpoint\" {\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-roles-with-saml/main.tf\n@@ -7,6 +7,11 @@ resource \"aws_iam_saml_provider\" \"idp_saml\" {\n saml_metadata_document = file(\"saml-metadata.xml\")\n }\n \n+resource \"aws_iam_saml_provider\" \"second_idp_saml\" {\n+ name = \"second_idp_saml\"\n+ saml_metadata_document = file(\"saml-metadata.xml\")\n+}\n+\n ###############################\n # IAM assumable roles with SAML\n ###############################\n@@ -24,6 +29,23 @@ module \"iam_assumable_roles_with_saml\" {\n | = aws_iam_saml_provider.idp_saml.id\n }\n \n+###############################\n+# IAM assumable roles with SAML\n+###############################\n+\n+module \"iam_assumable_roles_with_saml_second_provider\" {\n+ source = \"../../modules/iam-assumable-roles-with-saml\"\n+\n+ create_admin_role = true\n+\n+ create_poweruser_role = true\n+ poweruser_role_name = \"developer\"\n+\n+ create_readonly_role = true\n+\n+ provider_ids = [aws_iam_saml_provider.idp_saml.id, aws_iam_saml_provider.second_idp_saml.id]\n+}\n+\n #################################################################\n # Create custom role with SAML idp trust and additional policies\n #################################################################\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -40,7 +40,8 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n | poweruser\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for poweruser role | `string` | `\"\"` | no |\n | poweruser\\_role\\_policy\\_arns | List of policy ARNs to use for poweruser role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/PowerUserAccess\"<br>]</pre> | no |\n | poweruser\\_role\\_tags | A map of tags to add to poweruser role resource. | `map(string)` | `{}` | no |\n-| provider\\_id | ID of the SAML Provider | `string` | n/a | yes |\n+| provider\\_id | ID of the SAML Provider. Use provider\\_ids to specify several IDs. | `string` | `\"\"` | no |\n+| provider\\_ids | List of SAML Provider IDs | `list(string)` | `[]` | no |\n | readonly\\_role\\_name | IAM role with readonly access | `string` | `\"readonly\"` | no |\n | readonly\\_role\\_path | Path of readonly IAM role | `string` | `\"/\"` | no |\n | readonly\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for readonly role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-roles-with-saml/main.tf\n@@ -1,12 +1,17 @@\n+locals {\n+ identifiers = compact(distinct(concat(var.provider_ids, [var.provider_id])))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n statement {\n effect = \"Allow\"\n \n actions = [\"sts:AssumeRoleWithSAML\"]\n \n principals {\n- type = \"Federated\"\n- identifiers = [var.provider_id]\n+ type = \"Federated\"\n+\n+ identifiers = local.identifiers\n }\n \n condition {\n---\nmodules/iam-assumable-roles-with-saml/variables.tf\n@@ -1,6 +1,13 @@\n variable \"provider_id\" {\n- description = \"ID of the SAML Provider\"\n+ description = \"ID of the SAML Provider. Use provider_ids to specify several IDs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_ids\" {\n+ description = \"List of SAML Provider IDs\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_saml_endpoint\" {\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-roles-with-saml/main.tf\n@@ -7,6 +7,11 @@ resource \"aws_iam_saml_provider\" \"idp_saml\" {\n saml_metadata_document = file(\"saml-metadata.xml\")\n }\n \n+resource \"aws_iam_saml_provider\" \"second_idp_saml\" {\n+ name = \"second_idp_saml\"\n+ saml_metadata_document = file(\"saml-metadata.xml\")\n+}\n+\n ###############################\n # IAM assumable roles with SAML\n ###############################\n@@ -24,6 +29,23 @@ module \"iam_assumable_roles_with_saml\" {\n provider_id = aws_iam_saml_provider.idp_saml.id\n }\n \n+###############################\n+# IAM assumable roles with SAML\n+###############################\n+\n+module \"iam_assumable_roles_with_saml_second_provider\" {\n+ source = \"../../modules/iam-assumable-roles-with-saml\"\n+\n+ create_admin_role = true\n+\n+ create_poweruser_role = true\n+ poweruser_role_name = \"developer\"\n+\n+ create_readonly_role = true\n+\n+ provider_ids = [aws_iam_saml_provider.idp_saml.id, aws_iam_saml_provider.second_idp_saml.id]\n+}\n+\n #################################################################\n # Create custom role with SAML idp trust and additional policies\n #################################################################\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -40,7 +40,8 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n | poweruser\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for poweruser role | `string` | `\"\"` | no |\n | poweruser\\_role\\_policy\\_arns | List of policy ARNs to use for poweruser role | `list(string)` | <pre>[<br> \"arn:aws:iam::aws:policy/PowerUserAccess\"<br>]</pre> | no |\n | poweruser\\_role\\_tags | A map of tags to add to poweruser role resource. | `map(string)` | `{}` | no |\n-| provider\\_id | ID of the SAML Provider | `string` | n/a | yes |\n+| provider\\_id | ID of the SAML Provider. Use provider\\_ids to specify several IDs. | `string` | `\"\"` | no |\n+| provider\\_ids | List of SAML Provider IDs | `list(string)` | `[]` | no |\n | readonly\\_role\\_name | IAM role with readonly access | `string` | `\"readonly\"` | no |\n | readonly\\_role\\_path | Path of readonly IAM role | `string` | `\"/\"` | no |\n | readonly\\_role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for readonly role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-roles-with-saml/main.tf\n@@ -1,12 +1,17 @@\n+locals {\n+ identifiers = compact(distinct(concat(var.provider_ids, [var.provider_id])))\n+}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n statement {\n effect = \"Allow\"\n \n actions = [\"sts:AssumeRoleWithSAML\"]\n \n principals {\n- type = \"Federated\"\n- identifiers = [var.provider_id]\n+ type = \"Federated\"\n+\n+ identifiers = local.identifiers\n }\n \n condition {\n---\nmodules/iam-assumable-roles-with-saml/variables.tf\n@@ -1,6 +1,13 @@\n variable \"provider_id\" {\n- description = \"ID of the SAML Provider\"\n+ description = \"ID of the SAML Provider. Use provider_ids to specify several IDs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_ids\" {\n+ description = \"List of SAML Provider IDs\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_saml_endpoint\" {\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\nMinimum password length.\r\nYou can specify the minimum number of characters allowed in an IAM user password. You can type any number from 6 to 128.\r\n\r\n## Motivation and Context\r\nThis is supported by official document.\r\n\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-user/variables.tf\n@@ -46,9 +46,9 @@ variable \"password_reset_required\" {\n }\n \n variable \"password_length\" {\n- description = \"The length of the generated password\"\n+ description = \"The length of the generated password. You can type any number from 6 to 128.\"\n type = number\n- default = 20\n+ default = 6\n }\n \n variable \"upload_iam_user_ssh_key\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/variables.tf\n@@ -46,9 +46,9 @@ variable \"password_reset_required\" {\n }\n \n variable \"password_length\" {\n- description = \"The length of the generated password\"\n+ description = \"The length of the generated password. You can type any number from 6 to 128.\"\n type = number\n- default generated = 20\n+ default = 6\n }\n \n variable \"upload_iam_user_ssh_key\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/variables.tf\n@@ -46,9 +46,9 @@ variable \"password_reset_required\" {\n }\n \n variable \"password_length\" {\n- description = \"The length of the generated password\"\n+ description = \"The length of the generated password. You can type any number from 6 to 128.\"\n type = number\n- default = 20\n+ default = 6\n }\n \n variable \"upload_iam_user_ssh_key\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/variables.tf\n@@ -46,9 +46,9 @@ variable \"password_reset_required\" {\n }\n \n variable \"password_length\" {\n- description = \"The length of the generated password\"\n+ description = \"The length of the generated password. You type any number from 6 to 128.\"\n type = number\n- default = 20\n+ default = 6\n }\n \n variable \"upload_iam_user_ssh_key\" {\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\nI ran [Checkov](https://github.com/bridgecrewio/checkov) against this repository and got two errors shown below:\r\n\r\n```\r\nCheck: CKV_AWS_9: \"Ensure IAM password policy expires passwords within 90 days or less\"\r\n FAILED for resource: aws_iam_account_password_policy.this\r\n File: /iam-account/main.tf:9-21\r\n Guide: https://docs.bridgecrew.io/docs/iam_11\r\n\r\n 9 | resource \"aws_iam_account_password_policy\" \"this\" {\r\n 10 | count = var.create_account_password_policy ? 1 : 0\r\n 11 | \r\n 12 | max_password_age = var.max_password_age\r\n 13 | minimum_password_length = var.minimum_password_length\r\n 14 | allow_users_to_change_password = var.allow_users_to_change_password\r\n 15 | hard_expiry = var.hard_expiry\r\n 16 | password_reuse_prevention = var.password_reuse_prevention\r\n 17 | require_lowercase_characters = var.require_lowercase_characters\r\n 18 | require_uppercase_characters = var.require_uppercase_characters\r\n 19 | require_numbers = var.require_numbers\r\n 20 | require_symbols = var.require_symbols\r\n 21 | }\r\n\r\n Variable create_account_password_policy (of /iam-account/variables.tf) evaluated to value \"True\" in expression: count = ${var.create_account_password_policy ? 1 : 0}\r\n Variable max_password_age (of /iam-account/variables.tf) evaluated to value \"0\" in expression: max_password_age = ${var.max_password_age}\r\n Variable minimum_password_length (of /iam-account/variables.tf) evaluated to value \"8\" in expression: minimum_password_length = ${var.minimum_password_length}\r\n Variable allow_users_to_change_password (of /iam-account/variables.tf) evaluated to value \"True\" in expression: allow_users_to_change_password = ${var.allow_users_to_change_password}\r\n Variable hard_expiry (of /iam-account/variables.tf) evaluated to value \"False\" in expression: hard_expiry = ${var.hard_expiry}\r\n Variable require_lowercase_characters (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_lowercase_characters = ${var.require_lowercase_characters}\r\n Variable require_uppercase_characters (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_uppercase_characters = ${var.require_uppercase_characters}\r\n Variable require_numbers (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_numbers = ${var.require_numbers}\r\n Variable require_symbols (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_symbols = ${var.require_symbols}\r\n\r\nCheck: CKV_AWS_10: \"Ensure IAM password policy requires minimum length of 14 or greater\"\r\n FAILED for resource: aws_iam_account_password_policy.this\r\n File: /iam-account/main.tf:9-21\r\n Guide: https://docs.bridgecrew.io/docs/iam_9-1\r\n\r\n 9 | resource \"aws_iam_account_password_policy\" \"this\" {\r\n 10 | count = var.create_account_password_policy ? 1 : 0\r\n 11 | \r\n 12 | max_password_age = var.max_password_age\r\n 13 | minimum_password_length = var.minimum_password_length\r\n 14 | allow_users_to_change_password = var.allow_users_to_change_password\r\n 15 | hard_expiry = var.hard_expiry\r\n 16 | password_reuse_prevention = var.password_reuse_prevention\r\n 17 | require_lowercase_characters = var.require_lowercase_characters\r\n 18 | require_uppercase_characters = var.require_uppercase_characters\r\n 19 | require_numbers = var.require_numbers\r\n 20 | require_symbols = var.require_symbols\r\n 21 | }\r\n\r\n Variable create_account_password_policy (of /iam-account/variables.tf) evaluated to value \"True\" in expression: count = ${var.create_account_password_policy ? 1 : 0}\r\n Variable max_password_age (of /iam-account/variables.tf) evaluated to value \"0\" in expression: max_password_age = ${var.max_password_age}\r\n Variable minimum_password_length (of /iam-account/variables.tf) evaluated to value \"8\" in expression: minimum_password_length = ${var.minimum_password_length}\r\n Variable allow_users_to_change_password (of /iam-account/variables.tf) evaluated to value \"True\" in expression: allow_users_to_change_password = ${var.allow_users_to_change_password}\r\n Variable hard_expiry (of /iam-account/variables.tf) evaluated to value \"False\" in expression: hard_expiry = ${var.hard_expiry}\r\n Variable require_lowercase_characters (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_lowercase_characters = ${var.require_lowercase_characters}\r\n Variable require_uppercase_characters (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_uppercase_characters = ${var.require_uppercase_characters}\r\n Variable require_numbers (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_numbers = ${var.require_numbers}\r\n Variable require_symbols (of /iam-account/variables.tf) evaluated to value \"True\" in expression: require_symbols = ${var.require_symbols}\r\n```\r\n\r\n## Motivation and Context\r\nI'm creating this PR to align with Checkov recommendations from a security perspective.\r\n\r\nReferences:\r\n\r\n`max_password_age` = 90 | https://docs.bridgecrew.io/docs/iam_11\r\n`minimum_password_length` = 14 | https://docs.bridgecrew.io/docs/iam_9-1\r\n\r\n## Breaking Changes\r\nIt can affect users using the current module as their policies will change after applying this.\r\n\r\n## How Has This Been Tested?\r\nI have tested in our environments.\n\n---\n\nChoice A:\nmodules/iam-account/variables.tf\n@@ -18,13 +18,13 @@ variable variable {\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n- default = 0\n+ default = 90\n }\n \n variable \"minimum_password_length\" {\n description = \"Minimum length to require for user passwords\"\n type = number\n- default = 8\n+ default = 14\n }\n \n variable \"allow_users_to_change_password\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-account/variables.tf\n@@ -18,13 +18,13 @@ variable \"create_account_password_policy\" {\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n- default = 0\n+ default = 90\n }\n \n variable \"minimum_password_length\" {\n description = \"Minimum length to require for user passwords\"\n type = number\n- default @@ = 8\n+ default = 14\n }\n \n variable \"allow_users_to_change_password\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-account/variables.tf\n@@ -18,13 +18,13 @@ variable \"create_account_password_policy\" {\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n- default = 0\n+ number\n- default = 90\n }\n \n variable \"minimum_password_length\" {\n description = \"Minimum length to require for user passwords\"\n type = number\n- default = 8\n+ default = 14\n }\n \n variable \"allow_users_to_change_password\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-account/variables.tf\n@@ -18,13 +18,13 @@ variable \"create_account_password_policy\" {\n variable \"max_password_age\" {\n description = \"The number of days that an user password is valid.\"\n type = number\n- default = 0\n+ default = 90\n }\n \n variable \"minimum_password_length\" {\n description = \"Minimum length to require for user passwords\"\n type = number\n- default = 8\n+ default = 14\n }\n \n variable \"allow_users_to_change_password\" {\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\nAdds `role_prefix` option to `iam-assumable-role-with-oidc` module \r\n\r\n## Motivation and Context\r\n\r\nThe underlying `aws_iam_role` resource allows a `role_prefix` option for role creation, and in my situation that would be a useful configuration knob\r\n\r\n## Breaking Changes\r\n\r\nIt does not break configuration to my knowledge\r\n\r\n## How Has This Been Tested?\r\n\r\nHappy path tested on internal branch\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,7 +33,8 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n-| role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_name | IAM role name | `string` | `null` | no |\n+| role\\_name\\_prefix | IAM role name prefix | `string` | `null` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n to name = var.role_name\n+ name_prefix = var.role_name_prefix\n description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -31,7 +31,13 @@ variable \"tags\" {\n variable \"role_name\" {\n description = \"IAM role name\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"role_name_prefix\" {\n+ description = \"IAM role name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"role_description\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,7 +33,8 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n-| role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_name | IAM role name | `string` | `null` | no |\n+| role\\_name\\_prefix | IAM role name prefix | `string` | `null` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ name_prefix = var.role_name_prefix\n description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -31,7 +31,13 @@ variable \"tags\" {\n variable \"role_name\" {\n description = \"IAM role name\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"role_name_prefix\" {\n+ description = \"IAM role name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"role_description\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,7 +33,8 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n-| role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_name | IAM role name | `string` | `null` | no |\n+| role\\_name\\_prefix | IAM role name prefix | `string` | `null` | no |\n | role\\_path | Path of | role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ name_prefix = var.role_name_prefix\n description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -31,7 +31,13 @@ variable \"tags\" {\n variable \"role_name\" {\n description = \"IAM role name\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"role_name_prefix\" {\n+ description = \"IAM role name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"role_description\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,7 +33,8 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n-| role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_name | IAM role name | `string` | `null` | no |\n+| role\\_name\\_prefix | IAM role name prefix | `string` | `null` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ name_prefix = var.role_name_prefix\n description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -31,7 +31,13 @@ variable \"tags\" {\n variable \"role_name\" {\n description = \"IAM role name\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"role_name_prefix\" {\n+ description = \"IAM role name prefix\"\n+ type of = string\n+ default = null\n }\n \n variable \"role_description\" {\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:\nNeeded with new terraform-docs\r\n\r\n## Description\r\n\r\nUpdate to latest `pre-commit-terraform` release\r\n\r\n## Motivation and Context\r\n\r\nThe old pre-commit-terraform was failing to update README.md with a new install and new terraform-docs (`0.10.1`). This was stopping me from making a functional PR\r\n\r\n## Breaking Changes\r\n\r\nNo known breaking changes\r\n\r\n## How Has This Been Tested?\r\n\r\nRun locally\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.39.0\n+ rev: v1.43.0\n hooks:\n rev: - id: terraform_fmt\n - id: terraform_docs\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n -1,6 - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.39.0\n+ rev: v1.43.0\n hooks:\n - id: terraform_fmt\n - id: terraform_docs\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.39.0\n+ rev: v1.43.0\n hooks:\n - id: terraform_fmt\n - id: terraform_docs\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.39.0\n+ rev: v1.43.0\n hooks:\n - id: terraform_fmt\n - - id: terraform_docs\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\nRemove empty string elements from `local.urls` in `iam-assumable-role-with-oidc` submodule.\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\nIf only `var.provider_urls` is specified and `var.provider_url` is not specified, the array will contain an empty character and an error will occur.\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<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\r\nExecute terraform plan as follows.\r\n\r\n```hcl\r\nmodule \"iam_assumable_role_admin\" {\r\n source = \"terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc\"\r\n version = \"2.22.0\"\r\n\r\n create_role = true\r\n role_name = \"role-with-oidc\"\r\n provider_urls = [\"oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8\"]\r\n role_policy_arns = [\r\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\r\n ]\r\n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\r\n}\r\n```\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -2,7 +2,7 @@ locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n # clean URLs of https:// prefix\n urls = [\n- for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n identifiers = [\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -2,7 +2,7 @@ locals {\n aws_account_id = var.aws_account_id != ? var.aws_account_id : data.aws_caller_identity.current.account_id\n # clean URLs of https:// prefix\n urls = [\n- for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n identifiers = [\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -2,7 +2,7 @@ locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n # clean of https:// prefix\n urls = [\n- for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\n ]\n identifiers = [\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -2,7 +2,7 @@ locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n # clean URLs of https:// prefix\n urls = [\n- for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ for url in compact(distinct(concat(var.provider_urls, [var.provider_url]))) :\n replace(url, \"https://\", \"\")\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\nAdd \"role_description\" variable for the \"assumable-role-with-oidc\" module\r\n\r\n## Motivation and Context\r\nDuring a personal project using this excellent module I noticed that the feature to add a description for an oidc role was missing.\r\n\r\n## Breaking Changes\r\nNothing breaks, the change is minor. The parts that were added were copy-pasted from the \"assumable-role\" module.\r\n\r\n## How Has This Been Tested?\r\nThe change in the module was tested against a role that had no description before and one was added via this branch, and then the description was changed through the same method. No issues detected. \r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,6 +33,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_description | IAM Role description | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -34,6 +34,12 @@ variable \"role_name\" {\n default = \"\"\n }\n \n+variable \"role_description\" {\n+ description = \"IAM Role description\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"role_path\" {\n description = \"Path variable IAM role\"\n type = string\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,6 +33,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_description | IAM Role description | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -34,6 +34,12 @@ variable \"role_name\" {\n default = \"\"\n }\n \n+variable \"role_description\" {\n+ description = \"IAM Role description\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"role_path\" {\n description = \"Path of IAM role\"\n type = string\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,6 +33,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_description | IAM Role description | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -34,6 +34,12 @@ variable \"role_name\" {\n default | = \"\"\n }\n \n+variable \"role_description\" {\n+ description = \"IAM Role description\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"role_path\" {\n description = \"Path of IAM role\"\n type = string\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -33,6 +33,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n | provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n+| role\\_description | IAM Role description | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_policy\\_arns | List of ARNs of IAM \n to attach to IAM role | `list(string)` | `[]` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -54,6 +54,7 @@ resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n name = var.role_name\n+ description = var.role_description\n path = var.role_path\n max_session_duration = var.max_session_duration\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -34,6 +34,12 @@ variable \"role_name\" {\n default = \"\"\n }\n \n+variable \"role_description\" {\n+ description = \"IAM Role description\"\n+ type = string\n+ default = \"\"\n+}\n+\n variable \"role_path\" {\n description = \"Path of IAM role\"\n type = string\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:\nfix for terraform error for assumable-role\"number of resources cannot be determined during runtime\" in iam-assumable-role\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,6 +22,7 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n+ number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nexamples/iam-assumable-role/main.tf\n@@ -54,4 +54,5 @@ module \"iam_assumable_role_custom\" {\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n ]\n+ number_of_custom_role_policy_arns = 2\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,6 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of custom policies passed to variable role\\_policy\\_arns | `number` | `0` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,6 +70,13 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"number_of_role_policy_arns\" {\n+ description = \"Number of IAM policies to attach to IAM role\"\n+ type = number\n+ default = 0\n+}\n+\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/README.md\n@@ -32,6 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of custom policies passed to variable custom\\_role\\_policy\\_arns | `number` | `0` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\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 = 0\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,6 +22,7 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n+ number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nexamples/iam-assumable-role/main.tf\n@@ -54,4 +54,5 @@ module \"iam_assumable_role_custom\" {\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n ]\n+ number_of_custom_role_policy_arns = 2\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,6 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no \n+variable | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of custom policies passed to variable role\\_policy\\_arns | `number` | `0` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,6 +70,13 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"number_of_role_policy_arns\" {\n+ description = \"Number of IAM policies to attach to IAM role\"\n+ type = number\n+ default = 0\n+}\n+\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/README.md\n@@ -32,6 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of custom policies passed to variable custom\\_role\\_policy\\_arns | `number` | `0` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\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 = 0\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,6 +22,7 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n+ number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nexamples/iam-assumable-role/main.tf\n@@ -54,4 +54,5 @@ module \"iam_assumable_role_custom\" {\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n ]\n+ number_of_custom_role_policy_arns = 2\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,6 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of custom policies passed to variable role\\_policy\\_arns | `number` | `0` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,6 +70,13 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"number_of_role_policy_arns\" {\n+ description = \"Number of IAM policies to attach to IAM role\"\n+ type = number\n+ default = 0\n+}\n+\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/README.md\n@@ -32,6 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 to `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of custom policies passed to variable custom\\_role\\_policy\\_arns | `number` | `0` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\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 = 0\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -22,6 +22,7 @@ module \"iam_assumable_role_admin\" {\n role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n ]\n+ number_of_role_policy_arns = 1\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n---\nexamples/iam-assumable-role/main.tf\n@@ -54,4 +54,5 @@ module \"iam_assumable_role_custom\" {\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n ]\n+ number_of_custom_role_policy_arns = 2\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -28,6 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n+| number\\_of\\_role\\_policy\\_arns | Number of custom policies passed to variable role\\_policy\\_arns | `number` | `0` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n | provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -68,7 +68,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? var.number_of_role_policy_arns : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -70,6 +70,13 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"number_of_role_policy_arns\" {\n+ description = \"Number of IAM policies to attach to IAM role\"\n+ type = number\n+ default = 0\n+}\n+\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/README.md\n@@ -32,6 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | mfa\\_age | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n+| number\\_of\\_custom\\_role\\_policy\\_arns | Number of custom policies passed to variable custom\\_role\\_policy\\_arns | `number` | `0` | no |\n | poweruser\\_role\\_policy\\_arn | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | readonly\\_role\\_policy\\_arn | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | role\\_description | IAM Role description | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role ? length(var.custom_role_policy_arns) : 0\n+ count for var.create_role ? var.number_of_custom_role_policy_arns : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\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 = 0\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\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\nSupport non default partition like gov\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\nCloses #79\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<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\nDon't have govcloud access. Similar to #83\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -2,6 +2,8 @@ data \"aws_caller_identity\" \"current\" {\n count = var.aws_account_id == \"\" ? 1 : 0\n }\n \n+data \"aws_partition\" \"current\" {}\n+\n locals {\n aws_account_id = element(\n concat(\n@@ -41,9 +43,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n }\n \n@@ -71,9 +73,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n \n condition {\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -2,6 +2,8 @@ data \"aws_caller_identity\" \"current\" {\n count = var.aws_account_id == \"\" ? 1 : 0\n }\n \n+data \"aws_partition\" \"current\" {}\n+\n locals {\n aws_account_id = element(\n concat(\n@@ -41,9 +43,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n }\n \n@@ -71,9 +73,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n \n condition {\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -2,6 +2,8 @@ data \"aws_caller_identity\" \"current\" {\n count = var.aws_account_id == \"\" ? 1 : 0\n }\n \n+data \"aws_partition\" \"current\" {}\n+\n locals {\n aws_account_id = element(\n concat(\n@@ -41,9 +43,9 @@ \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n }\n \n@@ -71,9 +73,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n \n condition {\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -2,6 +2,8 @@ data \"aws_caller_identity\" \"current\" {\n count = var.aws_account_id == \"\" ? 1 : 0\n }\n \n+data \"aws_partition\" \"current\" {}\n+\n locals {\n aws_account_id = element(\n concat(\n@@ -41,9 +43,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n }\n \n@@ -71,9 +73,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \n # Allow for both users with \"path\" and without it\n resources = [\n- \"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n ]\n \n condition {\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\nSimplify Count statement in 2 cases of policy attachments as it causes failures during apply in some cases\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\nSimplify Count statement in 2 cases of policy attachments as it causes failures during apply in some cases\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<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\nYes.\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -66,7 +66,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? length(var.custom_role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-group-with-policies/main.tf\n@@ -27,14 +27,14 @@ resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- length(var.role_policy_arns) count = length(var.custom_group_policy_arns) > 0 ? length(var.custom_group_policy_arns) : 0\n+ count = length(var.custom_group_policy_arns)\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) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom.*.arn, count.index)\n@@ -51,7 +51,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\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:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -66,7 +66,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? length(var.custom_role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = count.index)\n---\nmodules/iam-group-with-policies/main.tf\n@@ -27,14 +27,14 @@ resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns) > 0 ? length(var.custom_group_policy_arns) : 0\n+ count = length(var.custom_group_policy_arns)\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) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom.*.arn, count.index)\n@@ -51,7 +51,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\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:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -66,7 +66,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? length(var.role_policy_arns) = 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? length(var.custom_role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-group-with-policies/main.tf\n@@ -27,14 +27,14 @@ resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns) > 0 ? length(var.custom_group_policy_arns) : 0\n+ count = length(var.custom_group_policy_arns)\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) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom.*.arn, count.index)\n@@ -51,7 +51,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\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:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -66,7 +66,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = join(\"\", aws_iam_role.this.*.name)\n policy_arn = var.role_policy_arns[count.index]\n---\nmodules/iam-assumable-role/main.tf\n@@ -72,7 +72,7 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n+ count = var.create_role ? length(var.custom_role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n policy_arn = element(var.custom_role_policy_arns, count.index)\n---\nmodules/iam-group-with-policies/main.tf\n@@ -27,14 +27,14 @@ resource \"aws_iam_group_policy_attachment\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_group_policy_attachment\" \"custom_arns\" {\n- count = length(var.custom_group_policy_arns) > 0 ? length(var.custom_group_policy_arns) : 0\n+ count = length(var.custom_group_policy_arns)\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) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\n \n group = local.group_name\n policy_arn = element(aws_iam_policy.custom.*.arn, count.index)\n@@ -51,7 +51,7 @@ resource \"aws_iam_policy\" \"iam_self_management\" {\n }\n \n resource \"aws_iam_policy\" \"custom\" {\n- count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0\n+ count = length(var.custom_group_policies)\n \n name = var.custom_group_policies[count.index][\"name\"]\n policy = var.custom_group_policies[count.index][\"policy\"]\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:\nBased on #81\r\nCloses #81\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -16,7 +16,8 @@ module \"iam_assumable_role_admin\" {\n Role = \"role-with-oidc\"\n }\n \n- provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\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---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n+| provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Use provider_urls to specify several URLs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\n default \"\"\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -16,7 +16,8 @@ module \"iam_assumable_role_admin\" {\n Role = \"role-with-oidc\"\n }\n \n- provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\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---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n+| provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Use provider_urls to specify several URLs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -16,7 +16,8 @@ module \"iam_assumable_role_admin\" {\n Role = \"role-with-oidc\"\n }\n \n- provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\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---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n+| provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Use provider_urls to specify several URLs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -16,7 +16,8 @@ module \"iam_assumable_role_admin\" {\n Role = \"role-with-oidc\"\n }\n \n- provider_url = \"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8\"\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---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Use provider\\_urls to specify several URLs. | `string` | `\"\"` | no |\n+| provider\\_urls | List of URLs of the OIDC Providers | `list(string)` | `[]` | no |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Use provider_urls to specify several URLs.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\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\n- Add support of sts:ExternalId\r\n\r\n## Motivation and Context\r\nhttps://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html - sometimes service integration require ExternalId instead of MFA.\r\n \r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\nI've tested in my environment having this kind of setup:\r\n\r\n```\r\nmodule \"iam_assume_role_in_prod_testrole\" {\r\n source = \"git::https://github.com/LAKostis/terraform-aws-iam.git//modules/iam-assumable-role?ref=feature/add-sts-externalid-support\"\r\n\r\n trusted_role_arns = [\r\n \"arn:aws:iam::${var.some_account_id}:root\",\r\n ]\r\n\r\n create_role = true\r\n\r\n role_name = \"DatadogAWSIntegrationRole\"\r\n role_requires_mfa = false\r\n\r\n sts_externalid = var.datadog_sts_id\r\n\r\n custom_role_policy_arns = [\r\n \"arn:aws:iam::${data.aws_caller_identity.test.account_id}:policy/DatadogAWSIntegrationPolicy\",\r\n ]\r\n\r\n providers = {\r\n aws = aws.test\r\n }\r\n}\r\n```\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role/main.tf\n@@ -48,6 +48,8 @@ module \"iam_assumable_role_custom\" {\n role_name = \"custom\"\n role_requires_mfa = false\n \n+ role_sts_externalid = \"some-id-goes-here\"\n+\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n---\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n@@ -49,6 +50,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Description |\n |------|-------------|\n | role\\_requires\\_mfa | Whether IAM role requires MFA |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role |\n | this\\_iam\\_instance\\_profile\\_arn | ARN of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_name | Name of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_path | Path of IAM instance profile |\n---\nmodules/iam-assumable-role/main.tf\n@@ -13,6 +13,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n type = \"Service\"\n identifiers = var.trusted_role_services\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/outputs.tf\n@@ -32,3 +32,9 condition output \"this_iam_instance_profile_path\" {\n description = \"Path of IAM instance profile\"\n value = element(concat(aws_iam_instance_profile.this.*.path, [\"\"]), 0)\n }\n+\n+output \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role\"\n+ value = var.role_sts_externalid\n+}\n+\n---\nmodules/iam-assumable-role/variables.tf\n@@ -125,3 +125,9 @@ variable \"role_description\" {\n default = \"\"\n }\n \n+variable \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n+ type = string\n+ default = null\n+}\n+\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role/main.tf\n@@ -48,6 +48,8 @@ module \"iam_assumable_role_custom\" {\n role_name = \"custom\"\n role_requires_mfa = false\n \n+ role_sts_externalid = \"some-id-goes-here\"\n+\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n---\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n@@ -49,6 +50,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Description |\n |------|-------------|\n | role\\_requires\\_mfa | Whether IAM role requires MFA |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role |\n | this\\_iam\\_instance\\_profile\\_arn | ARN of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_name | Name of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_path | Path of IAM instance profile |\n---\nmodules/iam-assumable-role/main.tf\n@@ -13,6 +13,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n type = \"Service\"\n identifiers = var.trusted_role_services\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/outputs.tf\n@@ -32,3 +32,9 @@ output \"this_iam_instance_profile_path\" {\n description = \"Path of IAM instance profile\"\n value = element(concat(aws_iam_instance_profile.this.*.path, [\"\"]), 0)\n }\n+\n+output \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role\"\n+ value = var.role_sts_externalid\n+}\n+\n---\nmodules/iam-assumable-role/variables.tf\n@@ -125,3 +125,9 @@ variable \"role_description\" {\n default = \"\"\n }\n \n+variable \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n+ type = string\n+ default = null\n+}\n+\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role/main.tf\n@@ -48,6 +48,8 @@ module \"iam_assumable_role_custom\" {\n role_name = \"custom\"\n role_requires_mfa = false\n \n+ role_sts_externalid = \"some-id-goes-here\"\n+\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n---\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n@@ -49,6 +50,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Description |\n |------|-------------|\n | role\\_requires\\_mfa | Whether IAM role requires MFA |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role |\n | this\\_iam\\_instance\\_profile\\_arn | ARN of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_name | Name of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_path | Path of IAM instance profile |\n---\nmodules/iam-assumable-role/main.tf\n@@ -13,6 +13,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n type = \"Service\"\n identifiers = var.trusted_role_services\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/outputs.tf\n@@ -32,3 +32,9 @@ output \"this_iam_instance_profile_path\" {\n description = \"Path of IAM instance profile\"\n value = element(concat(aws_iam_instance_profile.this.*.path, [\"\"]), 0)\n }\n+\n+output \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role\"\n+ value = var.role_sts_externalid\n+}\n+\n---\nmodules/iam-assumable-role/variables.tf\n@@ -125,3 +125,9 @@ variable \"role_description\" {\n default = \"\"\n }\n \n+variable \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n+ type = string\n+ default = null\n+}\n+\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role/main.tf\n@@ -48,6 +48,8 @@ module \"iam_assumable_role_custom\" {\n role_name = \"custom\"\n role_requires_mfa = false\n \n+ role_sts_externalid = \"some-id-goes-here\"\n+\n custom_role_policy_arns = [\n \"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\",\n \"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess\",\n---\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n@@ -49,6 +50,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | Name | Description |\n |------|-------------|\n | role\\_requires\\_mfa | Whether IAM role requires MFA |\n+| role\\_sts\\_externalid | STS ExternalId condition value to use with a role |\n | this\\_iam\\_instance\\_profile\\_arn | ARN of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_name | Name of IAM instance profile |\n | this\\_iam\\_instance\\_profile\\_path | Path of IAM instance profile |\n---\nmodules/iam-assumable-role/main.tf\n@@ -13,6 +13,15 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n type = \"Service\"\n identifiers = var.trusted_role_services\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_sts_externalid != null ? [true] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [var.role_sts_externalid]\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/outputs.tf\n@@ -32,3 +32,9 @@ output \"this_iam_instance_profile_path\" {\n description = \"Path of IAM instance profile\"\n value = element(concat(aws_iam_instance_profile.this.*.path, [\"\"]), 0)\n }\n+\n+output \"role_sts_externalid\" {\n+ description = \"STS ExternalId condition value to use with a role\"\n+ value = var.role_sts_externalid\n+}\n+\n---\nmodules/iam-assumable-role/variables.tf\n@@ -125,3 +125,9 @@ variable \"role_description\" {\n default = \"\"\n }\n \n+variable \"role_sts_externalid\" {\n+ description roles \"STS ExternalId condition value to use with a role (when MFA is not required)\"\n+ type = string\n+ default = null\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\n`iam-user`'s output ses_smtp_password is cannot access error.\r\n\r\n```zsh\r\nError: Unsupported attribute\r\n\r\n on .terraform/modules/iam_user_test/modules/iam-user/outputs.tf line 63, in output \"this_iam_access_key_ses_smtp_password\":\r\n 63: aws_iam_access_key.this.*.ses_smtp_password,\r\n\r\nThis object does not have an attribute named \"ses_smtp_password\".\r\n```\r\n\r\n## Motivation and Context\r\nCannot create iam-user.\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<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -64,7 +64,6 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | this\\_iam\\_access\\_key\\_id | The access key ID |\n | this\\_iam\\_access\\_key\\_key\\_fingerprint | The fingerprint of the PGP key used to encrypt the secret |\n | this\\_iam\\_access\\_key\\_secret | The access key secret |\n-| this\\_iam\\_access\\_key\\_ses\\_smtp\\_password | DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm |\n | this\\_iam\\_access\\_key\\_ses\\_smtp\\_password\\_v4 | The secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | this\\_iam\\_access\\_key\\_status | Active or Inactive. Keys are initially active, but can be made inactive by other means. |\n | this\\_iam\\_user\\_arn | The ARN assigned by AWS for this user |\n---\nmodules/iam-user/outputs.tf\n@@ -56,18 +56,6 @@ output \"this_iam_access_key_encrypted_secret\" {\n value = element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)\n }\n \n-output \"this_iam_access_key_ses_smtp_password\" {\n- description = \"DEPRECATED: The secret access key converted into | SES SMTP password by applying AWS's SigV2 conversion algorithm\"\n- value = element(\n- concat(\n- aws_iam_access_key.this.*.ses_smtp_password,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password,\n- [\"\"],\n- ),\n- 0,\n- )\n-}\n-\n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n value = element(\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -64,7 +64,6 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | this\\_iam\\_access\\_key\\_id | The access key ID |\n | this\\_iam\\_access\\_key\\_key\\_fingerprint | The fingerprint of the PGP key used to encrypt the secret |\n | this\\_iam\\_access\\_key\\_secret | The access key secret |\n-| this\\_iam\\_access\\_key\\_ses\\_smtp\\_password | DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm |\n | this\\_iam\\_access\\_key\\_ses\\_smtp\\_password\\_v4 | The secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | this\\_iam\\_access\\_key\\_status | Active or Inactive. Keys are initially active, but can be made inactive by other means. |\n | this\\_iam\\_user\\_arn | The ARN assigned by AWS for this user |\n---\nmodules/iam-user/outputs.tf\n@@ -56,18 +56,6 @@ output \"this_iam_access_key_encrypted_secret\" {\n value = element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)\n }\n \n-output \"this_iam_access_key_ses_smtp_password\" {\n- description = \"DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm\"\n- value = element(\n- concat(\n- aws_iam_access_key.this.*.ses_smtp_password,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password,\n- [\"\"],\n- ),\n- 0,\n- )\n-}\n-\n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password |\n applying AWS's Sigv4 conversion algorithm\"\n value = element(\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -64,7 +64,6 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | this\\_iam\\_access\\_key\\_id | The access key ID |\n | this\\_iam\\_access\\_key\\_key\\_fingerprint | The fingerprint of the PGP key used to encrypt the secret |\n | this\\_iam\\_access\\_key\\_secret | The access key secret |\n-| this\\_iam\\_access\\_key\\_ses\\_smtp\\_password | DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm |\n | this\\_iam\\_access\\_key\\_ses\\_smtp\\_password\\_v4 | The secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | this\\_iam\\_access\\_key\\_status | Active or Inactive. Keys are initially active, but can be made inactive by other means. |\n | this\\_iam\\_user\\_arn | The ARN assigned by AWS for this user |\n---\nmodules/iam-user/outputs.tf\n@@ -56,18 +56,6 @@ output \"this_iam_access_key_encrypted_secret\" {\n value = element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)\n }\n \n-output \"this_iam_access_key_ses_smtp_password\" {\n- description = \"DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm\"\n- value = element(\n- concat(\n- aws_iam_access_key.this.*.ses_smtp_password,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password,\n- [\"\"],\n- ),\n- 0,\n- )\n-}\n-\n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n value = element(\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -64,7 +64,6 @@ This module outputs commands and PGP messages which can be decrypted either usin\n | this\\_iam\\_access\\_key\\_id | The access key ID |\n | this\\_iam\\_access\\_key\\_key\\_fingerprint | The fingerprint of the PGP key used to encrypt the secret |\n | this\\_iam\\_access\\_key\\_secret | The access key secret |\n-| this\\_iam\\_access\\_key\\_ses\\_smtp\\_password | DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm |\n | this\\_iam\\_access\\_key\\_ses\\_smtp\\_password\\_v4 | The secret access key converted into an SES by password by applying AWS's Sigv4 conversion algorithm |\n | this\\_iam\\_access\\_key\\_status | Active or Inactive. Keys are initially active, but can be made inactive by other means. |\n | this\\_iam\\_user\\_arn | The ARN assigned by AWS for this user |\n---\nmodules/iam-user/outputs.tf\n@@ -56,18 +56,6 @@ output \"this_iam_access_key_encrypted_secret\" {\n value = element(concat(aws_iam_access_key.this.*.encrypted_secret, [\"\"]), 0)\n }\n \n-output \"this_iam_access_key_ses_smtp_password\" {\n- description = \"DEPRECATED: The secret access key converted into an SES SMTP password by applying AWS's SigV2 conversion algorithm\"\n- value = element(\n- concat(\n- aws_iam_access_key.this.*.ses_smtp_password,\n- aws_iam_access_key.this_no_pgp.*.ses_smtp_password,\n- [\"\"],\n- ),\n- 0,\n- )\n-}\n-\n output \"this_iam_access_key_ses_smtp_password_v4\" {\n description = \"The secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n value = element(\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\r\nBased on #86 \r\n\n\n---\n\nChoice A:\nmodules/iam-account/README.md\n@@ -26,14 +26,14 @@ Import successful!\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name |\n Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -11,14 +11,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -11,14 +11,14 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with specified IAM policies, and add users into a group.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM policy.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/README.md\n@@ -23,14 +23,14 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.50 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.50 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-account/README.md\n@@ -26,14 +26,14 @@ Import successful!\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -11,14 +11,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -11,14 +11,14 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with specified IAM policies, and add users into a group.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM policy.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/README.md\n@@ -23,14 +23,14 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.50 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.50 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-account/README.md\n@@ -26,14 +26,14 @@ Import successful!\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -11,14 +11,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -11,14 +11,14 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = 2.23, 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with specified IAM policies, and add users into a group.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM policy.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/README.md\n@@ -23,14 +23,14 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.50 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.50 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-account/README.md\n@@ -26,14 +26,14 @@ Import successful!\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -11,14 +11,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= Providers\n < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/README.md\n@@ -11,14 +11,14 @@ Creates predefined IAM roles (admin, poweruser and readonly) which can be assume\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/README.md\n@@ -9,14 +9,14 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with users who are allowed to assume IAM roles. This is typica\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/README.md\n@@ -7,14 +7,14 @@ Creates IAM group with specified IAM policies, and add users into a group.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/README.md\n@@ -7,14 +7,14 @@ Creates IAM policy.\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.23 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.23 |\n+| aws | >= 2.23, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/README.md\n@@ -23,14 +23,14 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n-| aws | ~> 2.50 |\n+| terraform | >= 0.12.6, < 0.14 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.50 |\n+| aws | >= 2.50, < 4.0 |\n \n ## Inputs\n \n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\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\nTerraform v0.13 feature count on modules.\r\nAdditionally, AWS provider v3.0 is released and should be supported.\r\n\r\n## Motivation and Context\r\nMany of us have already upgraded to Terraform 0.13 and this module is incompatible.\r\n\r\n## Breaking Changes\r\n[Terraform](https://github.com/hashicorp/terraform/releases/tag/v0.13.0)\r\n[AWS provider](https://github.com/terraform-providers/terraform-provider-aws/releases/tag/v3.0.0)\r\n\r\n## How Has This Been Tested?\r\nAnecdotally tested with our Terraform Cloud setup.\r\n\r\n## Issues\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/84\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/85\n\n---\n\nChoice A:\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-account/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.23\"\n+ aws = \">= 2.23, < 4.0\"\n }\n }\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.50\"\n+ aws = \">= 2.50, < 4.0\"\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:\nby using the current partition instead of hardcoding \"aws\"\r\n\r\n## Description\r\nCurrently this module does not work in govcloud because it hardcodes \"arn:aws:...\", while govcloud uses ARNs of the form \"arn:aws-gov\". This changes to use the documented technique for getting the current partition.\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n\r\nI have verified in a local Xometry environment that this produces correct and working IAM role definitions for both govcloud and non-govcloud environments.\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\n 0\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\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\nOverride hard-coding of aws partition and use computed partition instead\r\n\r\n## Motivation and Context\r\nFor example this is an invalid ARN in govcloud:\r\n arn:aws:iam::431345505690:oidc-provider/oidc.eks.us-gov-east-1.amazonaws.com/id/xyz\r\nThis is valid:\r\n arn:aws-us-gov:iam::431345505690:oidc-provider/oidc.eks.us-gov-east-1.amazonaws.com/id/xyz\r\n\r\nNote that this computed partition is used elsewhere within this module, but has been overlooked here.\r\n\r\n## Breaking Changes\r\nno\r\n\r\n## How Has This Been Tested?\r\nhave tested the equivalent logic locally by using terraform's replace() function around the results of this module\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ \"aws_iam_policy_document\" \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 +18,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n+\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n@@ -16,7 \"aws_partition\" @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n type = \"Federated\"\n \n identifiers = [\n- \"arn:aws:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${var.provider_url}\"\n ]\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:\nThis allows using one role with multiple OIDC providers, for example\nwhen you want to use a single role across multiple EKS clusters.\n\nDeprecates provider_url in favor of provider_urls which allows\nspecifying more than 1 provider URL. Existing behavior is retained, and\nboth options can be specified.\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role {\n | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Deprecated, use `provider_urls`. | `string` | \"\" | yes |\n+| provider\\_urls | List of OIDC Provider URLs | `list(string)` | [] | yes |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Deprecated. Use provider_urls instead.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Deprecated, use `provider_urls`. | `string` | \"\" | yes |\n+| provider\\_urls | List of OIDC Provider URLs | `list(string)` | [] | yes |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Deprecated. Use provider_urls instead.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Deprecated, use `provider_urls`. | `string` | \"\" | yes |\n+| provider\\_urls | List of OIDC Provider URLs | `list(string)` | [] | yes |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Deprecated. Use provider_urls instead.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n-| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider | `string` | `\"\"` | no |\n+| aws\\_account\\_id | The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider | `string` | `\"\"` | no |\n | create\\_role | Whether to create a role | `bool` | `false` | no |\n | force\\_detach\\_policies | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n | max\\_session\\_duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `3600` | no |\n | oidc\\_fully\\_qualified\\_subjects | The fully qualified OIDC subjects to be added to the role policy | `set(string)` | `[]` | no |\n | oidc\\_subjects\\_with\\_wildcards | The OIDC subject using wildcards to be added to the role policy | `set(string)` | `[]` | no |\n-| provider\\_url | URL of the OIDC Provider | `string` | n/a | yes |\n+| provider\\_url | URL of the OIDC Provider. Deprecated, use `provider_urls`. | `string` | \"\" | yes |\n+| provider\\_urls | List of OIDC Provider URLs | `list(string)` | [] | yes |\n | role\\_name | IAM role name | `string` | `\"\"` | no |\n | role\\_path | Path of IAM role | `string` | `\"/\"` | no |\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM policies | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -1,6 +1,14 @@\n locals {\n aws_account_id = var.aws_account_id != \"\" ? var.aws_account_id : data.aws_caller_identity.current.account_id\n- provider_url = replace(var.provider_url, \"https://\", \"\")\n+ # clean URLs of https:// prefix\n+ urls = [\n+ for url in distinct(concat(var.provider_urls, [var.provider_url])) :\n+ replace(url, \"https://\", \"\")\n+ ]\n+ identifiers = [\n+ for url in local.urls :\n+ \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${url}\"\n+ ]\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -18,26 +26,24 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\n- \"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${local.provider_url}\"\n- ]\n+ identifiers = local.identifiers\n }\n \n dynamic \"condition\" {\n- for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []\n+ for_each = length(var.oidc_fully_qualified_subjects) > 0 ? local.urls : []\n content {\n test = \"StringEquals\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_fully_qualified_subjects\n }\n }\n \n \n dynamic \"condition\" {\n- for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []\n+ for_each = length(var.oidc_subjects_with_wildcards) > 0 ? local.urls : []\n content {\n test = \"StringLike\"\n- variable = \"${local.provider_url}:sub\"\n+ variable = \"${condition.value}:sub\"\n values = var.oidc_subjects_with_wildcards\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -5,12 +5,19 @@ variable \"create_role\" {\n }\n \n variable \"provider_url\" {\n- description = \"URL of the OIDC Provider\"\n+ description = \"URL of the OIDC Provider. Deprecated. Use provider_urls instead.\"\n type = string\n+ default = \"\"\n+}\n+\n+variable \"provider_urls\" {\n+ description = \"List of URLs of the OIDC Providers\"\n+ type = list(string)\n+ default = []\n }\n \n variable \"aws_account_id\" {\n- description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider\"\n+ description = \"The AWS account ID where the OIDC provider lives, leave empty to use the account for the AWS provider\"\n type = string\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\nAdd support for inline policies in addition to custom policy arns.\r\n\r\n## Motivation and Context\r\nWe would like to migrate from our self maintained IAM modules to this one. The only missing feature is to support custom inline policy definitions. We don't want to maintain IAM policies, as long as they are not shared with multiple roles. Instead we would like to be able to add inline policies to a role with this module.\r\n\r\n## How Has This Been Tested?\r\nThis is in a state of a proposal. If you would like to add this feature, we would start to use this implementation in our workspaces and then describe the context on how this has been tested.\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -41,6 +41,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -56,6 +70,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -51,6 +51,17 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/main.tf\n@@ -46,6 +46,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.custom_role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -62,6 +76,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,17 @@ variable \"custom_role_policy_arns\" {\n = = []\n }\n \n+variable \"custom_role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -41,6 +41,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -56,6 +70,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -51,6 +51,17 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/main.tf\n@@ -46,6 +46,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n }\n }\n \n+data \"aws_iam_policy_document\" attach {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.custom_role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -62,6 +76,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,17 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -41,6 +41,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -56,6 +70,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -51,6 +51,17 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/main.tf\n@@ -46,6 +46,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.custom_role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -62,6 +76,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,17 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -41,6 +41,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -56,6 +70,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count = var.create_role && length(var.role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -51,6 +51,17 @@ variable \"role_policy_arns\" {\n default = []\n }\n \n+variable \"role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n variable \"oidc_fully_qualified_subjects\" {\n description = \"The fully qualified OIDC subjects to be added to the role policy\"\n type = set(string)\n---\nmodules/iam-assumable-role/main.tf\n@@ -46,6 +46,20 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"custom\" {\n+ count = var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ dynamic \"statement\" {\n+ for_each = var.custom_role_policy_statements\n+ content {\n+ sid = statement.value.sid\n+ actions = statement.value.actions\n+ effect = statement.value.effect\n+ resources = statement.value.resources\n+ }\n+ }\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -62,6 +76,14 @@ resource \"aws_iam_role\" \"this\" {\n tags = var.tags\n }\n \n+resource \"aws_iam_role_policy\" \"custom\" {\n+ count 0 var.create_role && length(var.custom_role_policy_statements) > 0 ? 1 : 0\n+\n+ role = aws_iam_role.this[0].name\n+ name_prefix = \"custom_\"\n+ policy = data.aws_iam_policy_document.custom[0].json\n+}\n+\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,17 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_policy_statements\" {\n+ description = \"List of inline policy statements to attach to IAM role\"\n+ type = list(object({\n+ sid = string\n+ actions = list(string)\n+ effect = string\n+ resources = list(string)\n+ }))\n+ default = []\n+}\n+\n # Pre-defined policies\n variable \"admin_role_policy_arn\" {\n description = \"Policy ARN to use for admin role\"\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\nAdd var to action to can fill out in module iam-assumable-role\r\n\r\n## Motivation and Context\r\nWe use github actions and the AWS action to get credentials need the sts:TagSession permission as you can read on:\r\nhttps://github.com/aws-actions/configure-aws-credentials/\r\n\r\n## Breaking Changes\r\nDoesn't apply\r\n\r\n## How Has This Been Tested?\r\nI tested this changes on my AWS account to ensure that works as I spected\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 IAM Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | trusted\\_role\\_services | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -2,7 +2,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type = \"AWS\"\n---\nmodules/iam-assumable-role/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"trusted_role_actions\" {\n+ description = \"Actions of STS\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\"]\n+}\n+\n variable \"trusted_role_arns\" {\n description = \"ARNs of AWS entities who can assume these roles\"\n type = list(string)\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | trusted\\_role\\_services | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -2,7 +2,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n roles\"\n {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type = \"AWS\"\n---\nmodules/iam-assumable-role/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"trusted_role_actions\" {\n+ description = \"Actions of STS\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\"]\n+}\n+\n variable \"trusted_role_arns\" {\n description = \"ARNs of AWS entities who can assume these roles\"\n type = list(string)\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | trusted\\_role\\_services | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -2,7 +2,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type = \"AWS\"\n---\nmodules/iam-assumable-role/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"trusted_role_actions\" {\n+ description = \"Actions of STS\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\"]\n+}\n+\n variable \"trusted_role_arns\" {\n description = \"ARNs of AWS entities who can assume these roles\"\n type = list(string)\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/README.md\n@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U\n | role\\_permissions\\_boundary\\_arn | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | role\\_requires\\_mfa | Whether role requires MFA | `bool` | `true` | no |\n | tags | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| trusted\\_role\\_actions | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n | trusted\\_role\\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n | trusted\\_role\\_services | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n---\nmodules/iam-assumable-role/main.tf\n@@ -2,7 +2,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n statement {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type = \"AWS\"\n---\nmodules/iam-assumable-role/variables.tf\n@@ -1,3 +1,9 @@\n+variable \"trusted_role_actions\" {\n+ description = \"Actions of STS\"\n+ type = list(string)\n+ default = [\"sts:AssumeRole\"]\n+}\n+\n variable \"trusted_role_arns\" {\n description = \"ARNs of AWS entities who can assume these roles\"\n type = list(string)\n---\n\n\n---\n" } ]
D