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\nThis PR addresses the permission issue when mounting the efs endpoint:\r\n b'mount.nfs4: access denied by server while mounting 127.0.0.1:/'\r\n\r\n```\r\nMessage: 'AWS credentials source used for IAM authentication: '\r\nArguments: ('webidentity:arn:aws:iam::012345678910:role/AWSIRSA_Platform_EFS_CSI_Driver,/var/run/secrets/eks.amazonaws.com/serviceaccount/token',)\r\nCould not start amazon-efs-mount-watchdog, unrecognized init system \"aws-efs-csi-dri\"\r\nb'mount.nfs4: access denied by server while mounting 127.0.0.1:/'\r\n```\r\n\r\nafter updating irsa efs policy by adding:\r\n```\r\n{\r\n \"Action\": [\r\n \"elasticfilesystem:ClientRootAccess\",\r\n \"elasticfilesystem:ClientWrite\",\r\n \"elasticfilesystem:ClientMount\"\r\n ],\r\n \"Condition\": {\r\n \"Bool\": {\r\n \"elasticfilesystem:AccessedViaMountTarget\": \"true\"\r\n }\r\n },\r\n \"Effect\": \"Allow\",\r\n \"Resource\": \"*\",\r\n \"Sid\": \"\"\r\n}\r\n```\r\n\r\nthe issue is fixed:\r\n\r\n```\r\nMessage: 'AWS credentials source used for IAM authentication: '\r\nArguments: ('webidentity:arn:aws:iam::012345678910:role/AWSIRSA_Platform_EFS_CSI_Driver,/var/run/secrets/eks.amazonaws.com/serviceaccount/token',)\r\nCould not start amazon-efs-mount-watchdog, unrecognized init system \"aws-efs-csi-dri\"\r\n```\r\n\r\nand the mount path is available.\r\n\r\n## Motivation and Context\r\nAllow IRSA efs role to mount efs targets\r\n\r\n## Breaking Changes\r\nno breaking changes\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -402,6 +402,20 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n values = [\"true\"]\n }\n }\n+\n+ statement {\n+ actions = [\n+ \"elasticfilesystem:ClientRootAccess\",\n+ \"elasticfilesystem:ClientWrite\",\n+ \"elasticfilesystem:ClientMount\",\n+ ]\n+ resources [\"*\"]\n+ condition {\n+ test = \"Bool\"\n+ variable = \"elasticfilesystem:AccessedViaMountTarget\"\n+ values = [\"true\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"efs_csi\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -402,6 +402,20 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n values = [\"true\"]\n }\n }\n+\n+ statement {\n+ actions = [\n+ \"elasticfilesystem:ClientRootAccess\",\n+ \"elasticfilesystem:ClientWrite\",\n+ \"elasticfilesystem:ClientMount\",\n+ ]\n+ resources = [\"*\"]\n+ condition {\n+ test = \"Bool\"\n+ variable = \"elasticfilesystem:AccessedViaMountTarget\"\n+ values = [\"true\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"efs_csi\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -402,6 +402,20 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n values = [\"true\"]\n }\n }\n+\n+ statement {\n+ actions = [\n+ \"elasticfilesystem:ClientRootAccess\",\n+ \"elasticfilesystem:ClientWrite\",\n+ \"elasticfilesystem:ClientMount\",\n+ ]\n+ resources = [\"*\"]\n+ condition {\n+ test = \"Bool\"\n+ variable = \"elasticfilesystem:AccessedViaMountTarget\"\n+ values = [\"true\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"efs_csi\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -402,6 +402,20 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n values = [\"true\"]\n }\n }\n+\n+ statement {\n+ actions = [\n+ \"elasticfilesystem:ClientRootAccess\",\n+ \"elasticfilesystem:ClientWrite\",\n+ \"elasticfilesystem:ClientMount\",\n+ ]\n+ resources = [\"*\"]\n+ condition {\n+ test = \"Bool\"\n+ variable = \"elasticfilesystem:AccessedViaMountTarget\"\n+ values = [\"true\"]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"efs_csi\" {\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 ability to assign a list of custom IAM Policies to selected IAM User during creation\r\n\r\n## Motivation and Context\r\nSometimes IAM Users require some elevation of privileges without including other groups. Also some projects should have a single user without a group, for example the `terraform` user with pre-existing policies to deploy resources. Does not make sense to create a group for this purpose, so the ability to add some policies to IAM User is a nice feature.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-user/README.md\n@@ -25,7 +25,9 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n \n ## Modules\n \n@@ -34,10 +36,13 @@ No providers.\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user4\"></a> [iam\\_user4](#module\\_iam\\_user4) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |\n \n ## Inputs\n \n@@ -64,4 +69,5 @@ No inputs.\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-user/main.tf\n@@ -46,3 +46,21 @@ module \"iam_user3\" {\n create_iam_access_key = true\n iam_access_key_status = \"Inactive\"\n }\n+\n+###################################################################\n+# IAM user with IAM policy attached\n+###################################################################\n+\n+data \"aws_iam_policy\" \"example\" {\n+ name = \"AmazonS3ReadOnlyAccess\"\n+}\n+\n+module \"iam_user4\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin6\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ policy_arns = [data.aws_iam_policy.example.arn]\n+}\n---\nexamples/iam-user/outputs.tf\n@@ -85,3 +85,8 @@ output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n value = module.iam_user.keybase_secret_key_pgp_message\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = module.iam_user.policy_arns\n+}\n---\nmodules/iam-user/README.md\n@@ -46,6 +46,7 @@ No modules.\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n@@ -63,6 +64,7 @@ No modules.\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n | <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_policy_arns\"></a> [policy\\_arns](#input\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user | `list(string)` | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -94,4 +96,5 @@ No modules.\n | <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n | <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/main.tf\n@@ -45,3 +45,10 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_user_policy_attachment\" \"this\" {\n+ for_each = var.create_user ? toset(var.policy_arns) : []\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/outputs.tf\n@@ -149,3 +149,8 @@ output \"iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].fingerprint, \"\")\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = [for policy_attachment in aws_iam_user_policy_attachment.this : policy_attachment.policy_arn]\n+}\n---\nmodules/iam-user/variables.tf\n@@ -81,6 +81,12 @@ variable \"permissions_boundary\" {\n default = \"\"\n }\n \n+variable \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to all resources.\"\n type = map(string)\n---\nwrappers/iam-user/main.tf\n@@ -17,5 +17,6 @@ module \"wrapper\" {\n ssh_key_encoding = try(each.value.ssh_key_encoding, var.defaults.ssh_key_encoding, \"SSH\")\n ssh_public_key = try(each.value.ssh_public_key, var.defaults.ssh_public_key, \"\")\n permissions_boundary = try(each.value.permissions_boundary, var.defaults.permissions_boundary, \"\")\n+ policy_arns = try(each.value.policy_arns, var.defaults.policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-user/README.md\n@@ -25,7 +25,9 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n \n ## Modules\n \n@@ -34,10 +36,13 @@ No providers.\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user4\"></a> [iam\\_user4](#module\\_iam\\_user4) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |\n \n ## Inputs\n \n@@ -64,4 +69,5 @@ No inputs.\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-user/main.tf\n@@ -46,3 +46,21 @@ module \"iam_user3\" {\n create_iam_access_key = true\n iam_access_key_status = \"Inactive\"\n }\n+\n+###################################################################\n+# IAM user with IAM policy attached\n+###################################################################\n+\n+data \"aws_iam_policy\" \"example\" {\n+ name = \"AmazonS3ReadOnlyAccess\"\n+}\n+\n+module \"iam_user4\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin6\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ policy_arns = [data.aws_iam_policy.example.arn]\n+}\n---\nexamples/iam-user/outputs.tf\n@@ -85,3 +85,8 @@ output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n value = module.iam_user.keybase_secret_key_pgp_message\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = module.iam_user.policy_arns\n+}\n---\nmodules/iam-user/README.md\n@@ -46,6 +46,7 @@ No modules.\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n@@ -63,6 +64,7 @@ No modules.\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n | <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_policy_arns\"></a> [policy\\_arns](#input\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user | `list(string)` | `[]` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -94,4 +96,5 @@ No modules.\n | <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n | <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/main.tf\n@@ -45,3 +45,10 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_user_policy_attachment\" \"this\" {\n+ for_each = var.create_user ? toset(var.policy_arns) : []\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/outputs.tf\n@@ -149,3 +149,8 @@ output \"iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].fingerprint, \"\")\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = [for policy_attachment in aws_iam_user_policy_attachment.this : policy_attachment.policy_arn]\n+}\n---\nmodules/iam-user/variables.tf\n@@ -81,6 +81,12 @@ variable \"permissions_boundary\" {\n default = \"\"\n }\n \n+variable \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to all resources.\"\n type = map(string)\n---\nwrappers/iam-user/main.tf\n@@ -17,5 +17,6 @@ module \"wrapper\" {\n ssh_key_encoding = try(each.value.ssh_key_encoding, var.defaults.ssh_key_encoding, \"SSH\")\n ssh_public_key = try(each.value.ssh_public_key, var.defaults.ssh_public_key, \"\")\n permissions_boundary = try(each.value.permissions_boundary, var.defaults.permissions_boundary, \"\")\n+ policy_arns = try(each.value.policy_arns, var.defaults.policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-user/README.md\n@@ -25,7 +25,9 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n \n ## Modules\n \n@@ -34,10 +36,13 @@ No providers.\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user4\"></a> [iam\\_user4](#module\\_iam\\_user4) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |\n \n ## Inputs\n \n@@ -64,4 +69,5 @@ No inputs.\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-user/main.tf\n@@ -46,3 +46,21 @@ module \"iam_user3\" {\n create_iam_access_key = true\n iam_access_key_status = \"Inactive\"\n }\n+\n+###################################################################\n+# IAM user with IAM policy attached\n+###################################################################\n+\n+data \"aws_iam_policy\" \"example\" {\n+ name = \"AmazonS3ReadOnlyAccess\"\n+}\n+\n+module \"iam_user4\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin6\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ policy_arns = [data.aws_iam_policy.example.arn]\n+}\n---\nexamples/iam-user/outputs.tf\n@@ -85,3 +85,8 @@ output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n value = module.iam_user.keybase_secret_key_pgp_message\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = module.iam_user.policy_arns\n+}\n---\nmodules/iam-user/README.md\n@@ -46,6 +46,7 @@ No modules.\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n@@ -63,6 +64,7 @@ No modules.\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n | <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_policy_arns\"></a> [policy\\_arns](#input\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user | `list(string)` | `[]` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -94,4 +96,5 @@ No modules.\n | <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n | <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/main.tf\n@@ -45,3 +45,10 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = }\n+\n+resource \"aws_iam_user_policy_attachment\" \"this\" {\n+ for_each = var.create_user ? toset(var.policy_arns) : []\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/outputs.tf\n@@ -149,3 +149,8 @@ output \"iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].fingerprint, \"\")\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = [for policy_attachment in aws_iam_user_policy_attachment.this : policy_attachment.policy_arn]\n+}\n---\nmodules/iam-user/variables.tf\n@@ -81,6 +81,12 @@ variable \"permissions_boundary\" {\n default = \"\"\n }\n \n+variable \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add to all resources.\"\n type = map(string)\n---\nwrappers/iam-user/main.tf\n@@ -17,5 +17,6 @@ module \"wrapper\" {\n ssh_key_encoding = try(each.value.ssh_key_encoding, var.defaults.ssh_key_encoding, \"SSH\")\n ssh_public_key = try(each.value.ssh_public_key, var.defaults.ssh_public_key, \"\")\n permissions_boundary = try(each.value.permissions_boundary, var.defaults.permissions_boundary, \"\")\n+ policy_arns = try(each.value.policy_arns, var.defaults.policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-user/README.md\n@@ -25,7 +25,9 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n \n ## Modules\n \n@@ -34,10 +36,13 @@ No providers.\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user4\"></a> [iam\\_user4](#module\\_iam\\_user4) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |\n \n ## Inputs\n \n@@ -64,4 +69,5 @@ No inputs.\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nexamples/iam-user/main.tf\n@@ -46,3 +46,21 @@ module \"iam_user3\" {\n create_iam_access_key = true\n iam_access_key_status = \"Inactive\"\n }\n+\n+###################################################################\n+# IAM user with IAM policy attached\n+###################################################################\n+\n+data \"aws_iam_policy\" \"example\" {\n+ name = \"AmazonS3ReadOnlyAccess\"\n+}\n+\n+module \"iam_user4\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin6\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ policy_arns = [data.aws_iam_policy.example.arn]\n+}\n---\nexamples/iam-user/outputs.tf\n@@ -85,3 +85,8 @@ output \"keybase_secret_key_pgp_message\" {\n description = \"Encrypted access secret key\"\n value = module.iam_user.keybase_secret_key_pgp_message\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = module.iam_user.policy_arns\n+}\n---\nmodules/iam-user/README.md\n@@ -46,6 +46,7 @@ No modules.\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n@@ -63,6 +64,7 @@ No modules.\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n | <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_policy_arns\"></a> [policy\\_arns](#input\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user | `list(string)` | `[]` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -94,4 +96,5 @@ No modules.\n | <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n | <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n+| <a name=\"output_policy_arns\"></a> [policy\\_arns](#output\\_policy\\_arns) | The list of ARNs of policies directly assigned to the IAM user |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/main.tf\n@@ -45,3 +45,10 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_user_policy_attachment\" \"this\" {\n+ for_each = var.create_user ? toset(var.policy_arns) : []\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/outputs.tf\n@@ -149,3 +149,8 @@ output \"iam_user_ssh_key_fingerprint\" {\n description = \"The MD5 message digest of the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].fingerprint, \"\")\n }\n+\n+output \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ value = [for policy_attachment in aws_iam_user_policy_attachment.this : policy_attachment.policy_arn]\n+}\n---\nmodules/iam-user/variables.tf\n@@ -81,6 +81,12 @@ variable \"permissions_boundary\" {\n default = \"\"\n }\n \n+variable \"policy_arns\" {\n+ description = \"The list of ARNs of policies directly assigned to the IAM user\"\n+ type = list(string)\n+ default = []\n+}\n+\n +85,8 \"tags\" {\n description = \"A map of tags to add to all resources.\"\n type = map(string)\n---\nwrappers/iam-user/main.tf\n@@ -17,5 +17,6 @@ module \"wrapper\" {\n ssh_key_encoding = try(each.value.ssh_key_encoding, var.defaults.ssh_key_encoding, \"SSH\")\n ssh_public_key = try(each.value.ssh_public_key, var.defaults.ssh_public_key, \"\")\n permissions_boundary = try(each.value.permissions_boundary, var.defaults.permissions_boundary, \"\")\n+ policy_arns = try(each.value.policy_arns, var.defaults.policy_arns, [])\n tags = try(each.value.tags, var.defaults.tags, {})\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdding the ability for role session name condition on assumable role with oidc module.\r\nUsed as a dependency the PR that added this functionality to assumable role - #379.\r\n\r\n## Motivation and Context\r\nI am using this module and this condition is missing for my use case.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n <a <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -80,6 +80,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed.\"\n+ type = list(string)\n+ default = [\"\"]\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -80,6 +80,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_fully_qualified_audiences\n }\n dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed.\"\n+ type = list(string)\n+ default = [\"\"]\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -80,6 +80,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed.\"\n+ type = list(string)\n+ default = [\"\"]\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| name=\"input_role_policy_arns\"></a> name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -80,6 +80,16 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n values = var.oidc_fully_qualified_audiences\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed.\"\n+ type = list(string)\n+ default = [\"\"]\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:\nAs per AWS customer notifications, the `elasticloadbalancing:AddTags` permission will be required soon for anyone calling `CreateLoadBalancer` with tags:\n\n> On June 1, 2023, we will be adding an additional layer of security to ELB ‘Create*' API calls where API callers must have explicit access to add tags in their Identity and Access Management (IAM) policy [1]. Currently, access to attach tags was implicitly granted with access to 'Create*' APIs. … We will be allowing 'Create*' API calls with the current policy to be accepted until August 30, 2023. After this date, the 'Create*' API call will fail and return an error if the the attribute is specified and permission is not granted.\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -839,6 +839,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -853,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n {\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -839,6 +839,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -853,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -839,6 +839,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -853,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ +839,7 \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -839,6 +839,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateLoadBalancer\",\n \"elasticloadbalancing:CreateTargetGroup\",\n ]\n@@ -853,6 +854,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \n statement {\n actions = [\n+ \"elasticloadbalancing:AddTags\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:CreateListener\",\n \"elasticloadbalancing:DeleteListener\",\n \"elasticloadbalancing:CreateRule\",\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\nEnable users to set `source_policy_documents` on the assume role policy.\r\n\r\n\r\n## Motivation and Context\r\nFixes #361.\r\n\r\nAs I'm creating IAM OIDC roles, I need to be able to test them by assuming them. Using `source_policies` is the most generic implem, so other use cases might also benefit this.\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -26,9 +26,9 @@ module \"iam_assumable_role_admin\" {\n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n \n-#####################################\n-# IAM assumable role with self assume\n-#####################################\n+################################################################\n+# IAM assumable role with self assume and assume from Admin role\n+################################################################\n module \"iam_assumable_role_self_assume\" {\n source = \"../../modules/iam-assumable-role-with-oidc\"\n \n@@ -37,6 +37,15 @@ module \"iam_assumable_role_self_assume\" {\n \n role_name = \"role-with-oidc-self-assume\"\n \n+ assume_role_source_policies = [jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [{\n+ Effect = \"Allow\"\n+ Action = [\"sts:AssumeRole\"]\n+ Principal = { AWS = [\"arn:aws:iam::012345678901:role/Admin\"] }\n+ }]\n+ })]\n+\n tags = {\n Role = \"role-with-oidc-self-assume\"\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_source_policies\"></a> [assume\\_role\\_source\\_policies](#input\\_assume\\_role\\_source\\_policies) | JSON blobs to use as source\\_policy\\_documents for the assume role policy | `list(string)` | `[]` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -16,6 +16,8 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n+ source_policy_documents = var.assume_role_source_policies\n+\n with \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_source_policies\" {\n+ description = \"JSON blobs to use as source_policy_documents for the assume role policy\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -21,4 +21,5 @@ module \"wrapper\" {\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n+ assume_role_source_policies = try(each.value.assume_role_source_policies, var.defaults.assume_role_source_policies, [])\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -26,9 +26,9 @@ module \"iam_assumable_role_admin\" {\n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n \n-#####################################\n-# IAM assumable role with self assume\n-#####################################\n+################################################################\n+# IAM assumable role with self assume and assume from Admin role\n+################################################################\n module \"iam_assumable_role_self_assume\" {\n source = \"../../modules/iam-assumable-role-with-oidc\"\n \n@@ -37,6 +37,15 @@ module \"iam_assumable_role_self_assume\" {\n \n role_name = \"role-with-oidc-self-assume\"\n \n+ assume_role_source_policies = [jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [{\n+ Effect = \"Allow\"\n+ Action = [\"sts:AssumeRole\"]\n+ Principal = { AWS = [\"arn:aws:iam::012345678901:role/Admin\"] }\n+ }]\n+ })]\n+\n tags = {\n Role = \"role-with-oidc-self-assume\"\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_source_policies\"></a> [assume\\_role\\_source\\_policies](#input\\_assume\\_role\\_source\\_policies) | JSON blobs to -16,6 as source\\_policy\\_documents for the assume role policy | `list(string)` | `[]` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -16,6 +16,8 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n+ source_policy_documents = var.assume_role_source_policies\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_source_policies\" {\n+ description = \"JSON blobs to use as source_policy_documents for the assume role policy\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -21,4 +21,5 @@ module \"wrapper\" {\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n+ assume_role_source_policies = try(each.value.assume_role_source_policies, var.defaults.assume_role_source_policies, [])\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -26,9 +26,9 @@ module \"iam_assumable_role_admin\" {\n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n \n-#####################################\n-# IAM assumable role with self assume\n-#####################################\n+################################################################\n+# IAM assumable role with self assume and assume from Admin role\n+################################################################\n module \"iam_assumable_role_self_assume\" {\n source = \"../../modules/iam-assumable-role-with-oidc\"\n \n@@ -37,6 +37,15 @@ module \"iam_assumable_role_self_assume\" {\n \n role_name = \"role-with-oidc-self-assume\"\n \n+ assume_role_source_policies = [jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [{\n+ Effect = \"Allow\"\n+ Action = [\"sts:AssumeRole\"]\n+ Principal = { AWS = [\"arn:aws:iam::012345678901:role/Admin\"] }\n+ }]\n+ })]\n+\n tags = {\n Role = \"role-with-oidc-self-assume\"\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_source_policies\"></a> [assume\\_role\\_source\\_policies](#input\\_assume\\_role\\_source\\_policies) | JSON blobs to use as source\\_policy\\_documents for the assume role policy | `list(string)` | `[]` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -16,6 +16,8 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n+ source_policy_documents = var.assume_role_source_policies\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_source_policies\" {\n+ description = \"JSON blobs to use as source_policy_documents for the assume role policy\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -21,4 +21,5 @@ module \"wrapper\" {\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n+ assume_role_source_policies = try(each.value.assume_role_source_policies, var.defaults.assume_role_source_policies, [])\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -26,9 +26,9 @@ module \"iam_assumable_role_admin\" {\n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n \n-#####################################\n-# IAM assumable role with self assume\n-#####################################\n+################################################################\n+# IAM assumable role with self assume and assume from Admin role\n+################################################################\n module \"iam_assumable_role_self_assume\" {\n source = \"../../modules/iam-assumable-role-with-oidc\"\n \n@@ -37,6 +37,15 @@ module \"iam_assumable_role_self_assume\" {\n \n role_name = \"role-with-oidc-self-assume\"\n \n+ assume_role_source_policies = [jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [{\n+ Effect = \"Allow\"\n+ Action = [\"sts:AssumeRole\"]\n+ Principal = { AWS = [\"arn:aws:iam::012345678901:role/Admin\"] }\n+ }]\n+ })]\n+\n tags = {\n Role = \"role-with-oidc-self-assume\"\n }\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_source_policies\"></a> [assume\\_role\\_source\\_policies](#input\\_assume\\_role\\_source\\_policies) | JSON blobs to use as source\\_policy\\_documents for the assume role policy | `list(string)` | `[]` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -16,6 +16,8 @@ data \"aws_partition\" \"current\" {}\n data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n count = var.create_role ? 1 : 0\n \n+ source_policy_documents = var.assume_role_source_policies\n+\n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n for_each = var.allow_self_assume_role ? [1] : []\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_source_policies\" {\n+ description = \"JSON blobs to use as source_policy_documents for the assume role policy\"\n+ type = list(string)\n+ default = []\n+}\n---\nwrappers/iam-assumable-role-with-oidc/main.tf\n@@ -21,4 +21,5 @@ module {\n oidc_fully_qualified_audiences = try(each.value.oidc_fully_qualified_audiences, var.defaults.oidc_fully_qualified_audiences, [])\n force_detach_policies = try(each.value.force_detach_policies, var.defaults.force_detach_policies, false)\n allow_self_assume_role = try(each.value.allow_self_assume_role, var.defaults.allow_self_assume_role, false)\n+ assume_role_source_policies = try(each.value.assume_role_source_policies, var.defaults.assume_role_source_policies, [])\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\nTrying to set as a requirement the parameter role_session_name when a user assumes a role I found that someone created an [issue](https://github.com/terraform-aws-modules/terraform-aws-iam/issues/359) but it has been closed. I need this feature, so I implemented this MR.\r\nI hope this will be useful for the community.\r\n\r\n\r\n## Motivation and Context\r\nThe purpose of this condition is to make easier track the user actions when viewing AWS CloudTrail logs, as described in this [AWS post](https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\r\n\r\n\r\n## Breaking Changes\r\nNothing\r\n\r\n## How Has This Been Tested?\r\nI tested this locally in my environment and it works great. To test this, you need to set your username as role_session_name when assuming the role. If you don´t set your username as this variable, the assumerole will fail.\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role/README.md\n@@ -62,6 +62,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -117,6 +117,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ your }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -154,3 +154,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/README.md\n@@ -62,6 +62,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -117,6 +117,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n values = local.role_sts_externalid\n }\n `false` }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -154,3 +154,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/README.md\n@@ -62,6 +62,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -117,6 +117,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -154,3 +154,15 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/README.md\n@@ -62,6 +62,8 @@ No modules.\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n+| <a name=\"input_role_requires_session_name\"></a> [role\\_requires\\_session\\_name](#input\\_role\\_requires\\_session\\_name) | Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/) | `bool` | `false` | no |\n+| <a name=\"input_role_session_name\"></a> [role\\_session\\_name](#input\\_role\\_session\\_name) | role\\_session\\_name for roles which require this parameter when being assumed. By default, you need to set your own username as role\\_session\\_name | `list(string)` | <pre>[<br> \"${aws:username}\"<br>]</pre> | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n | <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Actions of STS | `list(string)` | <pre>[<br> \"sts:AssumeRole\"<br>]</pre> | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -117,6 +117,15 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n values = local.role_sts_externalid\n }\n }\n+\n+ dynamic \"condition\" {\n+ for_each = var.role_requires_session_name ? [1] : []\n+ content {\n+ test = \"StringEquals\"\n+ variable = \"sts:RoleSessionName\"\n+ values = var.role_session_name\n+ }\n+ }\n }\n }\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -154,3 +154,15 @@ variable \"allow_self_assume_role\" {\n assuming type = bool\n default = false\n }\n+\n+variable \"role_requires_session_name\" {\n+ description = \"Determines if the role-session-name variable is needed when assuming a role(https://aws.amazon.com/blogs/security/easily-control-naming-individual-iam-role-sessions/)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"role_session_name\" {\n+ description = \"role_session_name for roles which require this parameter when being assumed. By default, you need to set your own username as role_session_name\"\n+ type = list(string)\n+ default = [\"$${aws:username}\"]\n+}\n---\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\nAs of #349 a pretty large security vulnerability was introduced to the `iam-role-for-service-accounts-eks` module that by default allows full decryption off all KMS keys within the account that it's implemented in. In the release notes it was noted as a fix and not a new feature. For the naked eye this can indicate that it's a fix in some existing feature that they might not be using, when the reality is that it opened up a backdoor to all KMS keys if you use the External Secrets 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\nI've changed the default here to be an empty array to focus on closing this security vulnerability first. I'll try to make some time to implement the condition object to the `kms:decrypt` statement later on. \r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nThis might be a breaking changes for those that have already implemented the security vulnerability and should be noted as such in the release documentation. \r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,7 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n-| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | `[]` | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -461,11 +461,14 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -167,7 +167,7 @@ variable \"external_secrets_secrets_manager_arns\" {\n variable \"external_secrets_kms_key_arns\" {\n description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n type = list(string)\n- default = [\"arn:aws:kms:*:*:key/*\"]\n+ default = []\n }\n \n # FSx Lustre CSI\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,7 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) actions Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n-| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | `[]` | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -461,11 +461,14 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -167,7 +167,7 @@ variable \"external_secrets_secrets_manager_arns\" {\n variable \"external_secrets_kms_key_arns\" {\n description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n type = list(string)\n- default = [\"arn:aws:kms:*:*:key/*\"]\n+ default = []\n }\n \n # FSx Lustre CSI\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,7 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n-| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | `[]` | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -461,11 +461,14 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- actions = [\n- \"kms:Decrypt\"\n- ]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -167,7 +167,7 @@ variable \"external_secrets_secrets_manager_arns\" {\n variable \"external_secrets_kms_key_arns\" {\n description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to | using External Secrets\"\n type = list(string)\n- default = [\"arn:aws:kms:*:*:key/*\"]\n+ default = []\n }\n \n # FSx Lustre CSI\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,7 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n-| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | `[]` | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -461,11 +461,14 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_secrets_manager_arns\n }\n \n- statement {\n- variable actions = [\n- \"kms:Decrypt\"\n- ]\n- resources = var.external_secrets_kms_key_arns\n+ dynamic \"statement\" {\n+ for_each = length(var.external_secrets_kms_key_arns) > 0 ? [1] : []\n+ content {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -167,7 +167,7 @@ variable \"external_secrets_secrets_manager_arns\" {\n variable \"external_secrets_kms_key_arns\" {\n description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n type = list(string)\n- default = [\"arn:aws:kms:*:*:key/*\"]\n+ default = []\n }\n \n # FSx Lustre CSI\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis is an update to the readme to clarify that _two_ parameters are needed for a fully functional autoscaler.\r\n\r\n## Motivation and Context\r\nI got bit by only providing `attach_cluster_autoscaler_policy` and not providing `cluster_autoscaler_cluster_ids`. The result was my auto scaler deployed, but it couldn't scale anything.\r\n\r\n## Breaking Changes\r\nN/A\r\n\r\n## How Has This Been Tested?\r\nN/A\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -187,7 +187,7 @@ No modules.\n | <a name=\"input_attach_appmesh_controller_policy\"></a> [attach\\_appmesh\\_controller\\_policy](#input\\_attach\\_appmesh\\_controller\\_policy) | Determines whether to attach the attach Controller policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_appmesh_envoy_proxy_policy\"></a> [attach\\_appmesh\\_envoy\\_proxy\\_policy](#input\\_attach\\_appmesh\\_envoy\\_proxy\\_policy) | Determines whether to attach the Appmesh envoy proxy policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_cert_manager_policy\"></a> [attach\\_cert\\_manager\\_policy](#input\\_attach\\_cert\\_manager\\_policy) | Determines whether to attach the Cert Manager IAM policy to the role | `bool` | `false` | no |\n-| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n+| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role. Both this and [cluster\\_autoscaler\\_cluster\\_ids](#input\\_cluster\\_autoscaler\\_cluster\\_ids) must be set for a fully functional autoscaler. | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_efs_csi_policy\"></a> [attach\\_efs\\_csi\\_policy](#input\\_attach\\_efs\\_csi\\_policy) | Determines whether to attach the EFS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -187,7 +187,7 @@ No modules.\n | <a name=\"input_attach_appmesh_controller_policy\"></a> [attach\\_appmesh\\_controller\\_policy](#input\\_attach\\_appmesh\\_controller\\_policy) | Determines whether to attach the Appmesh Controller policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_appmesh_envoy_proxy_policy\"></a> [attach\\_appmesh\\_envoy\\_proxy\\_policy](#input\\_attach\\_appmesh\\_envoy\\_proxy\\_policy) | Determines whether to attach the Appmesh envoy proxy policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_cert_manager_policy\"></a> [attach\\_cert\\_manager\\_policy](#input\\_attach\\_cert\\_manager\\_policy) | Determines whether to attach the Cert Manager IAM policy to the role | `bool` | `false` | no |\n-| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster | IAM policy to the role | `bool` | `false` | no |\n+| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role. Both this and [cluster\\_autoscaler\\_cluster\\_ids](#input\\_cluster\\_autoscaler\\_cluster\\_ids) must be set for a fully functional autoscaler. | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_efs_csi_policy\"></a> [attach\\_efs\\_csi\\_policy](#input\\_attach\\_efs\\_csi\\_policy) | Determines whether to attach the EFS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -187,7 +187,7 @@ No modules.\n | <a name=\"input_attach_appmesh_controller_policy\"></a> [attach\\_appmesh\\_controller\\_policy](#input\\_attach\\_appmesh\\_controller\\_policy) CSI Determines whether to attach the Appmesh Controller policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_appmesh_envoy_proxy_policy\"></a> [attach\\_appmesh\\_envoy\\_proxy\\_policy](#input\\_attach\\_appmesh\\_envoy\\_proxy\\_policy) | Determines whether to attach the Appmesh envoy proxy policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_cert_manager_policy\"></a> [attach\\_cert\\_manager\\_policy](#input\\_attach\\_cert\\_manager\\_policy) | Determines whether to attach the Cert Manager IAM policy to the role | `bool` | `false` | no |\n-| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n+| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role. Both this and [cluster\\_autoscaler\\_cluster\\_ids](#input\\_cluster\\_autoscaler\\_cluster\\_ids) must be set for a fully functional autoscaler. | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_efs_csi_policy\"></a> [attach\\_efs\\_csi\\_policy](#input\\_attach\\_efs\\_csi\\_policy) | Determines whether to attach the EFS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -187,7 +187,7 @@ No modules.\n | <a name=\"input_attach_appmesh_controller_policy\"></a> [attach\\_appmesh\\_controller\\_policy](#input\\_attach\\_appmesh\\_controller\\_policy) | Determines whether to attach the Appmesh Controller policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_appmesh_envoy_proxy_policy\"></a> [attach\\_appmesh\\_envoy\\_proxy\\_policy](#input\\_attach\\_appmesh\\_envoy\\_proxy\\_policy) | Determines whether to attach the Appmesh envoy proxy policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_cert_manager_policy\"></a> [attach\\_cert\\_manager\\_policy](#input\\_attach\\_cert\\_manager\\_policy) | Determines whether to attach the Cert Manager IAM policy to the role | `bool` | `false` | no |\n-| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n+| <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role. Both this and [cluster\\_autoscaler\\_cluster\\_ids](#input\\_cluster\\_autoscaler\\_cluster\\_ids) must be set for a fully functional autoscaler. | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_efs_csi_policy\"></a> [attach\\_efs\\_csi\\_policy](#input\\_attach\\_efs\\_csi\\_policy) | Determines whether to attach the EFS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\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\nUse http datasource to retrieve keys from non-keybase urls (like keys.openpgp.org)\r\n\r\n## Motivation and Context\r\nAllows alternatives to keybase, without needing to hardcode pgp keys\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -2,16 +2,21 @@\n \n Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user public key. All of these are optional resources.\n \n-## Notes for keybase users\n-\n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+## PGP encryption\n \n-When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n+To encrypt passwords and access keys, provide a PGP key to `pgp_key` variable in one of three formats. \n+1. Keybase hosted public key: `keybase:username`\n+2. Generic HTTP hosted public key: `http://example.com/my_pgp_key.pub`\n+3. Explicit public key string: `-----BEGIN PGP PUBLIC KEY BLOCK----- .....`\n \n-### How to decrypt user's encrypted password and secret key\n+### Keybase\n+\n+#### Prerequsites\n+When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n+#### How to decrypt user's encrypted password and secret key\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n@@ -20,19 +25,31 @@ This module outputs commands and PGP messages which can be decrypted either usin\n - `keybase_secret_key_pgp_message`\n - `keybase_ses_smtp_password_v4_pgp_message`\n \n+\n+### PGP key over Generic HTTP or as explicit string\n+When `pgp_key` is a string starting with `http` or `https`, the module will attempt to download the public key over HTTP. Ensure that the key is available over the network, and provide any necessary request headers via `pgp_key_request_headers`.\n+\n+Note, when using the Generic HTTP URL or as explicit string, the Keybase decryption commands may not work. Instead, use the encrypted outputs directly in any decryption tool:\n+- `iam_user_login_profile_encrypted_password`\n+- `iam_access_key_encrypted_secret`\n+- `iam_access_key_encrypted_ses_smtp_password_v4`\n+\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_http\"></a> [http](#requirement\\_http) | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_http\"></a> [http](#provider\\_http) | >= 3.0 |\n \n ## Modules\n \n@@ -47,6 +64,7 @@ No modules.\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n+| [http_http.pgp_key](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |\n \n ## Inputs\n \n@@ -62,7 +80,8 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key_request_headers\"></a> [pgp\\_key\\_request\\_headers](#input\\_pgp\\_key\\_request\\_headers) | Additional headers if fetching the key over HTTP. | `map(string)` | `{}` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n---\nmodules/iam-user/main.tf\n@@ -1,3 +1,10 @@\n+data \"http\" \"pgp_key\" {\n+ count = startswith(var.pgp_key, \"http\") ? 1 : 0\n+\n+ url = var.pgp_key\n+ request_headers = var.pgp_key_request_headers\n+}\n+\n resource \"aws_iam_user\" \"this\" {\n count = var.create_user ? 1 : 0\n \n@@ -13,7 +20,7 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n count = var.create_user && var.create_iam_user_login_profile ? 1 : 0\n \n user = aws_iam_user.this[0].name\n- pgp_key = var.pgp_key\n+ pgp_key = try(base64encode(data.http.pgp_key[0].response_body), var.pgp_key)\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n \n---\nmodules/iam-user/variables.tf\n@@ -34,11 +34,17 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n+ description = \"Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n \n+variable \"pgp_key_request_headers\" {\n+ description = \"Additional headers if fetching the key over HTTP.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n variable \"iam_access_key_status\" {\n description = \"Access key status to apply.\"\n type = string\n---\nmodules/iam-user/versions.tf\n@@ -6,5 +6,9 @@ terraform {\n source = \"hashicorp/aws\"\n version = \">= 4.0\"\n }\n+ http = {\n+ source = \"hashicorp/http\"\n+ version = \">= 3.0\"\n+ }\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -2,16 +2,21 @@\n \n Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user public key. All of these are optional resources.\n \n-## Notes for keybase users\n-\n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+## PGP encryption\n \n-When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n+To encrypt passwords and access keys, provide a PGP key to `pgp_key` variable in one of three formats. \n+1. Keybase hosted public key: `keybase:username`\n+2. Generic HTTP hosted public key: `http://example.com/my_pgp_key.pub`\n+3. Explicit public key string: `-----BEGIN PGP PUBLIC KEY BLOCK----- .....`\n \n-### How to decrypt user's encrypted password and secret key\n+### Keybase\n+\n+#### Prerequsites\n+When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n+#### How to decrypt user's encrypted password and secret key\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n@@ -20,19 +25,31 @@ This module outputs commands and PGP messages which can be decrypted either usin\n - `keybase_secret_key_pgp_message`\n - `keybase_ses_smtp_password_v4_pgp_message`\n \n+\n+### PGP key over Generic HTTP or as explicit string\n+When `pgp_key` is a string starting with `http` or `https`, the module will attempt to download the public key over HTTP. Ensure that the key is available over the network, and provide any necessary request headers via `pgp_key_request_headers`.\n+\n+Note, when using the Generic HTTP URL or as explicit string, the Keybase decryption commands may not work. Instead, use the encrypted outputs directly in any decryption tool:\n+- `iam_user_login_profile_encrypted_password`\n+- `iam_access_key_encrypted_secret`\n+- `iam_access_key_encrypted_ses_smtp_password_v4`\n+\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_http\"></a> [http](#requirement\\_http) | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_http\"></a> [http](#provider\\_http) | >= 3.0 |\n \n ## Modules\n \n@@ -47,6 +64,7 @@ No modules.\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n+| [http_http.pgp_key](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |\n \n ## Inputs\n \n@@ -62,7 +80,8 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key_request_headers\"></a> [pgp\\_key\\_request\\_headers](#input\\_pgp\\_key\\_request\\_headers) | Additional headers if fetching the key over HTTP. | `map(string)` | `{}` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n---\nmodules/iam-user/main.tf\n@@ -1,3 +1,10 @@\n+data \"http\" \"pgp_key\" {\n+ count = startswith(var.pgp_key, \"http\") ? 1 : 0\n+\n+ url = var.pgp_key\n+ request_headers = var.pgp_key_request_headers\n+}\n+\n resource \"aws_iam_user\" \"this\" {\n count = var.create_user ? 1 : 0\n \n@@ -13,7 +20,7 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n count = var.create_user && var.create_iam_user_login_profile ? 1 : 0\n \n user = aws_iam_user.this[0].name\n- pgp_key = var.pgp_key\n+ pgp_key = try(base64encode(data.http.pgp_key[0].response_body), var.pgp_key)\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n \n---\nmodules/iam-user/variables.tf\n@@ -34,11 +34,17 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n+ description = \"Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n \n+variable \"pgp_key_request_headers\" {\n+ description = \"Additional headers if fetching the key over HTTP.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n variable \"iam_access_key_status\" {\n description = \"Access key status to apply.\"\n type = string\n---\nmodules/iam-user/versions.tf\n@@ -6,5 +6,9 @@ terraform {\n source = \"hashicorp/aws\"\n \"aws_iam_user_login_profile\" version = \">= 4.0\"\n }\n+ http = {\n+ source = \"hashicorp/http\"\n+ version = \">= 3.0\"\n+ }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -2,16 +2,21 @@\n \n Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user public key. All of these are optional resources.\n \n-## Notes for keybase users\n-\n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+## PGP encryption\n \n-When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n+To encrypt passwords and access keys, provide a PGP key to `pgp_key` variable in one of three formats. \n+1. Keybase hosted public key: `keybase:username`\n+2. Generic HTTP hosted public key: `http://example.com/my_pgp_key.pub`\n+3. Explicit public key string: `-----BEGIN PGP PUBLIC KEY BLOCK----- .....`\n \n-### How to decrypt user's encrypted password and secret key\n+### Keybase\n+\n+#### Prerequsites\n+When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n+#### How to decrypt user's encrypted password and secret key\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n@@ -20,19 +25,31 @@ This module outputs commands and PGP messages which can be decrypted either usin\n - `keybase_secret_key_pgp_message`\n - `keybase_ses_smtp_password_v4_pgp_message`\n \n+\n+### PGP key over Generic HTTP or as explicit string\n+When `pgp_key` is a string starting with `http` or `https`, the module will attempt to download the public key over HTTP. Ensure that the key is available over the network, and provide any necessary request headers via `pgp_key_request_headers`.\n+\n+Note, when using the Generic HTTP URL or as explicit string, the Keybase decryption commands may not work. Instead, use the encrypted outputs directly in any decryption tool:\n+- `iam_user_login_profile_encrypted_password`\n+- `iam_access_key_encrypted_secret`\n+- `iam_access_key_encrypted_ses_smtp_password_v4`\n+\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_http\"></a> [http](#requirement\\_http) | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_http\"></a> [http](#provider\\_http) | >= 3.0 |\n \n ## Modules\n \n@@ -47,6 +64,7 @@ No modules.\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n+| [http_http.pgp_key](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |\n \n ## Inputs\n \n@@ -62,7 +80,8 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key_request_headers\"></a> [pgp\\_key\\_request\\_headers](#input\\_pgp\\_key\\_request\\_headers) | Additional headers if fetching the key over HTTP. | `map(string)` | `{}` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n---\nmodules/iam-user/main.tf\n@@ -1,3 +1,10 @@\n+data \"http\" \"pgp_key\" {\n+ count = startswith(var.pgp_key, \"http\") ? 1 : 0\n+\n+ url = var.pgp_key\n+ request_headers = var.pgp_key_request_headers\n+}\n+\n resource \"aws_iam_user\" \"this\" {\n count = var.create_user ? 1 : 0\n \n@@ -13,7 +20,7 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n count = var.create_user && var.create_iam_user_login_profile ? 1 : 0\n \n user = aws_iam_user.this[0].name\n- pgp_key = var.pgp_key\n+ pgp_key = try(base64encode(data.http.pgp_key[0].response_body), var.pgp_key)\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n \n---\nmodules/iam-user/variables.tf\n@@ -34,11 +34,17 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n+ description = \"Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n \n+variable \"pgp_key_request_headers\" {\n+ description = \"Additional headers if fetching the key over HTTP.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n variable \"iam_access_key_status\" {\n description = \"Access key status to apply.\"\n type = string\n---\nmodules/iam-user/versions.tf\n@@ -6,5 +6,9 @@ terraform {\n source = \"hashicorp/aws\"\n version = \">= 4.0\"\n }\n+ http = {\n+ source = \"hashicorp/http\"\n+ version = \">= 3.0\"\n+ }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -2,16 +2,21 @@\n \n Creates IAM user, IAM login profile, IAM access key and uploads IAM SSH user public key. All of these are optional resources.\n \n-## Notes for keybase users\n-\n **If possible, always use PGP encryption to prevent Terraform from keeping unencrypted password and access secret key in state file.**\n \n-### Keybase pre-requisits\n+## PGP encryption\n \n-When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n+To encrypt passwords and access keys, provide a PGP key to `pgp_key` variable in one of three formats. \n+1. Keybase hosted public key: `keybase:username`\n+2. Generic HTTP hosted public key: `http://example.com/my_pgp_key.pub`\n+3. Explicit public key string: `-----BEGIN PGP PUBLIC KEY BLOCK----- .....`\n \n-### How to decrypt user's encrypted password and secret key\n+### Keybase\n+\n+#### Prerequsites\n+When `pgp_key` is specified as `keybase:username`, make sure that that user has already uploaded public key to keybase.io. For example, user with username `test` has done it properly and you can [verify it here](https://keybase.io/test/pgp_keys.asc).\n \n+#### How to decrypt user's encrypted password and secret key\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n@@ -20,19 +25,31 @@ This module outputs commands and PGP messages which can be decrypted either usin\n - `keybase_secret_key_pgp_message`\n - `keybase_ses_smtp_password_v4_pgp_message`\n \n+\n+### PGP key over Generic HTTP or as explicit string\n+When `pgp_key` is a string starting with `http` or `https`, the module will attempt to download the public key over HTTP. Ensure that the key is available over the network, and provide any necessary request headers via `pgp_key_request_headers`.\n+\n+Note, when using the Generic HTTP URL or as explicit string, the Keybase decryption commands may not work. Instead, use the encrypted outputs directly in any decryption tool:\n+- `iam_user_login_profile_encrypted_password`\n+- `iam_access_key_encrypted_secret`\n+- `iam_access_key_encrypted_ses_smtp_password_v4`\n+\n+\n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n \n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.0 |\n+| <a name=\"requirement_http\"></a> [http](#requirement\\_http) | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n | <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.0 |\n+| <a name=\"provider_http\"></a> [http](#provider\\_http) | >= 3.0 |\n \n ## Modules\n \n@@ -47,6 +64,7 @@ No modules.\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n+| [http_http.pgp_key](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |\n \n ## Inputs\n \n@@ -62,7 +80,8 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key. | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key_request_headers\"></a> [pgp\\_key\\_request\\_headers](#input\\_pgp\\_key\\_request\\_headers) | Additional headers if fetching the key over HTTP. | `map(string)` | `{}` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n---\nmodules/iam-user/main.tf\n@@ -1,3 +1,10 @@\n+data \"http\" \"pgp_key\" {\n+ count = startswith(var.pgp_key, \"http\") ? 1 : 0\n+\n+ url = var.pgp_key\n+ request_headers = var.pgp_key_request_headers\n+}\n+\n resource \"aws_iam_user\" \"this\" {\n count = var.create_user ? 1 : 0\n \n@@ -13,7 +20,7 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n count = var.create_user && var.create_iam_user_login_profile ? 1 : 0\n \n user = aws_iam_user.this[0].name\n- pgp_key = var.pgp_key\n+ pgp_key = try(base64encode(data.http.pgp_key[0].response_body), var.pgp_key)\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n \n---\nmodules/iam-user/variables.tf\n@@ -34,11 +34,17 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n+ description = \"Either a base-64 encoded PGP public key, a keybase username in the form `keybase:username`, or an HTTP/HTTPS url where the key is hosted. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n \n+variable \"pgp_key_request_headers\" {\n+ description = \"Additional headers if fetching the key over HTTP.\"\n+ type = map(string)\n+ default = {}\n+}\n+\n variable \"iam_access_key_status\" {\n description = \"Access key status to apply.\"\n type = string\n---\nmodules/iam-user/versions.tf\n@@ -6,5 +6,9 @@ terraform {\n source = \"hashicorp/aws\"\n version = \">= 4.0\"\n }\n+ http = {\n+ source = \"hashicorp/http\"\n+ version = \">= 3.0\"\n+ }\n }\n }\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/365\r\n\r\n## Motivation and Context\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/365\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-policy/main.tf\n@@ -16,7 +16,7 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"iam_policy\" {\n source = \"../../modules/iam-policy\"\n \n- name = \"example\"\n+ name_prefix = \"example-\"\n path = \"/\"\n description = \"My example policy\"\n \n---\nmodules/iam-policy/README.md\n@@ -32,7 +32,8 @@ No modules.\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | 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---\nmodules/iam-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\nmodules/iam-read-only-policy/README.md\n@@ -43,7 +43,8 @@ No modules.\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n---\nmodules/iam-read-only-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\n\n\n---\n\nChoice B:\nexamples/iam-policy/main.tf\n@@ -16,7 +16,7 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"iam_policy\" {\n source = \"../../modules/iam-policy\"\n \n- name = \"example\"\n+ name_prefix = \"example-\"\n path = \"/\"\n description = \"My example policy\"\n \n---\nmodules/iam-policy/README.md\n@@ -32,7 +32,8 @@ No modules.\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | 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---\nmodules/iam-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\nmodules/iam-read-only-policy/README.md\n@@ -43,7 +43,8 @@ No modules.\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n---\nmodules/iam-read-only-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? <a : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\n\n\n---\n\nChoice C:\nexamples/iam-policy/main.tf\n@@ -16,7 +16,7 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"iam_policy\" {\n source = \"../../modules/iam-policy\"\n \n- name = \"example\"\n+ name_prefix = \"example-\"\n path = \"/\"\n description = \"My example policy\"\n \n---\nmodules/iam-policy/README.md\n@@ -32,7 +32,8 @@ No modules.\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | 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---\nmodules/iam-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\nmodules/iam-read-only-policy/README.md\n@@ -43,7 +43,8 @@ No modules.\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n---\nmodules/iam-read-only-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = \"name\" name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\n\n\n---\n\nChoice D:\nexamples/iam-policy/main.tf\n@@ -16,7 +16,7 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"iam_policy\" {\n source = \"../../modules/iam-policy\"\n \n- name = \"example\"\n+ name_prefix = \"example-\"\n path = \"/\"\n description = \"My example policy\"\n \n---\nmodules/iam-policy/README.md\n@@ -32,7 +32,8 @@ No modules.\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | 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---\nmodules/iam-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\nmodules/iam-read-only-policy/README.md\n@@ -43,7 +43,8 @@ No modules.\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_name\"></a> [name](#input\\_name) | The name of the policy | `string` | `null` | no |\n+| <a name=\"input_name_prefix\"></a> [name\\_prefix](#input\\_name\\_prefix) | IAM policy name prefix | `string` | `null` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | The path of the policy in IAM | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n | <a [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n---\nmodules/iam-read-only-policy/main.tf\n@@ -2,6 +2,7 @@ resource \"aws_iam_policy\" \"policy\" {\n count = var.create_policy ? 1 : 0\n \n name = var.name\n+ name_prefix = var.name_prefix\n path = var.path\n description = var.description\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -7,7 +7,13 @@ variable \"create_policy\" {\n variable \"name\" {\n description = \"The name of the policy\"\n type = string\n- default = \"\"\n+ default = null\n+}\n+\n+variable \"name_prefix\" {\n+ description = \"IAM policy name prefix\"\n+ type = string\n+ default = null\n }\n \n variable \"path\" {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nFixes #366 \r\n\r\n## Motivation and Context\r\nSometimes we need to assign a single role to multiple service accounts or service account names are created dynamically so we might not know them in advance. It allows us to override the default `StringEquals` condition with `StringLike` and use wildcards to allow multiple service accounts to assume the same role.\r\n\r\n## Breaking Changes\r\nNo, the new variable defaults to previously hard-coded value. \r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nexamples/iam-eks-role/README.md\n@@ -36,6 +36,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n+| <a name=\"module_iam_eks_role_with_assume_wildcard\"></a> [iam\\_eks\\_role\\_with\\_assume\\_wildcard](#module\\_iam\\_eks\\_role\\_with\\_assume\\_wildcard) | ../../modules/iam-eks-role | n/a |\n | <a name=\"module_iam_eks_role_with_self_assume\"></a> [iam\\_eks\\_role\\_with\\_self\\_assume](#module\\_iam\\_eks\\_role\\_with\\_self\\_assume) | ../../modules/iam-eks-role | n/a |\n ## Resources\n---\nexamples/iam-eks-role/main.tf\n@@ -40,6 +40,27 @@ module \"iam_eks_role_with_self_assume\" {\n }\n }\n \n+#############################################\n+# IAM EKS role with wildcard assume condition\n+#############################################\n+module \"iam_eks_role_with_assume_wildcard\" {\n+ source = \"../../modules/iam-eks-role\"\n+ role_name = \"my-app-assume-wildcard\"\n+\n+ cluster_service_accounts = {\n+ (random_pet.this.id) = [\"default:my-app-prefix-*\"]\n+ }\n+ assume_role_condition_test = \"StringLike\"\n+\n+ tags = {\n+ Name = \"my-app-assume-wildcard\"\n+ }\n+\n+ role_policy_arns = {\n+ AmazonEKS_CNI_Policy = \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n---\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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---\nmodules/iam-eks-role/main.tf\n@@ -52,7 +52,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n values = [for s in statement.value : \"system:serviceaccount:${s}\"]\n }\n---\nmodules/iam-eks-role/variables.tf\n@@ -69,3 +69,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n---\n\n\n---\n\nChoice B:\nexamples/iam-eks-role/README.md\n@@ -36,6 +36,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n+| <a name=\"module_iam_eks_role_with_assume_wildcard\"></a> [iam\\_eks\\_role\\_with\\_assume\\_wildcard](#module\\_iam\\_eks\\_role\\_with\\_assume\\_wildcard) | ../../modules/iam-eks-role | n/a |\n | <a name=\"module_iam_eks_role_with_self_assume\"></a> [iam\\_eks\\_role\\_with\\_self\\_assume](#module\\_iam\\_eks\\_role\\_with\\_self\\_assume) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n---\nexamples/iam-eks-role/main.tf\n@@ -40,6 +40,27 @@ module \"iam_eks_role_with_self_assume\" {\n }\n Run \n+#############################################\n+# IAM EKS role with wildcard assume condition\n+#############################################\n+module \"iam_eks_role_with_assume_wildcard\" {\n+ source = \"../../modules/iam-eks-role\"\n+ role_name = \"my-app-assume-wildcard\"\n+\n+ cluster_service_accounts = {\n+ (random_pet.this.id) = [\"default:my-app-prefix-*\"]\n+ }\n+ assume_role_condition_test = \"StringLike\"\n+\n+ tags = {\n+ Name = \"my-app-assume-wildcard\"\n+ }\n+\n+ role_policy_arns = {\n+ AmazonEKS_CNI_Policy = \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n---\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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---\nmodules/iam-eks-role/main.tf\n@@ -52,7 +52,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n values = [for s in statement.value : \"system:serviceaccount:${s}\"]\n }\n---\nmodules/iam-eks-role/variables.tf\n@@ -69,3 +69,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n---\n\n\n---\n\nChoice C:\nexamples/iam-eks-role/README.md\n@@ -36,6 +36,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n+| <a name=\"module_iam_eks_role_with_assume_wildcard\"></a> [iam\\_eks\\_role\\_with\\_assume\\_wildcard](#module\\_iam\\_eks\\_role\\_with\\_assume\\_wildcard) | ../../modules/iam-eks-role | n/a |\n | <a name=\"module_iam_eks_role_with_self_assume\"></a> [iam\\_eks\\_role\\_with\\_self\\_assume](#module\\_iam\\_eks\\_role\\_with\\_self\\_assume) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n---\nexamples/iam-eks-role/main.tf\n@@ -40,6 +40,27 @@ module \"iam_eks_role_with_self_assume\" {\n }\n }\n \n+#############################################\n+# IAM EKS role with wildcard assume condition\n+#############################################\n+module \"iam_eks_role_with_assume_wildcard\" {\n+ source = \"../../modules/iam-eks-role\"\n+ role_name = \"my-app-assume-wildcard\"\n+\n+ cluster_service_accounts = {\n+ (random_pet.this.id) = [\"default:my-app-prefix-*\"]\n+ }\n+ assume_role_condition_test = \"StringLike\"\n+\n+ tags = {\n+ Name = \"my-app-assume-wildcard\"\n+ }\n+\n+ role_policy_arns = {\n+ AmazonEKS_CNI_Policy = \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n---\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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---\nmodules/iam-eks-role/main.tf\n@@ -52,7 +52,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = condition\n+#############################################\n+module \"https://\", \"\")}:sub\"\n values = [for s in statement.value : \"system:serviceaccount:${s}\"]\n }\n---\nmodules/iam-eks-role/variables.tf\n@@ -69,3 +69,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n---\n\n\n---\n\nChoice D:\nexamples/iam-eks-role/README.md\n@@ -36,6 +36,7 @@ Run `terraform destroy` when you don't need these resources.\n |------|--------|---------|\n | <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n+| <a name=\"module_iam_eks_role_with_assume_wildcard\"></a> [iam\\_eks\\_role\\_with\\_assume\\_wildcard](#module\\_iam\\_eks\\_role\\_with\\_assume\\_wildcard) | ../../modules/iam-eks-role | n/a |\n | <a name=\"module_iam_eks_role_with_self_assume\"></a> [iam\\_eks\\_role\\_with\\_self\\_assume](#module\\_iam\\_eks\\_role\\_with\\_self\\_assume) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n---\nexamples/iam-eks-role/main.tf\n@@ -40,6 +40,27 @@ module \"iam_eks_role_with_self_assume\" {\n }\n }\n \n+#############################################\n+# IAM EKS role with wildcard assume condition\n+#############################################\n+module \"iam_eks_role_with_assume_wildcard\" {\n+ source = \"../../modules/iam-eks-role\"\n+ role_name = \"my-app-assume-wildcard\"\n+\n+ cluster_service_accounts = {\n+ (random_pet.this.id) = [\"default:my-app-prefix-*\"]\n+ }\n+ assume_role_condition_test = \"StringLike\"\n+\n+ tags = {\n+ Name = \"my-app-assume-wildcard\"\n+ }\n+\n+ role_policy_arns = {\n+ AmazonEKS_CNI_Policy = \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n---\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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---\nmodules/iam-eks-role/main.tf\n@@ -52,7 +52,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n values = [for s in statement.value : \"system:serviceaccount:${s}\"]\n }\n---\nmodules/iam-eks-role/variables.tf\n@@ -69,3 +69,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\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:\nAdd elasticloadbalancing:AddTags permissions to AWS Load Balancer Controller policy required for version 2.4.7\r\n\r\n## Description\r\nVersion 2.4.7 of AWS ALB controller has been released with an updated IAM permission https://github.com/kubernetes-sigs/aws-load-balancer-controller/releases/tag/v2.4.7.\r\n\r\nThe permission required is elasticloadbalancing:AddTags. See change here https://github.com/kubernetes-sigs/aws-load-balancer-controller/pull/3046/files.\r\n\r\n\r\n## Motivation and Context\r\nUpdates AWS ALB Controller policy to match latest on version 2.4.7.\r\n\r\n\r\n## Breaking Changes\r\nNone.\r\n\r\n## How Has This Been Tested?\r\nI have applied the IAM policy to AWS using Terraform, then copied the resulting JSON file from AWS, and did a file side-by-side comparison with the official IAM policy JSON confirming it matches.\r\n\r\nFixes #339 \r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -875,6 +875,32 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n }\n }\n \n+ statement {\n+ actions = [\n+ \"elasticloadbalancing:AddTags\"\n+ ]\n+ resources = [\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/net/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/app/*/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"elasticloadbalancing:CreateAction\"\n+ values = [\n+ \"CreateTargetGroup\",\n+ \"CreateLoadBalancer\",\n+ ]\n+ }\n+\n+ condition {\n+ test = \"Null\"\n+ variable = \"aws:RequestTag/elbv2.k8s.aws/cluster\"\n+ values = [\"false\"]\n+ }\n+ }\n+\n statement {\n actions = [\n \"elasticloadbalancing:RegisterTargets\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -875,6 +875,32 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n }\n }\n \n+ statement {\n+ actions = [\n+ \"elasticloadbalancing:AddTags\"\n+ ]\n+ resources = [\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/net/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/app/*/*\",\n+ ]\n+\n+ condition {\n+ = \"StringEquals\"\n+ variable = \"elasticloadbalancing:CreateAction\"\n+ values = [\n+ \"CreateTargetGroup\",\n+ \"CreateLoadBalancer\",\n+ ]\n+ }\n+\n+ condition {\n+ test = \"Null\"\n+ variable = \"aws:RequestTag/elbv2.k8s.aws/cluster\"\n+ values = [\"false\"]\n+ }\n+ }\n+\n statement {\n actions = [\n \"elasticloadbalancing:RegisterTargets\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -875,6 +875,32 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n }\n }\n \n+ statement {\n+ actions = [\n+ ]\n+ resources = [\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/net/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/app/*/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"elasticloadbalancing:CreateAction\"\n+ values = [\n+ \"CreateTargetGroup\",\n+ \"CreateLoadBalancer\",\n+ ]\n+ }\n+\n+ condition {\n+ test = \"Null\"\n+ variable = \"aws:RequestTag/elbv2.k8s.aws/cluster\"\n+ values = [\"false\"]\n+ }\n+ }\n+\n statement {\n actions = [\n \"elasticloadbalancing:RegisterTargets\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -875,6 +875,32 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n }\n }\n \n+ statement {\n+ actions = [\n+ \"elasticloadbalancing:AddTags\"\n+ ]\n+ resources = [\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/net/*/*\",\n+ \"arn:${local.partition}:elasticloadbalancing:*:*:loadbalancer/app/*/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"elasticloadbalancing:CreateAction\"\n+ values = [\n+ \"CreateTargetGroup\",\n+ \"CreateLoadBalancer\",\n+ ]\n+ }\n+\n+ condition {\n+ test = \"Null\"\n+ variable = \"aws:RequestTag/elbv2.k8s.aws/cluster\"\n+ values = [\"false\"]\n+ }\n+ }\n+\n statement {\n actions = [\n \"elasticloadbalancing:RegisterTargets\",\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nRemove unnecessary action (\"autoscaling:UpdateAutoScalingGroup\") from the IAM policy of the Cluster Autoscaler.\r\nUpdate the order of the IAM actions as in the [documentation,](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#full-cluster-autoscaler-features-policy-recommended) so that it is easier for future comparison.\r\n\r\n## Motivation and Context\r\nReduces the IAM permissions to the required actions.\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -74,8 +74,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n- \"autoscaling:TerminateInstanceInAutoScalingGroup\",\n- \"autoscaling:UpdateAutoScalingGroup\",\n+ \"autoscaling:TerminateInstanceInAutoScalingGroup\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -74,8 +74,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n- \"autoscaling:TerminateInstanceInAutoScalingGroup\",\n- \"autoscaling:UpdateAutoScalingGroup\",\n+ \"autoscaling:TerminateInstanceInAutoScalingGroup\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -74,8 +74,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n content {\n actions = \"autoscaling:SetDesiredCapacity\",\n- \"autoscaling:TerminateInstanceInAutoScalingGroup\",\n- \"autoscaling:UpdateAutoScalingGroup\",\n+ \"autoscaling:TerminateInstanceInAutoScalingGroup\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -74,8 +74,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n content {\n actions = [\n \"autoscaling:SetDesiredCapacity\",\n- \"autoscaling:TerminateInstanceInAutoScalingGroup\",\n- \"autoscaling:UpdateAutoScalingGroup\",\n+ \"autoscaling:TerminateInstanceInAutoScalingGroup\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nUpdate policies for cluster autoscaler\r\n\r\n## Motivation and Context\r\nSupport attribute-based instance selection using instance requirements.\r\n\r\n[Fix #346 ](https://github.com/terraform-aws-modules/terraform-aws-iam/issues/346)\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -62,6 +62,8 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n -62,6 \"ec2:DescribeLaunchTemplateVersions\",\n \"ec2:DescribeInstanceTypes\",\n \"eks:DescribeNodegroup\",\n+ \"ec2:DescribeImages\",\n+ \"ec2:GetInstanceTypesFromInstanceRequirements\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -62,6 +62,8 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"ec2:DescribeLaunchTemplateVersions\",\n \"ec2:DescribeInstanceTypes\",\n \"eks:DescribeNodegroup\",\n+ \"ec2:DescribeImages\",\n+ \"ec2:GetInstanceTypesFromInstanceRequirements\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -62,6 +62,8 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"ec2:DescribeLaunchTemplateVersions\",\n \"ec2:DescribeInstanceTypes\",\n \"eks:DescribeNodegroup\",\n+ \"ec2:DescribeImages\",\n+ \"ec2:GetInstanceTypesFromInstanceRequirements\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -62,6 +62,8 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"ec2:DescribeLaunchTemplateVersions\",\n \"ec2:DescribeInstanceTypes\",\n \"eks:DescribeNodegroup\",\n+ -62,6 \"ec2:GetInstanceTypesFromInstanceRequirements\"\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nJust like ListSecrets from Secrets Manager the DecribeParameter action is always required to allow full access\r\n\r\n## Motivation and Context\r\nWith out this the policy will not work when using the external_secrets_ssm_parameter_arns variable\r\n\r\n## Breaking Changes\r\nno\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using my fork as a module\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -431,11 +431,15 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n+ statement {\n+ actions = [\"ssm:DescribeParameters\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n- \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -431,11 +431,15 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n+ statement {\n+ actions = [\"ssm:DescribeParameters\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n- \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -431,11 +431,15 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n+ statement {\n+ actions = [\"ssm:DescribeParameters\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n }\n+\n = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n- \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -431,11 +431,15 @@ resource \"aws_iam_role_policy_attachment\" \"external_dns\" {\n data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n+ statement {\n+ actions = [\"ssm:DescribeParameters\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n- \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\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\nUpdates the URL for the Karpenter Cloudformation file which contains the IAM permissions\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\nKarpenter changed the directory structure in their repo, so the old link was broken\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -8,7 with @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n - [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n-- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n+- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -8,7 +8,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n - [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n-- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n+- - - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -8,7 +8,7 @@ Creates an IAM role which can with assumed by AWS EKS `ServiceAccount`s with optio\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n - [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n-- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n+- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -8,7 +8,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [External DNS](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy)\n - [External Secrets](https://github.com/external-secrets/kubernetes-external-secrets#add-a-secret)\n - [FSx for Lustre CSI Driver](https://github.com/kubernetes-sigs/aws-fsx-csi-driver/blob/master/docs/README.md)\n-- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n+- [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n - [App Mesh Controller](https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/iam/controller-iam-policy.json)\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\nUpdate efs_csi policy to current version\r\n\r\n## Motivation and Context\r\nEFS driver has updated example policy\r\n\r\nSee https://github.com/kubernetes-sigs/aws-efs-csi-driver/pull/964\r\n\r\n## Breaking Changes\r\nno\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -341,6 +341,17 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n -341,6 }\n }\n \n+ statement {\n+ actions = [\"elasticfilesystem:TagResource\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/efs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n+ }\n+ }\n+\n statement {\n actions = [\"elasticfilesystem:DeleteAccessPoint\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -341,6 +341,17 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n }\n }\n+ }\n \n+ statement {\n+ actions = [\"elasticfilesystem:TagResource\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/efs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n+ }\n+ }\n+\n statement {\n actions = [\"elasticfilesystem:DeleteAccessPoint\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -341,6 +341,17 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"elasticfilesystem:TagResource\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/efs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n+ }\n+ }\n+\n statement {\n actions = [\"elasticfilesystem:DeleteAccessPoint\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -341,6 +341,17 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"elasticfilesystem:TagResource\"]\n+ = resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/efs.csi.aws.com/cluster\"\n+ values = [\"true\"]\n+ }\n+ }\n+\n statement {\n actions = [\"elasticfilesystem:DeleteAccessPoint\"]\n resources = [\"*\"]\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\nAdd thumbprints for change in the intermediate certificate authority.\r\nhttps://github.blog/changelog/2022-01-13-github-actions-update-on-oidc-based-deployments-to-aws/\r\n\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nWithout this, `configure-aws-credentials` step fails.\r\n\r\n```\r\nRun aws-actions/configure-aws-credentials@v1\r\n with:\r\n role-to-assume: arn:aws:iam::9[2](https://github.com/speee/dx-platform/actions/runs/123456789012/jobs/123456789012#step:7:2)123456789012:role/terraform-github-actions\r\n role-session-name: gh-actions\r\n aws-region: ap-northeast-1\r\n audience: sts.amazonaws.com\r\nError: OpenIDConnect provider's HTTPS certificate doesn't match configured thumbprint\r\n```\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nNothing.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n\r\n1. I checked current iam-github-oidc-provider was broken.\r\n2. `vim .terraform/modules/iam_github_oidc_provider/modules/iam-github-oidc-provider/main.tf` and fix line 18.\r\n3. `terraform apply` and `Run aws-actions/configure-aws-credentials@v1` in GitHub Actions succeeded.\r\n\r\n\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-github-oidc-provider/main.tf\n@@ -13,9 +13,12 @@ data \"tls_certificate\" \"this\" {\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n- url = var.url\n- client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ url = var.url\n+ client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n+ thumbprint_list = concat(\n+ data.tls_certificate.this[0].certificates[*].sha1_fingerprint,\n+ [\"6938fd4d98bab03faadb97b34396831e3780aea1\"], # https://github.blog/changelog/2022-01-13-github-actions-update-on-oidc-based-deployments-to-aws/\n+ )\n \n tags = var.tags\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-github-oidc-provider/main.tf\n@@ -13,9 +13,12 @@ data \"tls_certificate\" \"this\" resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n- url = var.url\n- client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ url = var.url\n+ client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n+ thumbprint_list = concat(\n+ data.tls_certificate.this[0].certificates[*].sha1_fingerprint,\n+ [\"6938fd4d98bab03faadb97b34396831e3780aea1\"], # https://github.blog/changelog/2022-01-13-github-actions-update-on-oidc-based-deployments-to-aws/\n+ )\n \n tags = var.tags\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-github-oidc-provider/main.tf\n@@ -13,9 +13,12 @@ data \"tls_certificate\" \"this\" {\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n- url = var.url\n- client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ url = var.url\n+ client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n+ thumbprint_list = concat(\n+ data.tls_certificate.this[0].certificates[*].sha1_fingerprint,\n+ [\"6938fd4d98bab03faadb97b34396831e3780aea1\"], # https://github.blog/changelog/2022-01-13-github-actions-update-on-oidc-based-deployments-to-aws/\n+ )\n \n tags = var.tags\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-github-oidc-provider/main.tf\n@@ -13,9 +13,12 @@ data \"tls_certificate\" \"this\" {\n resource \"aws_iam_openid_connect_provider\" \"this\" {\n count = var.create ? 1 : 0\n \n- url = var.url\n- client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n- thumbprint_list = data.tls_certificate.this[0].certificates[*].sha1_fingerprint\n+ url = var.url\n+ client_id_list = coalescelist(var.client_id_list, [\"sts.${data.aws_partition.current.dns_suffix}\"])\n+ thumbprint_list = concat(\n+ data.tls_certificate.this[0].certificates[*].sha1_fingerprint,\n+ [\"6938fd4d98bab03faadb97b34396831e3780aea1\"], # https://github.blog/changelog/2022-01-13-github-actions-update-on-oidc-based-deployments-to-aws/\n+ )\n \n tags = var.tags\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdd `kms:decrypt` policy for External Secret\r\n\r\n## Motivation and Context\r\n`kms:decrypt` policy is needed to get secrets from secret manager.\r\n\r\nReference https://github.com/external-secrets/external-secrets/issues/390\r\n\r\n## Breaking Changes\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.0\n+ rev: v1.77.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -137,6 +137,7 @@ module \"external_secrets_irsa_role\" {\n attach_external_secrets_policy = true\n external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,6 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -458,6 +458,13 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n+\n+ statement {\n+ actions [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -164,6 +164,12 @@ variable \"external_secrets_secrets_manager_arns\" {\n default = [\"arn:aws:secretsmanager:*:*:secret:*\"]\n }\n \n+variable \"external_secrets_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n+ type = list(string)\n+ default = [\"arn:aws:kms:*:*:key/*\"]\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.0\n+ rev: v1.77.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -137,6 +137,7 @@ module \"external_secrets_irsa_role\" {\n attach_external_secrets_policy = true\n external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,6 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -458,6 +458,13 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n+\n+ statement {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -164,6 +164,12 @@ variable \"external_secrets_secrets_manager_arns\" {\n default = [\"arn:aws:secretsmanager:*:*:secret:*\"]\n }\n \n+variable \"external_secrets_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n+ type = list(string)\n+ default = [\"arn:aws:kms:*:*:key/*\"]\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.0\n+ rev: v1.77.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -137,6 +137,7 @@ module \"external_secrets_irsa_role\" {\n attach_external_secrets_policy = true\n external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,6 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -458,6 +458,13 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n+\n+ statement {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -164,6 +164,12 @@ variable \"external_secrets_secrets_manager_arns\" {\n default = [\"arn:aws:secretsmanager:*:*:secret:*\"]\n }\n \n+variable \"external_secrets_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n+ type = list(string)\n+ default = [\"arn:aws:kms:*:*:key/*\"]\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.0\n+ rev: v1.77.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -137,6 +137,7 @@ module \"external_secrets_irsa_role\" {\n attach_external_secrets_policy = true\n external_secrets_ssm_parameter_arns = [\"arn:aws:ssm:*:*:parameter/foo\"]\n external_secrets_secrets_manager_arns = [\"arn:aws:secretsmanager:*:*:secret:bar\"]\n+ external_secrets_kms_key_arns = [\"arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab\"]\n \n oidc_providers = {\n ex = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -204,6 +204,7 @@ No modules.\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow External DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n+| <a name=\"input_external_secrets_kms_key_arns\"></a> [external\\_secrets\\_kms\\_key\\_arns](#input\\_external\\_secrets\\_kms\\_key\\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:kms:*:*:key/*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_secrets_manager_arns\"></a> [external\\_secrets\\_secrets\\_manager\\_arns](#input\\_external\\_secrets\\_secrets\\_manager\\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:secretsmanager:*:*:secret:*\"<br>]</pre> | no |\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -458,6 +458,13 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n ]\n resources = var.external_secrets_secrets_manager_arns\n }\n+\n+ statement {\n+ actions = [\n+ \"kms:Decrypt\"\n+ ]\n+ resources = var.external_secrets_kms_key_arns\n+ }\n }\n \n resource \"aws_iam_policy\" \"external_secrets\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -164,6 +164,12 @@ variable \"external_secrets_secrets_manager_arns\" {\n default = [\"arn:aws:secretsmanager:*:*:secret:*\"]\n }\n \n+variable \"external_secrets_kms_key_arns\" {\n+ description = \"List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets\"\n+ type = list(string)\n+ default = [\"arn:aws:kms:*:*:key/*\"]\n+}\n+\n # FSx Lustre CSI\n variable \"attach_fsx_lustre_csi_policy\" {\n description = \"Determines whether to attach the FSx for Lustre CSI Driver IAM policy to the role\"\n---\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:\nssm:DescribeParameters is required to sync secrets from ParameterStore\r\n\r\n## Description\r\nError from the external-secrets log:\r\naws-role is not authorized to perform: ssm:DescribeParameters on resource: * because no identity-based policy allows the ssm:DescribeParameters action\\n\\tstatus code: 400, request id: ff\",\"stacktrace\":\"github.com/external-secrets/external-secrets/pkg/controllers/e │\r\n\r\n## Motivation and Context\r\nWhen using AWS System Manager Parameters with external-secrets(ESO) the secrets can not be synced unless the AWS Role that is mapped to the EKS Service Account has the ssm:DescribeParameters action.\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\n1. Using the module: `\"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"`\r\n2. provider: aws\r\n3. ESO SecretStore with \r\n```\r\nspec:\r\n provider:\r\n aws:\r\n service: ParameterStore\r\n region: us-east-1\r\n auth:\r\n jwt:\r\n serviceAccountRef:\r\n name: <sa_name>\r\n```\r\n4. Other values passed to the module\r\n``` \r\nattach_external_secrets_policy = true\r\nallow_self_assume_role = true\r\n```\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\r\n```\r\npre-commit run -a\r\n[INFO] Initializing environment for https://github.com/antonbabenko/pre-commit-terraform.\r\n[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.\r\n[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.\r\n[INFO] Once installed this environment will be reused.\r\n[INFO] This may take a few minutes...\r\nTerraform fmt............................................................Passed\r\nTerraform validate.......................................................Passed\r\nTerraform docs...........................................................Passed\r\nTerraform validate with tflint...........................................Passed\r\ncheck for merge conflicts................................................Passed\r\nfix end of files.........................................................Passed\r\n```\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -435,6 +435,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ }\n---\n \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -435,6 +435,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -435,6 +435,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:DescribeParameters\",\n ]\n = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -435,6 +435,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n actions = [\n \"ssm:GetParameter\",\n \"ssm:GetParameters\",\n+ \"ssm:DescribeParameters\",\n ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nAdd a new input variable to specify IAM path in `iam-group-with-assumable-roles-policy`, fixing #344 \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\nAdds the feature requested in #344 while keeping full backwards compatibility\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\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_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -8,6 +8,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n \n resource \"aws_iam_policy\" \"this\" {\n name = var.name\n+ path group = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n \n@@ -16,6 +17,7 @@ resource \"aws_iam_policy\" \"this\" {\n \n resource \"aws_iam_group\" \"this\" {\n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_policy_attachment\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -3,6 +3,12 @@ variable \"name\" {\n type = string\n }\n \n+variable \"path\" {\n+ description = \"Path of IAM policy and IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"assumable_roles\" {\n description = \"List of IAM roles ARNs which can be assumed by the group\"\n type = list(string)\n---\n\n\n---\n\nChoice B:\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 of IAM policy and IAM group | `string` | n/a | yes |\n+| <a name=\"input_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -8,6 +8,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n \n resource \"aws_iam_policy\" \"this\" {\n name = var.name\n+ path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n \n@@ -16,6 +17,7 @@ resource \"aws_iam_policy\" \"this\" {\n \n resource \"aws_iam_group\" \"this\" {\n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_policy_attachment\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -3,6 +3,12 @@ variable \"name\" {\n type = string\n }\n \n+variable \"path\" {\n+ description = \"Path of IAM policy and IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"assumable_roles\" {\n description = \"List of IAM roles ARNs which can be assumed by the group\"\n type = list(string)\n---\n\n\n---\n\nChoice C:\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 and have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM policy and IAM group | `string` | n/a | yes |\n+| <a name=\"input_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -8,6 +8,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n \n resource \"aws_iam_policy\" \"this\" {\n name = var.name\n+ path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n \n@@ -16,6 +17,7 @@ resource \"aws_iam_policy\" \"this\" {\n \n resource \"aws_iam_group\" \"this\" {\n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_policy_attachment\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -3,6 +3,12 @@ variable \"name\" {\n type = string\n }\n \n+variable \"path\" {\n+ description = \"Path of IAM policy and IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"assumable_roles\" {\n description = \"List of IAM roles ARNs which can be assumed by the group\"\n type = list(string)\n---\n\n\n---\n\nChoice D:\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_path\"></a> [path](#input\\_path) | Path of IAM policy and IAM group | `string` | `\"/\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n \n ## Outputs\n---\nmodules/iam-group-with-assumable-roles-policy/main.tf\n@@ -8,6 +8,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n \n resource \"aws_iam_policy\" \"this\" {\n name = var.name\n+ path = var.path\n description = \"Allows to assume role in another AWS account\"\n policy = data.aws_iam_policy_document.assume_role.json\n \n@@ -16,6 +17,7 @@ resource \"aws_iam_policy\" \"this\" {\n \n resource \"aws_iam_group\" \"this\" {\n name = var.name\n+ path = var.path\n }\n \n resource \"aws_iam_group_policy_attachment\" \"this\" {\n---\nmodules/iam-group-with-assumable-roles-policy/variables.tf\n@@ -3,6 +3,12 @@ variable \"name\" {\n type = string\n }\n \n+variable \"path\" {\n+ description = \"Path of IAM policy and IAM group\"\n+ type = string\n+ default = \"/\"\n+}\n+\n variable \"assumable_roles\" {\n description = \"List of IAM roles ARNs which can be assumed by the group\"\n type = list(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## Description\r\n\r\nAdd `eks:DescribeCluster` for Karpenter IRSA role\r\n\r\n## Motivation and Context\r\nThis is needed as of Karpenter 0.25: https://github.com/aws/karpenter/issues/3462\r\n- Closes #341 \r\n\r\n## Breaking Changes\r\nNo\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nI tested on my local setup.\r\n\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) ? data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,10 +1,12 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n+ region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -599,6 +599,11 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ statement {\n+ actions = [\"eks:DescribeCluster\"]\n+ resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"]\n+ }\n+\n dynamic \"statement\" {\n for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,10 +1,12 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n partition }\n+\n = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n+ region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -599,6 +599,11 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ statement {\n+ actions = [\"eks:DescribeCluster\"]\n+ resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"]\n+ }\n+\n dynamic \"statement\" {\n for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,10 +1,12 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n+ region = data.aws_region.current.name\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -599,6 +599,11 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ statement {\n+ actions = [\"eks:DescribeCluster\"]\n+ resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"]\n+ }\n+\n dynamic \"statement\" {\n for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,10 +1,12 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n+ region = data.aws_region.current.name\n role_name_condition = +170,7 != null ? var.role_name : \"${var.role_name_prefix}*\"\n }\n \n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -599,6 +599,11 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = var.karpenter_controller_node_iam_role_arns\n }\n \n+ statement {\n+ actions = [\"eks:DescribeCluster\"]\n+ resources = [\"arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"]\n+ }\n+\n dynamic \"statement\" {\n for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\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:\nKarpenter v0.25.0 is capable of detecting the EKS endpoint automatically but it requires the `eks:DescribeCluster` IAM permission.\r\n\r\nhttps://karpenter.sh/v0.25.0/upgrade-guide/#upgrading-to-v0250\r\n\r\nPlan output with an existing Karpenter IAM role:\r\n\r\n```hcl\r\nTerraform will perform the following actions:\r\n\r\n # aws_iam_policy.karpenter_controller[0] will be updated in-place\r\n ~ resource \"aws_iam_policy\" \"karpenter_controller\" {\r\n id = \"arn:aws:iam::XXXXXXXXXXX:policy/AmazonEKS_Karpenter_Controller_Policy-XXXXXXXXXXX\"\r\n name = \"AmazonEKS_Karpenter_Controller_Policy-XXXXXXXXXXX\"\r\n ~ policy = jsonencode(\r\n ~ {\r\n ~ Statement = [\r\n + {\r\n + Action = \"eks:DescribeCluster\"\r\n + Effect = \"Allow\"\r\n + Resource = \"arn:aws:eks:eu-central-1:XXXXXXXXXXX:cluster/my-cluster\"\r\n + Sid = \"\"\r\n },\r\n {\r\n Action = [\r\n \"pricing:GetProducts\",\r\n \"ec2:DescribeSubnets\",\r\n \"ec2:DescribeSpotPriceHistory\",\r\n \"ec2:DescribeSecurityGroups\",\r\n \"ec2:DescribeLaunchTemplates\",\r\n \"ec2:DescribeInstances\",\r\n \"ec2:DescribeInstanceTypes\",\r\n \"ec2:DescribeInstanceTypeOfferings\",\r\n \"ec2:DescribeImages\",\r\n \"ec2:DescribeAvailabilityZones\",\r\n \"ec2:CreateTags\",\r\n \"ec2:CreateLaunchTemplate\",\r\n \"ec2:CreateFleet\",\r\n ]\r\n Effect = \"Allow\"\r\n Resource = \"*\"\r\n Sid = \"\"\r\n },\r\n # (6 unchanged elements hidden)\r\n ]\r\n # (1 unchanged element hidden)\r\n }\r\n )\r\n tags = {}\r\n # (6 unchanged attributes hidden)\r\n }\r\n```\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,8 +1,10 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n+ region = data.aws_region.current.name\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -527,6 +527,16 @@ }\n+ \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n+ statement {\n+ actions = [\n+ \"eks:DescribeCluster\",\n+ ]\n+\n+ resources = [\n+ \"arn:aws:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"\n+ ]\n+ }\n+ \n statement {\n actions = [\n \"ec2:CreateFleet\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,8 +1,10 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n+ region = data.aws_region.current.name\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -527,6 +527,16 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role @@\n var.attach_karpenter_controller_policy ? 1 : 0\n \n+ statement {\n+ actions = [\n+ \"eks:DescribeCluster\",\n+ ]\n+\n+ resources = [\n+ \"arn:aws:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"\n+ ]\n+ }\n+ \n statement {\n actions = [\n \"ec2:CreateFleet\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,8 +1,10 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n+ region = data.aws_region.current.name\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -527,6 +527,16 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n+ statement {\n+ actions = [\n+ \"eks:DescribeCluster\",\n+ ]\n+\n+ resources = [\n+ \"arn:aws:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"\n+ ]\n+ }\n+ \n statement {\n actions = [\n \"ec2:CreateFleet\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -1,8 +1,10 @@\n data \"aws_partition\" \"current\" {}\n data \"aws_caller_identity\" \"current\" {}\n+data \"aws_region\" \"current\" {}\n \n locals {\n account_id = data.aws_caller_identity.current.account_id\n+ region = data.aws_region.current.name\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -527,6 +527,16 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n data \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n+ statement {\n+ actions = [\n+ \"eks:DescribeCluster\",\n+ ]\n+\n+ resources = [\n+ \"arn:aws:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}\"\n+ ]\n+ }\n+ \n statement {\n actions = [\n \"ec2:CreateFleet\",\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:\nWe faced an issue since #313 that new users which need to set a new password after first login not able to do that. Reason was that `iam:ChangePassword` was not granted for users which not have a MFA device set (which is the case for new users).\r\n\r\nWith this change we are able to create new users and they can login with there temporary password and are able to reset the password.\r\n\r\nMaybe it is related to #333.\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -134,6 +134,7 @@ data \"iam_self_management\" {\n effect = \"Deny\"\n \n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -134,6 +134,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Deny\"\n \n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n +134,7 \"iam:GetUser\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -134,6 +134,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Deny\"\n \n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n {\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -134,6 +134,7 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n effect = \"Deny\"\n \n not_actions = [\n+ \"iam:ChangePassword\",\n \"iam:CreateVirtualMFADevice\",\n \"iam:EnableMFADevice\",\n \"iam:GetUser\",\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\nUpdate self-manage policy to support users with path, regressed in 5.11.0.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nChanges introduced in #313 removed support for users with path. \r\n\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nFixes #334\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-group-with-policies/main.tf\n@@ -14,6 +14,7 @@ module \"iam_user2\" {\n source = \"../../modules/iam-user\"\n \n name = \"user2\"\n+ path = \"/developers/\"\n \n create_iam_user_login_profile = false\n create_iam_access_key = false\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -35,7 +35,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:GetUser\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -50,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateAccessKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -65,7 +71,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSigningCertificate\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -81,7 +90,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -97,7 +109,10 @@ \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateServiceSpecificCredential\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -124,8 +139,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ResyncMFADevice\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n-\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n---\n\n\n---\n\nChoice B:\nexamples/iam-group-with-policies/main.tf\n@@ -14,6 +14,7 @@ module \"iam_user2\" {\n source = \"../../modules/iam-user\"\n \n name = \"user2\"\n+ path = \"/developers/\"\n \n create_iam_user_login_profile = false\n create_iam_access_key = false\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -35,7 +35,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:GetUser\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -50,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateAccessKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -65,7 +71,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSigningCertificate\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -81,7 +90,10 @@ data \"iam_self_management\" {\n \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -97,7 +109,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateServiceSpecificCredential\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -124,8 +139,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ResyncMFADevice\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n-\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n---\n\n\n---\n\nChoice C:\nexamples/iam-group-with-policies/main.tf\n@@ -14,6 +14,7 @@ module \"iam_user2\" {\n source = \"../../modules/iam-user\"\n \n name = \"user2\"\n+ path = \"/developers/\"\n \n create_iam_user_login_profile = false\n create_iam_access_key = false\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -35,7 +35,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:GetUser\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -50,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateAccessKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -65,7 +71,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSigningCertificate\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -81,7 +90,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -97,7 +109,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateServiceSpecificCredential\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -124,8 +139,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ResyncMFADevice\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n-\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n---\n\n\n---\n\nChoice D:\nexamples/iam-group-with-policies/main.tf\n@@ -14,6 +14,7 @@ module \"iam_user2\" {\n source = \"../../modules/iam-user\"\n \n name = \"user2\"\n+ path = \"/developers/\"\n \n create_iam_user_login_profile = false\n create_iam_access_key = false\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -35,7 +35,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:GetUser\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -50,7 +53,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateAccessKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -65,7 +71,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSigningCertificate\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -81,7 +90,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -97,7 +109,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateServiceSpecificCredential\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\n@@ -124,8 +139,10 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:ResyncMFADevice\"\n ]\n \n- resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n-\n+ resources = [\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n+ \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\"\n+ ]\n }\n \n statement {\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\nDisable MFA enforcement for created groups added in 5.11.0. This change was undocumented, therefore it should be reverted and added as opt-in feature.\r\n\r\n## Motivation and Context\r\nKeep the module backward compatible with versions prior to 5.11.0\r\n\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nFixes #332 \r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/README.md\n@@ -44,6 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -145,28 +145,29 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n ]\n }\n \n- statement {\n- sid = \"DenyAllExceptListedIfNoMFA\"\n-\n- effect = \"Deny\"\n-\n- not_actions = [\n- \"iam:ChangePassword\",\n- \"iam:CreateVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GetUser\",\n- \"iam:ListMFADevices\",\n- \"iam:ListVirtualMFADevices\",\n- \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n- ]\n-\n- resources = [\"*\"]\n-\n- condition {\n- test = \"BoolIfExists\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"false\"]\n+ dynamic \"statement\" {\n+ for_each = var.enable_mfa_enforcment ? [1] : []\n+\n+ content {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+ effect = \"Deny\"\n+ not_actions = [\n+ \"iam:ChangePassword\",\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n+ ]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n+ }\n }\n }\n }\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -28,6 +28,12 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n+variable \"enable_mfa_enforcment\" {\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"attach_iam_self_management_policy\" {\n description = \"Whether to attach IAM policy which allows IAM users to manage their credentials and MFA\"\n type = bool\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/README.md\n@@ -44,6 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_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-\"` | |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -145,28 +145,29 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n ]\n }\n \n- statement {\n- sid = \"DenyAllExceptListedIfNoMFA\"\n-\n- effect = \"Deny\"\n-\n- not_actions = [\n- \"iam:ChangePassword\",\n- \"iam:CreateVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GetUser\",\n- \"iam:ListMFADevices\",\n- \"iam:ListVirtualMFADevices\",\n- \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n- ]\n-\n- resources = [\"*\"]\n-\n- condition {\n- test = \"BoolIfExists\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"false\"]\n+ dynamic \"statement\" {\n+ for_each = var.enable_mfa_enforcment ? [1] : []\n+\n+ content {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+ effect = \"Deny\"\n+ not_actions = [\n+ \"iam:ChangePassword\",\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n+ ]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n+ }\n }\n }\n }\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -28,6 +28,12 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n+variable \"enable_mfa_enforcment\" {\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"attach_iam_self_management_policy\" {\n description = \"Whether to attach IAM policy which allows IAM users to manage their credentials and MFA\"\n type = bool\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/README.md\n@@ -44,6 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should `name` and `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -145,28 +145,29 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n ]\n }\n \n- statement {\n- sid = \"DenyAllExceptListedIfNoMFA\"\n-\n- effect = \"Deny\"\n-\n- not_actions = [\n- \"iam:ChangePassword\",\n- \"iam:CreateVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GetUser\",\n- \"iam:ListMFADevices\",\n- \"iam:ListVirtualMFADevices\",\n- \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n- ]\n-\n- resources = [\"*\"]\n-\n- condition {\n- test = \"BoolIfExists\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"false\"]\n+ dynamic \"statement\" {\n+ for_each = var.enable_mfa_enforcment ? [1] : []\n+\n+ content {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+ effect = \"Deny\"\n+ not_actions = [\n+ \"iam:ChangePassword\",\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n+ ]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n+ }\n }\n }\n }\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -28,6 +28,12 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n+variable \"enable_mfa_enforcment\" {\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"attach_iam_self_management_policy\" {\n description = \"Whether to attach IAM policy which allows IAM users to manage their credentials and MFA\"\n type = bool\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/README.md\n@@ -44,6 +44,7 @@ No modules.\n | <a name=\"input_create_group\"></a> [create\\_group](#input\\_create\\_group) | Whether to create IAM group | `bool` | `true` | no |\n | <a name=\"input_custom_group_policies\"></a> [custom\\_group\\_policies](#input\\_custom\\_group\\_policies) | List of maps of inline IAM policies to attach to IAM group. Should have `name` = `policy` keys in each element. | `list(map(string))` | `[]` | no |\n | <a name=\"input_custom_group_policy_arns\"></a> [custom\\_group\\_policy\\_arns](#input\\_custom\\_group\\_policy\\_arns) | List of IAM policies ARNs to attach to IAM group | `list(string)` | `[]` | no |\n+| <a name=\"input_enable_mfa_enforcment\"></a> [enable\\_mfa\\_enforcment](#input\\_enable\\_mfa\\_enforcment) | Determines whether permissions are added to the policy which requires the groups IAM users to use MFA | `bool` | `true` | no |\n | <a name=\"input_group_users\"></a> [group\\_users](#input\\_group\\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |\n | <a name=\"input_iam_self_management_policy_name_prefix\"></a> [iam\\_self\\_management\\_policy\\_name\\_prefix](#input\\_iam\\_self\\_management\\_policy\\_name\\_prefix) | Name prefix for IAM policy to create with IAM self-management permissions | `string` | `\"IAMSelfManagement-\"` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Name of IAM group | `string` | `\"\"` | no |\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -145,28 +145,29 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n ]\n }\n \n- statement {\n- sid = \"DenyAllExceptListedIfNoMFA\"\n-\n- effect = \"Deny\"\n-\n- not_actions = [\n- \"iam:ChangePassword\",\n- \"iam:CreateVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GetUser\",\n- \"iam:ListMFADevices\",\n- \"iam:ListVirtualMFADevices\",\n- \"iam:ResyncMFADevice\",\n- \"sts:GetSessionToken\"\n- ]\n-\n- resources = [\"*\"]\n-\n- condition {\n- test = \"BoolIfExists\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"false\"]\n+ dynamic \"statement\" {\n+ for_each = var.enable_mfa_enforcment ? [1] : []\n+\n+ content {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+ effect = \"Deny\"\n+ not_actions = [\n+ \"iam:ChangePassword\",\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n+ ]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n+ }\n }\n }\n }\n---\nmodules/iam-group-with-policies/variables.tf\n@@ -28,6 +28,12 @@ variable \"custom_group_policies\" {\n default = []\n }\n \n+variable \"enable_mfa_enforcment\" {\n+ description = \"Determines whether permissions are added to the policy which requires the groups IAM users to use MFA\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"attach_iam_self_management_policy\" {\n description = \"Whether to attach IAM policy which allows IAM users to manage their credentials and MFA\"\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<!--- Describe your changes in detail -->\r\nThe `Release` and `Lock` workflow are using an old version and hence a [deprecated runtime (Node.js 12)](https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/). Bumping these workflows will resolve the deprecation warning in the affected workflows.\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\nMake sure that CI workflows uses non-deprecated runtimes.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone.\n\n---\n\nChoice A:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n\nChoice B:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n\nChoice C:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n\nChoice D:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThe current module is very useful but it only provides solutions to ones of the most used things, cert-manager, external-secrets, etc.\r\nBut there are no options for any other permissions. The idea is to take profit of this module and allow people to use it in order to add custom policies other than the ones that are already set.\r\n\r\n## Motivation and Context\r\nIn my case I needed that some of my workloads were able to assume a role with a serviceaccount which has permissions to write in a specific bucket.\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\nI tested it with the solution provided in the examples/ (see files changed)\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -44,6 +44,8 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -328,6 +328,53 @@ module \"vpc_cni_ipv6_irsa_role\" {\n tags = local.tags\n }\n \n+################################################################################\n+# Custom IRSA Roles\n+################################################################################\n+\n+# This is an example of a custom IRSA role which allows workloads with the specified serviceccount to perform actions in a S3 bucket.\n+module \"iam_policy\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n+\n+ name = \"myapp\"\n+ path = \"/\"\n+ description = \"Example policy\"\n+\n+ policy = jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [\n+ {\n+ Effect = \"Allow\"\n+ Action = [\n+ \"s3:*\",\n+ ]\n+ Resource = \"*\"\n+ }\n+ ]\n+ })\n+\n+}\n+\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-app\"\n+\n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n+ oidc_providers = {\n+ one = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ }\n+ two = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n+ }\n+ }\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -27,6 +27,10 @@ module \"iam_eks_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n role_name = \"my-app\"\n \n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n oidc_providers = {\n one = {\n provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -44,6 +44,8 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -328,6 +328,53 @@ module \"vpc_cni_ipv6_irsa_role\" {\n tags = local.tags\n }\n \n+################################################################################\n+# Custom IRSA Roles\n+################################################################################\n+\n+# This is an example of a custom IRSA role which allows workloads with the specified serviceccount to perform actions in a S3 bucket.\n+module \"iam_policy\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n+\n+ name = \"myapp\"\n+ path = \"/\"\n+ description = \"Example policy\"\n+\n+ policy = jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [\n+ {\n+ Effect = \"Allow\"\n+ Action = [\n+ \"s3:*\",\n+ ]\n+ Resource = \"*\"\n+ }\n+ ]\n+ })\n+\n+}\n+\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-app\"\n+\n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n+ oidc_providers = {\n+ one = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ }\n+ two = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n+ }\n+ }\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -27,6 +27,10 @@ module \"iam_eks_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n role_name = \"my-app\"\n \n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ # }\n+\n oidc_providers = {\n one = {\n provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -44,6 +44,8 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -328,6 +328,53 @@ module \"vpc_cni_ipv6_irsa_role\" {\n tags = local.tags\n }\n \n+################################################################################\n+# Custom IRSA Roles\n+################################################################################\n+\n+# This is an example of a custom IRSA role which allows workloads with the specified serviceccount to perform actions in a S3 bucket.\n+module \"iam_policy\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n+\n+ name = \"myapp\"\n+ path = \"/\"\n+ description = \"Example policy\"\n+\n+ policy = jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [\n+ {\n+ Effect = \"Allow\"\n+ Action = [\n+ \"s3:*\",\n+ ]\n+ Resource = \"*\"\n+ }\n+ ]\n+ })\n+\n+}\n+\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-app\"\n+\n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n+ oidc_providers = {\n+ one = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ }\n+ two = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n+ }\n+ }\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -27,6 +27,10 @@ module n/a {\n source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n role_name = \"my-app\"\n \n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n oidc_providers = {\n one = {\n provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/README.md\n@@ -44,6 +44,8 @@ Run `terraform destroy` when you don't need these resources.\n | <a name=\"module_external_dns_irsa_role\"></a> [external\\_dns\\_irsa\\_role](#module\\_external\\_dns\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_external_secrets_irsa_role\"></a> [external\\_secrets\\_irsa\\_role](#module\\_external\\_secrets\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_fsx_lustre_csi_irsa_role\"></a> [fsx\\_lustre\\_csi\\_irsa\\_role](#module\\_fsx\\_lustre\\_csi\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a |\n+| <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | terraform-aws-modules/iam/aws//modules/iam-policy | n/a |\n | <a name=\"module_irsa_role\"></a> [irsa\\_role](#module\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_karpenter_controller_irsa_role\"></a> [karpenter\\_controller\\_irsa\\_role](#module\\_karpenter\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n | <a name=\"module_load_balancer_controller_irsa_role\"></a> [load\\_balancer\\_controller\\_irsa\\_role](#module\\_load\\_balancer\\_controller\\_irsa\\_role) | ../../modules/iam-role-for-service-accounts-eks | n/a |\n---\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -328,6 +328,53 @@ module \"vpc_cni_ipv6_irsa_role\" {\n tags = local.tags\n }\n \n+################################################################################\n+# Custom IRSA Roles\n+################################################################################\n+\n+# This is an example of a custom IRSA role which allows workloads with the specified serviceccount to perform actions in a S3 bucket.\n+module \"iam_policy\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-policy\"\n+\n+ name = \"myapp\"\n+ path = \"/\"\n+ description = \"Example policy\"\n+\n+ policy = jsonencode({\n+ Version = \"2012-10-17\"\n+ Statement = [\n+ {\n+ Effect = \"Allow\"\n+ Action = [\n+ \"s3:*\",\n+ \"canary:my-app-staging\"]\n+ ]\n+ Resource = \"*\"\n+ }\n+ ]\n+ })\n+\n+}\n+\n+module \"iam_eks_role\" {\n+ source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n+ role_name = \"my-app\"\n+\n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n+ oidc_providers = {\n+ one = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ }\n+ two = {\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n+ }\n+ }\n+}\n+\n ################################################################################\n # Supporting Resources\n ################################################################################\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -27,6 +27,10 @@ module \"iam_eks_role\" {\n source = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n role_name = \"my-app\"\n \n+ role_policy_arns = {\n+ policy = \"arn:aws:iam::012345678901:policy/myapp\"\n+ }\n+\n oidc_providers = {\n one = {\n provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\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\nmodules/iam-role-for-service-accounts-eks -\r\nEBS-CSI driver policy - fix condition string for DeleteVolume action to reflect the changes in the upstream\r\n\r\n## Motivation and Context\r\nIssue - https://github.com/terraform-aws-modules/terraform-aws-iam/issues/325\r\nThe change in the upstream - https://github.com/kubernetes-sigs/aws-ebs-csi-driver/pull/1450\r\n\r\n## Breaking Changes\r\nThere are no breaking changes\r\n\r\n## How Has This Been Tested?\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n- tested on the EKS 1.23, Chart: aws-ebs-csi-driver-2.11.1, the driver version: 1.11.3\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -225,6 +225,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test statement = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n+ values = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -225,6 +225,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n+ values = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -225,6 +225,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n+ values [\"*\"]\n---\n [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -225,6 +225,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n }\n }\n \n+ statement {\n+ actions = [\"ec2:DeleteVolume\"]\n+ resources = [\"*\"]\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/created-for/pvc/name\"\n+ values = [\"*\"]\n+ }\n+ }\n+\n statement {\n actions = [\"ec2:DeleteSnapshot\"]\n resources = [\"*\"]\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\n\n- Update pre-commit workflow CI checks to use pinned version for `tflint` to avoid GitHub API rate limiting and use latest action versions\n- Update pre-commit versions to latest\n\n## Motivation and Context\n\n- Avoid failing CI checks due to GitHub API rate limiting\n\n## Breaking Changes\n\n- No\n\n## How Has This Been Tested?\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\n- [x] I have executed `pre-commit run -a` on my pull request\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate dirs\n- check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,10 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,10 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,10 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ clowdhaus/[email protected]\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,10 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\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\nFixes #320 \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nThis is needed to prevent errors when trying to add a computed value for `custom_role_trust_policy` \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\nThose already passing valid values into `custom_role_trust_policy` will need to \r\nadd an extra input `create_custom_role_trust_policy = true` to prevent Terraform\r\nfrom trying to destroy policies.\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.82.0\n+ rev: v1.83.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-assumable-role/main.tf\n@@ -104,8 +104,9 @@ module \"iam_assumable_role_custom_trust_policy\" {\n \n role_name = \"iam_assumable_role_custom_trust_policy\"\n \n- custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n- custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+ create_custom_role_trust_policy = true\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n }\n \n data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n---\nmodules/iam-assumable-role/README.md\n@@ -46,10 +46,11 @@ No modules.\n | <a name=\"input_attach_admin_policy\"></a> [attach\\_admin\\_policy](#input\\_attach\\_admin\\_policy) | Whether to attach an admin policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_poweruser_policy\"></a> [attach\\_poweruser\\_policy](#input\\_attach\\_poweruser\\_policy) | Whether to attach a poweruser policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_readonly_policy\"></a> [attach\\_readonly\\_policy](#input\\_attach\\_readonly\\_policy) | Whether to attach a readonly policy to a role | `bool` | `false` | no |\n+| <a name=\"input_create_custom_role_trust_policy\"></a> [create\\_custom\\_role\\_trust\\_policy](#input\\_create\\_custom\\_role\\_trust\\_policy) | Whether to create a custom\\_role\\_trust\\_policy. Prevent errors with count, when custom\\_role\\_trust\\_policy is computed | `bool` | `false` | no |\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy. (Only valid if create\\_custom\\_role\\_trust\\_policy = true) | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -2,14 +2,15 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_partition\" \"current\" {}\n \n locals {\n- account_id = data.aws_caller_identity.current.account_id\n- partition = data.aws_partition.current.partition\n- role_sts_externalid = flatten([var.role_sts_externalid])\n- role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ account_id = data.aws_caller_identity.current.account_id\n+ partition = data.aws_partition.current.partition\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ custom_role_trust_policy_condition = var.create_custom_role_trust_policy ? var.custom_role_trust_policy : \"\"\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 0 : 1\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -68,7 +69,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 1 : 0\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -151,7 +152,7 @@ resource \"aws_iam_role\" \"this\" {\n permissions_boundary = var.role_permissions_boundary_arn\n \n assume_role_policy = coalesce(\n- var.custom_role_trust_policy,\n+ local.custom_role_trust_policy_condition,\n try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n data.aws_iam_policy_document.assume_role[0].json\n )\n---\nmodules/iam-assumable-role/variables.tf\n@@ -83,11 +83,17 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custom role trust policy\"\n+ description = \"A custom role trust policy. (Only valid if create_custom_role_trust_policy = true)\"\n type = string\n default = \"\"\n }\n \n+variable \"create_custom_role_trust_policy\" {\n+ description = \"Whether to create a custom_role_trust_policy. Prevent errors with count, when custom_role_trust_policy is computed\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.82.0\n+ rev: v1.83.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-assumable-role/main.tf\n@@ -104,8 +104,9 @@ module \"iam_assumable_role_custom_trust_policy\" {\n \n role_name = \"iam_assumable_role_custom_trust_policy\"\n \n- custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n- custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+ create_custom_role_trust_policy = true\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n }\n \n data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n---\nmodules/iam-assumable-role/README.md\n@@ -46,10 +46,11 @@ No modules.\n | <a name=\"input_attach_admin_policy\"></a> [attach\\_admin\\_policy](#input\\_attach\\_admin\\_policy) | Whether to attach an admin policy to a role | `bool` | `false` \n no |\n | <a name=\"input_attach_poweruser_policy\"></a> [attach\\_poweruser\\_policy](#input\\_attach\\_poweruser\\_policy) | Whether to attach a poweruser policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_readonly_policy\"></a> [attach\\_readonly\\_policy](#input\\_attach\\_readonly\\_policy) | Whether to attach a readonly policy to a role | `bool` | `false` | no |\n+| <a name=\"input_create_custom_role_trust_policy\"></a> [create\\_custom\\_role\\_trust\\_policy](#input\\_create\\_custom\\_role\\_trust\\_policy) | Whether to create a custom\\_role\\_trust\\_policy. Prevent errors with count, when custom\\_role\\_trust\\_policy is computed | `bool` | `false` | no |\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy. (Only valid if create\\_custom\\_role\\_trust\\_policy = true) | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -2,14 +2,15 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_partition\" \"current\" {}\n \n locals {\n- account_id = data.aws_caller_identity.current.account_id\n- partition = data.aws_partition.current.partition\n- role_sts_externalid = flatten([var.role_sts_externalid])\n- role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ account_id = data.aws_caller_identity.current.account_id\n+ partition = data.aws_partition.current.partition\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ custom_role_trust_policy_condition = var.create_custom_role_trust_policy ? var.custom_role_trust_policy : \"\"\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 0 : 1\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -68,7 +69,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 1 : 0\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -151,7 +152,7 @@ resource \"aws_iam_role\" \"this\" {\n permissions_boundary = var.role_permissions_boundary_arn\n \n assume_role_policy = coalesce(\n- var.custom_role_trust_policy,\n+ local.custom_role_trust_policy_condition,\n try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n data.aws_iam_policy_document.assume_role[0].json\n )\n---\nmodules/iam-assumable-role/variables.tf\n@@ -83,11 +83,17 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custom role trust policy\"\n+ description = \"A custom role trust policy. (Only valid if create_custom_role_trust_policy = true)\"\n type = string\n default = \"\"\n }\n \n+variable \"create_custom_role_trust_policy\" {\n+ description = \"Whether to create a custom_role_trust_policy. Prevent errors with count, when custom_role_trust_policy is computed\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.82.0\n+ rev: v1.83.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-assumable-role/main.tf\n@@ -104,8 +104,9 @@ module \"iam_assumable_role_custom_trust_policy\" {\n \n role_name = \"iam_assumable_role_custom_trust_policy\"\n \n- custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n- custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+ create_custom_role_trust_policy = true\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n }\n \n data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n---\nmodules/iam-assumable-role/README.md\n@@ -46,10 +46,11 @@ No modules.\n | <a name=\"input_attach_admin_policy\"></a> [attach\\_admin\\_policy](#input\\_attach\\_admin\\_policy) | Whether to attach an admin policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_poweruser_policy\"></a> [attach\\_poweruser\\_policy](#input\\_attach\\_poweruser\\_policy) | Whether to attach a poweruser policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_readonly_policy\"></a> [attach\\_readonly\\_policy](#input\\_attach\\_readonly\\_policy) | Whether to attach a readonly policy to a role | `bool` | `false` | no |\n+| <a name=\"input_create_custom_role_trust_policy\"></a> [create\\_custom\\_role\\_trust\\_policy](#input\\_create\\_custom\\_role\\_trust\\_policy) | Whether to create a custom\\_role\\_trust\\_policy. Prevent errors with count, when custom\\_role\\_trust\\_policy is computed | `bool` | `false` | no |\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy. (Only valid if create\\_custom\\_role\\_trust\\_policy = true) | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -2,14 +2,15 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_partition\" \"current\" {}\n \n locals {\n- account_id = data.aws_caller_identity.current.account_id\n- partition = data.aws_partition.current.partition\n- role_sts_externalid = flatten([var.role_sts_externalid])\n- role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ account_id = data.aws_caller_identity.current.account_id\n+ partition = data.aws_partition.current.partition\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ custom_role_trust_policy_condition = var.create_custom_role_trust_policy ? var.custom_role_trust_policy : \"\"\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 0 : 1\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -68,7 +69,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 1 : 0\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -151,7 +152,7 @@ resource \"aws_iam_role\" \"this\" {\n permissions_boundary = var.role_permissions_boundary_arn\n \n assume_role_policy = coalesce(\n- var.custom_role_trust_policy,\n+ local.custom_role_trust_policy_condition,\n try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n data.aws_iam_policy_document.assume_role[0].json\n )\n---\nmodules/iam-assumable-role/variables.tf\n@@ -83,11 +83,17 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custom role trust policy\"\n+ description = \"A custom role trust policy. (Only valid if 0 = true)\"\n type = string\n default = \"\"\n }\n \n+variable \"create_custom_role_trust_policy\" {\n+ description = \"Whether to create a custom_role_trust_policy. Prevent errors with count, when custom_role_trust_policy is computed\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.82.0\n+ rev: v1.83.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n---\nexamples/iam-assumable-role/main.tf\n@@ -104,8 +104,9 @@ module \"iam_assumable_role_custom_trust_policy\" {\n \n role_name = \"iam_assumable_role_custom_trust_policy\"\n \n- custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n- custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+ create_custom_role_trust_policy = true\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n }\n \n data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n---\nmodules/iam-assumable-role/README.md\n@@ -46,10 +46,11 @@ No modules.\n | <a name=\"input_attach_admin_policy\"></a> [attach\\_admin\\_policy](#input\\_attach\\_admin\\_policy) | Whether to attach an admin policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_poweruser_policy\"></a> [attach\\_poweruser\\_policy](#input\\_attach\\_poweruser\\_policy) | Whether to attach a poweruser policy to a role | `bool` | `false` | no |\n | <a name=\"input_attach_readonly_policy\"></a> [attach\\_readonly\\_policy](#input\\_attach\\_readonly\\_policy) | Whether to attach a readonly policy to a role | `bool` | `false` | no |\n+| <a name=\"input_create_custom_role_trust_policy\"></a> [create\\_custom\\_role\\_trust\\_policy](#input\\_create\\_custom\\_role\\_trust\\_policy) | Whether to create a custom\\_role\\_trust\\_policy. Prevent errors with count, when custom\\_role\\_trust\\_policy is computed | `bool` | `false` | no |\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy. (Only valid if create\\_custom\\_role\\_trust\\_policy = true) | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -2,14 +2,15 @@ data \"aws_caller_identity\" \"current\" {}\n data \"aws_partition\" \"current\" {}\n \n locals {\n- account_id = data.aws_caller_identity.current.account_id\n- partition = data.aws_partition.current.partition\n- role_sts_externalid = flatten([var.role_sts_externalid])\n- role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ account_id = data.aws_caller_identity.current.account_id\n+ partition = data.aws_partition.current.partition\n+ role_sts_externalid = flatten([var.role_sts_externalid])\n+ role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ custom_role_trust_policy_condition = var.create_custom_role_trust_policy ? var.custom_role_trust_policy : \"\"\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 0 : 1\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -68,7 +69,7 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n- count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+ count = !var.create_custom_role_trust_policy && var.role_requires_mfa ? 1 : 0\n \n dynamic \"statement\" {\n # https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/\n@@ -151,7 +152,7 @@ resource \"aws_iam_role\" \"this\" {\n permissions_boundary = var.role_permissions_boundary_arn\n \n assume_role_policy = coalesce(\n- var.custom_role_trust_policy,\n+ local.custom_role_trust_policy_condition,\n try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n data.aws_iam_policy_document.assume_role[0].json\n )\n---\nmodules/iam-assumable-role/variables.tf\n@@ -83,11 +83,17 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custom role trust policy\"\n+ description = \"A custom role trust policy. (Only valid if create_custom_role_trust_policy = true)\"\n type = string\n default = \"\"\n }\n \n+variable \"create_custom_role_trust_policy\" {\n+ description = \"Whether to create a custom_role_trust_policy. Prevent errors with count, when custom_role_trust_policy is computed\"\n+ type create = bool\n+ default = false\n+}\n+\n variable \"number_of_custom_role_policy_arns\" {\n description = \"Number of IAM policies to attach to IAM role\"\n type = number\n---\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`role_name` conflicts with `role_name_prefix` in the `iam-assumable-role` module. \r\n\r\n## Motivation and Context\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/318\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role/main.tf\n@@ -49,7 +49,7 @@ module \"iam_assumable_role_custom\" {\n \n create_role = true\n \n- role_name = \"custom\"\n+ role_name_prefix = \"custom-\"\n role_requires_mfa = false\n \n role_sts_externalid = \"some-id-goes-here\"\n---\nmodules/iam-assumable-role/README.md\n@@ -57,7 +57,7 @@ No modules.\n | <a name=\"input_poweruser_role_policy_arn\"></a> [poweruser\\_role\\_policy\\_arn](#input\\_poweruser\\_role\\_policy\\_arn) | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | <a name=\"input_readonly_role_policy_arn\"></a> [readonly\\_role\\_policy\\_arn](#input\\_readonly\\_role\\_policy\\_arn) | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n-| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n+| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -43,7 +43,7 @@ variable \"create_instance_profile\" {\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---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role/main.tf\n@@ -49,7 +49,7 @@ module \"iam_assumable_role_custom\" {\n \n create_role = true\n \n- role_name = \"custom\"\n+ role_name_prefix = \"custom-\"\n role_requires_mfa = false\n \n role_sts_externalid = \"some-id-goes-here\"\n---\nmodules/iam-assumable-role/README.md\n@@ -57,7 +57,7 @@ No modules.\n | <a name=\"input_poweruser_role_policy_arn\"></a> [poweruser\\_role\\_policy\\_arn](#input\\_poweruser\\_role\\_policy\\_arn) | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | <a name=\"input_readonly_role_policy_arn\"></a> [readonly\\_role\\_policy\\_arn](#input\\_readonly\\_role\\_policy\\_arn) | Policy ARN to use true\n readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n-| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n+| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -43,7 +43,7 @@ variable \"create_instance_profile\" {\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---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role/main.tf\n@@ -49,7 +49,7 @@ module \"iam_assumable_role_custom\" {\n \n create_role = true\n \n- role_name = \"custom\"\n+ role_name_prefix = \"custom-\"\n role_requires_mfa = false\n \n role_sts_externalid = \"some-id-goes-here\"\n---\nmodules/iam-assumable-role/README.md\n@@ -57,7 +57,7 @@ No Role | <a name=\"input_poweruser_role_policy_arn\"></a> [poweruser\\_role\\_policy\\_arn](#input\\_poweruser\\_role\\_policy\\_arn) | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | <a name=\"input_readonly_role_policy_arn\"></a> [readonly\\_role\\_policy\\_arn](#input\\_readonly\\_role\\_policy\\_arn) | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n-| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n+| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -43,7 +43,7 @@ variable \"create_instance_profile\" {\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---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role/main.tf\n@@ -49,7 +49,7 @@ module \"iam_assumable_role_custom\" {\n \n create_role = true\n \n- role_name = \"custom\"\n+ role_name_prefix = \"custom-\"\n role_requires_mfa = false\n \n role_sts_externalid = \"some-id-goes-here\"\n---\nmodules/iam-assumable-role/README.md\n@@ -57,7 +57,7 @@ No modules.\n | <a name=\"input_poweruser_role_policy_arn\"></a> [poweruser\\_role\\_policy\\_arn](#input\\_poweruser\\_role\\_policy\\_arn) | Policy ARN to use for poweruser role | `string` | `\"arn:aws:iam::aws:policy/PowerUserAccess\"` | no |\n | <a name=\"input_readonly_role_policy_arn\"></a> [readonly\\_role\\_policy\\_arn](#input\\_readonly\\_role\\_policy\\_arn) | Policy ARN to use for readonly role | `string` | `\"arn:aws:iam::aws:policy/ReadOnlyAccess\"` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `\"\"` | no |\n-| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n+| <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -43,7 +43,7 @@ variable \"create_instance_profile\" {\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---\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\nAdded the abbility to append optional extra trusted roles actions appart from the default \"AssumeRoleWithSAML\" in the iam-assumable-role-with-saml module\r\n\r\n## Motivation and Context\r\nWanted the to utilize the module to avoid rewiting all the logic from scratch but also have the ability to add some extra actions that apply to our use cases.\r\n\r\n## Breaking Changes\r\nNone as far as I know.\r\n\r\n## How Has This Been Tested?\r\nInternally in our organisation in many deployments. Unable to showcase.\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-saml/README.md\n@@ -52,6 +52,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Extra Actions of STS | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -34,7 +34,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n \n statement {\n effect = \"Allow\"\n- actions = [\"sts:AssumeRoleWithSAML\"]\n+ actions = compact(distinct(concat([\"sts:AssumeRoleWithSAML\"], var.trusted_role_actions)))\n \n principals {\n type = \"Federated\"\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -87,3 +87,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) false\n }\n+\n+variable \"trusted_role_actions\" {\n+ description = \"Extra Actions of STS\"\n+ type = list(string)\n+ default = [\"\"]\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-saml/README.md\n@@ -52,6 +52,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Extra Actions of STS | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -34,7 +34,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n \n statement {\n effect = \"Allow\"\n- actions = [\"sts:AssumeRoleWithSAML\"]\n+ actions = compact(distinct(concat([\"sts:AssumeRoleWithSAML\"], var.trusted_role_actions)))\n \n principals {\n type = \"Federated\"\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -87,3 +87,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"trusted_role_actions\" {\n+ description = \"Extra Actions of STS\"\n+ type = list(string)\n+ default = [\"\"]\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-saml/README.md\n@@ -52,6 +52,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Extra Actions of STS | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -34,7 +34,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n \n statement {\n effect = \"Allow\"\n- actions = [\"sts:AssumeRoleWithSAML\"]\n+ actions = compact(distinct(concat([\"sts:AssumeRoleWithSAML\"], var.trusted_role_actions)))\n \n principals {\n type = \"Federated\"\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -87,3 +87,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable -34,7 {\n+ description = \"Extra Actions of STS\"\n+ type = list(string)\n+ default = [\"\"]\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-saml/README.md\n@@ -52,6 +52,7 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_actions\"></a> [trusted\\_role\\_actions](#input\\_trusted\\_role\\_actions) | Extra Actions of STS | `list(string)` | <pre>[<br> \"\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -34,7 +34,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_saml\" {\n \n statement {\n effect = \"Allow\"\n- actions = [\"sts:AssumeRoleWithSAML\"]\n+ actions = compact(distinct(concat([\"sts:AssumeRoleWithSAML\"], var.trusted_role_actions)))\n \n principals {\n type = \"Federated\"\n---\nmodules/iam-assumable-role-with-saml/variables.tf\n@@ -87,3 +87,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"trusted_role_actions\" {\n+ description = \"Extra Actions of STS\"\n+ type = list(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:\nhttps://docs.aws.amazon.com/systems-manager/latest/userguide/integrating_csi_driver.html#integrating_csi_driver_access\r\n\r\n## Description\r\naccording to documentation ssm:GetParameters permission is required\r\n\r\n## Motivation and Context\r\natm AWS CSI Secret Store Driver failed to get parameter with error\r\n`MountVolume.SetUp failed for volume \"volume_name\" : rpc error: code = Unknown desc = failed to mount secrets store objects for pod namespace/pod-647dbc98b4-h8kl4, err: rpc error: code = Unknown desc = Failed fetching parameters: WebIdentityErr: failed to retrieve credentials caused by: AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity status code: 403, request id: request-uuid`\r\n\r\n## Breaking Changes\r\n-\r\n\r\n## How Has This Been Tested?\r\n- use https://github.com/aws/secrets-store-csi-driver-provider-aws\r\n- `attach_external_secrets_policy = true`; `external_secrets_ssm_parameter_arns = [\"cluster-oidc-provider-arn\"]`\r\n- Deployment spec: specify serviceAccountName with\r\n```\r\n annotations = {\r\n \"eks.amazonaws.com/role-arn\" = module.secrets-store-csi-irsa-role.iam_role_arn\r\n }\r\n```\r\n- mount SecretProviderClass with `provider: aws`\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n actions - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -410,7 +410,10 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n statement {\n- actions = [\"ssm:GetParameter\"]\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -410,7 +410,10 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n statement {\n- actions = [\"ssm:GetParameter\"]\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: actions rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -410,7 +410,10 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n statement {\n- actions = [\"ssm:GetParameter\"]\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n repos:\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -410,7 +410,10 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n count = var.create_role && var.attach_external_secrets_policy ? 1 : 0\n \n statement {\n- actions = [\"ssm:GetParameter\"]\n+ actions = [\n+ \"ssm:GetParameter\",\n+ \"ssm:GetParameters\",\n+ ]\n resources = var.external_secrets_ssm_parameter_arns\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\nSupport IAM access key status. \r\n\r\n## Motivation and Context\r\n- Resolves #314\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nexamples/iam-user/README.md\n@@ -33,6 +33,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n---\nexamples/iam-user/main.tf\n@@ -33,3 +33,16 @@ module \"iam_user2\" {\n create_iam_user_login_profile = false\n create_iam_access_key = true\n }\n+\n+###################################################################\n+# IAM user with inactive IAM access key\n+###################################################################\n+module \"iam_user3\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin5\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ iam_access_key_status = \"Inactive\"\n+}\n---\nmodules/iam-user/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_access_key_status\"></a> [iam\\_access\\_key\\_status](#input\\_iam\\_access\\_key\\_status) | Access key status to apply. | `string` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -28,12 +28,14 @@ resource \"aws_iam_access_key\" \"this\" {\n \n user = aws_iam_user.this[0].name\n pgp_key = var.pgp_key\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_access_key\" \"this_no_pgp\" {\n count = var.create_user && var.create_iam_access_key && var.pgp_key == \"\" ? 1 : 0\n \n- user = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_user_ssh_key\" \"this\" {\n---\nmodules/iam-user/variables.tf\n@@ -39,6 +39,12 @@ variable \"pgp_key\" {\n default = \"\"\n }\n \n+variable \"iam_access_key_status\" {\n+ description = \"Access key status to apply.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"password_reset_required\" {\n description = \"Whether the user should be forced to reset the generated password on |------|--------|---------|\n login.\"\n type = bool\n---\n\n\n---\n\nChoice B:\nexamples/iam-user/README.md\n@@ -33,6 +33,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n---\nexamples/iam-user/main.tf\n@@ -33,3 +33,16 @@ module \"iam_user2\" {\n create_iam_user_login_profile = false\n create_iam_access_key = true\n }\n+\n+###################################################################\n+# IAM user with inactive IAM access key\n+###################################################################\n+module \"iam_user3\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin5\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ iam_access_key_status = \"Inactive\"\n+}\n---\nmodules/iam-user/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_access_key_status\"></a> [iam\\_access\\_key\\_status](#input\\_iam\\_access\\_key\\_status) | Access key status to apply. | `string` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -28,12 +28,14 @@ resource \"aws_iam_access_key\" \"this\" {\n \n user = aws_iam_user.this[0].name\n pgp_key = var.pgp_key\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_access_key\" \"this_no_pgp\" {\n count = var.create_user && var.create_iam_access_key && var.pgp_key == \"\" ? 1 : 0\n \n- user = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_user_ssh_key\" \"this\" {\n---\nmodules/iam-user/variables.tf\n@@ -39,6 +39,12 @@ variable \"pgp_key\" {\n default = \"\"\n }\n \n+variable \"iam_access_key_status\" {\n+ description = \"Access key status to apply.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"password_reset_required\" {\n description = \"Whether the user should be forced to reset the generated password on first login.\"\n type = bool\n---\n\n\n---\n\nChoice C:\nexamples/iam-user/README.md\n@@ -33,6 +33,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n---\nexamples/iam-user/main.tf\n@@ -33,3 +33,16 @@ module \"iam_user2\" {\n create_iam_user_login_profile = false\n create_iam_access_key = true\n }\n+\n+###################################################################\n+# IAM user with inactive IAM access key\n+###################################################################\n+module \"iam_user3\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin5\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ iam_access_key_status = \"Inactive\"\n+}\n---\nmodules/iam-user/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_access_key_status\"></a> [iam\\_access\\_key\\_status](#input\\_iam\\_access\\_key\\_status) | Access key status to apply. | `string` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -28,12 +28,14 @@ resource \"aws_iam_access_key\" \"this\" {\n \n user name=\"input_password_reset_required\"></a> = aws_iam_user.this[0].name\n pgp_key = var.pgp_key\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_access_key\" \"this_no_pgp\" {\n count = var.create_user && var.create_iam_access_key && var.pgp_key == \"\" ? 1 : 0\n \n- user = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_user_ssh_key\" \"this\" {\n---\nmodules/iam-user/variables.tf\n@@ -39,6 +39,12 @@ variable \"pgp_key\" {\n default = \"\"\n }\n \n+variable \"iam_access_key_status\" {\n+ description = \"Access key status to apply.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"password_reset_required\" {\n description = \"Whether the user should be forced to reset the generated password on first login.\"\n type = bool\n---\n\n\n---\n\nChoice D:\nexamples/iam-user/README.md\n@@ -33,6 +33,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_user\"></a> [iam\\_user](#module\\_iam\\_user) | ../../modules/iam-user | n/a |\n | <a name=\"module_iam_user2\"></a> [iam\\_user2](#module\\_iam\\_user2) | ../../modules/iam-user | n/a |\n+| <a name=\"module_iam_user3\"></a> [iam\\_user3](#module\\_iam\\_user3) | ../../modules/iam-user | n/a |\n \n ## Resources\n \n---\nexamples/iam-user/main.tf\n@@ -33,3 +33,16 @@ module \"iam_user2\" {\n create_iam_user_login_profile = false\n create_iam_access_key = true\n }\n+\n+###################################################################\n+# IAM user with inactive IAM access key\n+###################################################################\n+module \"iam_user3\" {\n+ source = \"../../modules/iam-user\"\n+\n+ name = \"vasya.pupkin5\"\n+\n+ create_iam_user_login_profile = false\n+ create_iam_access_key = true\n+ iam_access_key_status = \"Inactive\"\n+}\n---\nmodules/iam-user/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_access_key_status\"></a> [iam\\_access\\_key\\_status](#input\\_iam\\_access\\_key\\_status) | Access key status to apply. | `string` | `null` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -28,12 +28,14 @@ resource \"aws_iam_access_key\" \"this\" {\n \n user = aws_iam_user.this[0].name\n pgp_key = var.pgp_key\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_access_key\" \"this_no_pgp\" {\n count = var.create_user && var.create_iam_access_key && var.pgp_key == \"\" ? 1 : 0\n \n- user = aws_iam_user.this[0].name\n+ user = aws_iam_user.this[0].name\n+ status = var.iam_access_key_status\n }\n \n resource \"aws_iam_user_ssh_key\" \"this\" {\n---\nmodules/iam-user/variables.tf\n@@ -39,6 +39,12 @@ variable \"pgp_key\" {\n default = \"\"\n }\n \n+variable \"iam_access_key_status\" {\n+ description = \"Access key status to apply.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"password_reset_required\" {\n description = \"Whether the user should be forced to reset the generated password on first login.\"\n type = bool\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\nFix the `IAMSelfManagement` policy to allow virtual MFA devices creation.\r\n\r\nDue to [this new feature](https://aws.amazon.com/blogs/security/you-can-now-assign-multiple-mfa-devices-in-iam/), the resource name of virtual MFA devices change and the policy doesn't work anymore. \r\n\r\nThe wildcard in the MFA resource name is required now, because the user must specify a name for his virtual MFA device, and this is a part of the resource name.\r\n\r\n## Motivation and Context\r\n- Resolves #312 \r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n- [x] I have directly edited the `IAMSelfManagement` policy and added successfully a new virtual MFA device.\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -9,83 +9,146 @@ locals {\n partition = data.aws_partition.current.partition\n }\n \n+# Allows MFA-authenticated IAM users to manage their own credentials on the My security credentials page\n+# https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html\n data \"aws_iam_policy_document\" \"iam_self_management\" {\n statement {\n- sid = \"AllowSelfManagement\"\n+ sid = \"AllowViewAccountInfo\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListVirtualMFADevices\"\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnPasswords\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:ChangePassword\",\n+ \"iam:GetUser\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnAccessKeys\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n \"iam:CreateAccessKey\",\n- \"iam:CreateLoginProfile\",\n- \"iam:CreateVirtualMFADevice\",\n \"iam:DeleteAccessKey\",\n- \"iam:DeleteLoginProfile\",\n- \"iam:DeleteVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GenerateCredentialReport\",\n- \"iam:GenerateServiceLastAccessedDetails\",\n- \"iam:Get*\",\n- \"iam:List*\",\n- \"iam:ResyncMFADevice\",\n- \"iam:UpdateAccessKey\",\n- \"iam:UpdateLoginProfile\",\n- \"iam:UpdateUser\",\n- \"iam:UploadSigningCertificate\",\n- \"iam:UploadSSHPublicKey\",\n- \"iam:TagUser\",\n- \"iam:ListUserTags\",\n- \"iam:UntagUser\",\n+ \"iam:ListAccessKeys\",\n+ \"iam:UpdateAccessKey\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnSigningCertificates\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:DeleteSigningCertificate\",\n+ \"iam:ListSigningCertificates\",\n+ \"iam:UpdateSigningCertificate\",\n+ \"iam:UploadSigningCertificate\"\n ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n statement {\n- sid = \"AllowIAMReadOnly\"\n+ sid = \"AllowManageOwnSSHPublicKeys\"\n+\n+ effect = \"Allow\"\n \n actions = [\n- \"iam:Get*\",\n- \"iam:List*\",\n+ \"iam:DeleteSSHPublicKey\",\n+ \"iam:GetSSHPublicKey\",\n+ \"iam:ListSSHPublicKeys\",\n+ \"iam:UpdateSSHPublicKey\",\n+ \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"*\"]\n- effect = \"Allow\"\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n- # Allow to deactivate MFA only when logging in with MFA\n statement {\n- sid = \"AllowDeactivateMFADevice\"\n+ sid = \"AllowManageOwnGitCredentials\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateServiceSpecificCredential\",\n+ \"iam:DeleteServiceSpecificCredential\",\n+ \"iam:ListServiceSpecificCredentials\",\n+ \"iam:ResetServiceSpecificCredential\",\n+ \"iam:UpdateServiceSpecificCredential\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnVirtualMFADevice\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateVirtualMFADevice\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:mfa/*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnUserMFA\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:DeactivateMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ResyncMFADevice\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+\n+ }\n+\n+ statement {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+\n+ effect = \"Deny\"\n+\n+ not_actions = [\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n ]\n \n- condition {\n- test = \"Bool\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"true\"]\n- }\n+ resources = [\"*\"]\n \n condition {\n- test = \"NumericLessThan\"\n- variable = \"aws:MultiFactorAuthAge\"\n- values = [\"3600\"]\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -9,83 +9,146 @@ locals {\n partition = data.aws_partition.current.partition\n }\n \n+# Allows MFA-authenticated IAM users to manage their own credentials on the My security credentials page\n+# https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html\n data \"aws_iam_policy_document\" \"iam_self_management\" {\n statement {\n- sid = \"AllowSelfManagement\"\n+ sid = \"AllowViewAccountInfo\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListVirtualMFADevices\"\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnPasswords\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:ChangePassword\",\n+ \"iam:GetUser\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnAccessKeys\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n \"iam:CreateAccessKey\",\n- \"iam:CreateLoginProfile\",\n- \"iam:CreateVirtualMFADevice\",\n \"iam:DeleteAccessKey\",\n- \"iam:DeleteLoginProfile\",\n- \"iam:DeleteVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GenerateCredentialReport\",\n- \"iam:GenerateServiceLastAccessedDetails\",\n- \"iam:Get*\",\n- \"iam:List*\",\n- \"iam:ResyncMFADevice\",\n- \"iam:UpdateAccessKey\",\n- \"iam:UpdateLoginProfile\",\n- \"iam:UpdateUser\",\n- \"iam:UploadSigningCertificate\",\n- \"iam:UploadSSHPublicKey\",\n- \"iam:TagUser\",\n- \"iam:ListUserTags\",\n- \"iam:UntagUser\",\n+ \"iam:ListAccessKeys\",\n+ \"iam:UpdateAccessKey\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnSigningCertificates\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:DeleteSigningCertificate\",\n+ \"iam:ListSigningCertificates\",\n+ \"iam:UpdateSigningCertificate\",\n+ \"iam:UploadSigningCertificate\"\n ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n statement {\n- sid = \"AllowIAMReadOnly\"\n+ sid = \"AllowManageOwnSSHPublicKeys\"\n+\n+ effect = \"Allow\"\n \n actions = [\n- \"iam:Get*\",\n- \"iam:List*\",\n+ \"iam:DeleteSSHPublicKey\",\n+ \"iam:GetSSHPublicKey\",\n+ \"iam:ListSSHPublicKeys\",\n+ \"iam:UpdateSSHPublicKey\",\n+ \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"*\"]\n- effect = \"Allow\"\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n- # Allow to deactivate MFA only when logging in with MFA\n statement {\n- sid = \"AllowDeactivateMFADevice\"\n+ sid = \"AllowManageOwnGitCredentials\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateServiceSpecificCredential\",\n+ \"iam:DeleteServiceSpecificCredential\",\n+ \"iam:ListServiceSpecificCredentials\",\n+ \"iam:ResetServiceSpecificCredential\",\n+ \"iam:UpdateServiceSpecificCredential\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnVirtualMFADevice\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateVirtualMFADevice\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:mfa/*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnUserMFA\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:DeactivateMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ResyncMFADevice\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+\n+ }\n+\n+ statement {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+\n+ effect = \"Deny\"\n+\n+ not_actions = [\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n ]\n \n- condition {\n- test = \"Bool\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"true\"]\n- }\n+ resources = [\"*\"]\n \n condition {\n- test = \"NumericLessThan\"\n- variable = \"aws:MultiFactorAuthAge\"\n- values = [\"3600\"]\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -9,83 +9,146 @@ locals {\n partition = data.aws_partition.current.partition\n }\n \n+# Allows MFA-authenticated IAM users to manage their own credentials on the My security credentials page\n+# https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html\n data \"aws_iam_policy_document\" \"iam_self_management\" {\n statement {\n- sid = \"AllowSelfManagement\"\n+ sid = \"AllowViewAccountInfo\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListVirtualMFADevices\"\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnPasswords\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:ChangePassword\",\n+ \"iam:GetUser\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnAccessKeys\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n \"iam:CreateAccessKey\",\n- \"iam:CreateLoginProfile\",\n- \"iam:CreateVirtualMFADevice\",\n \"iam:DeleteAccessKey\",\n- \"iam:DeleteLoginProfile\",\n- \"iam:DeleteVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GenerateCredentialReport\",\n- \"iam:GenerateServiceLastAccessedDetails\",\n- \"iam:Get*\",\n- \"iam:List*\",\n- \"iam:ResyncMFADevice\",\n- \"iam:UpdateAccessKey\",\n- \"iam:UpdateLoginProfile\",\n- \"iam:UpdateUser\",\n- \"iam:UploadSigningCertificate\",\n- \"iam:UploadSSHPublicKey\",\n- \"iam:TagUser\",\n- \"iam:ListUserTags\",\n- \"iam:UntagUser\",\n+ \"iam:ListAccessKeys\",\n+ \"iam:UpdateAccessKey\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnSigningCertificates\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:DeleteSigningCertificate\",\n+ \"iam:ListSigningCertificates\",\n+ \"iam:UpdateSigningCertificate\",\n+ \"iam:UploadSigningCertificate\"\n ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n statement {\n- sid = \"AllowIAMReadOnly\"\n+ sid = \"AllowManageOwnSSHPublicKeys\"\n+\n+ effect = \"Allow\"\n \n actions = [\n- \"iam:Get*\",\n- \"iam:List*\",\n+ \"iam:DeleteSSHPublicKey\",\n+ \"iam:GetSSHPublicKey\",\n+ \"iam:ListSSHPublicKeys\",\n+ \"iam:UpdateSSHPublicKey\",\n+ \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"*\"]\n- effect = \"Allow\"\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n- # Allow to deactivate MFA only when logging in with MFA\n statement {\n- sid = \"AllowDeactivateMFADevice\"\n+ sid = \"AllowManageOwnGitCredentials\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateServiceSpecificCredential\",\n+ \"iam:DeleteServiceSpecificCredential\",\n+ \"iam:ListServiceSpecificCredentials\",\n+ \"iam:ResetServiceSpecificCredential\",\n+ \"iam:UpdateServiceSpecificCredential\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnVirtualMFADevice\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateVirtualMFADevice\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:mfa/*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnUserMFA\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:DeactivateMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ResyncMFADevice\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+\n+ }\n+\n+ statement {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+\n+ effect = \"Deny\"\n+\n+ not_actions = [\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n ]\n \n- condition {\n- test = \"Bool\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"true\"]\n- }\n+ resources = [\"*\"]\n \n condition {\n- test = \"NumericLessThan\"\n- variable = \"aws:MultiFactorAuthAge\"\n- values = [\"3600\"]\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ users values = [\"false\"]\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -9,83 +9,146 @@ locals {\n partition = data.aws_partition.current.partition\n }\n \n+# Allows MFA-authenticated IAM users to manage their own credentials on the My security credentials page\n+# https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html\n data \"aws_iam_policy_document\" \"iam_self_management\" {\n statement {\n- sid = \"AllowSelfManagement\"\n+ sid = \"AllowViewAccountInfo\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:GetAccountPasswordPolicy\",\n+ \"iam:ListVirtualMFADevices\"\n+ ]\n+\n+ resources = [\"*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnPasswords\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:ChangePassword\",\n+ \"iam:GetUser\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnAccessKeys\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n \"iam:CreateAccessKey\",\n- \"iam:CreateLoginProfile\",\n- \"iam:CreateVirtualMFADevice\",\n \"iam:DeleteAccessKey\",\n- \"iam:DeleteLoginProfile\",\n- \"iam:DeleteVirtualMFADevice\",\n- \"iam:EnableMFADevice\",\n- \"iam:GenerateCredentialReport\",\n- \"iam:GenerateServiceLastAccessedDetails\",\n- \"iam:Get*\",\n- \"iam:List*\",\n- \"iam:ResyncMFADevice\",\n- \"iam:UpdateAccessKey\",\n- \"iam:UpdateLoginProfile\",\n- \"iam:UpdateUser\",\n- \"iam:UploadSigningCertificate\",\n- \"iam:UploadSSHPublicKey\",\n- \"iam:TagUser\",\n- \"iam:ListUserTags\",\n- \"iam:UntagUser\",\n+ \"iam:ListAccessKeys\",\n+ \"iam:UpdateAccessKey\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnSigningCertificates\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:DeleteSigningCertificate\",\n+ \"iam:ListSigningCertificates\",\n+ \"iam:UpdateSigningCertificate\",\n+ \"iam:UploadSigningCertificate\"\n ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n statement {\n- sid = \"AllowIAMReadOnly\"\n+ sid = \"AllowManageOwnSSHPublicKeys\"\n+\n+ effect = \"Allow\"\n \n actions = [\n- \"iam:Get*\",\n- \"iam:List*\",\n+ \"iam:DeleteSSHPublicKey\",\n+ \"iam:GetSSHPublicKey\",\n+ \"iam:ListSSHPublicKeys\",\n+ \"iam:UpdateSSHPublicKey\",\n+ \"iam:UploadSSHPublicKey\"\n ]\n \n- resources = [\"*\"]\n- effect = \"Allow\"\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n }\n \n- # Allow to deactivate MFA only when logging in with MFA\n statement {\n- sid = \"AllowDeactivateMFADevice\"\n+ sid = \"AllowManageOwnGitCredentials\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateServiceSpecificCredential\",\n+ \"iam:DeleteServiceSpecificCredential\",\n+ \"iam:ListServiceSpecificCredentials\",\n+ \"iam:ResetServiceSpecificCredential\",\n+ \"iam:UpdateServiceSpecificCredential\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnVirtualMFADevice\"\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"iam:CreateVirtualMFADevice\"\n+ ]\n+\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:mfa/*\"]\n+ }\n+\n+ statement {\n+ sid = \"AllowManageOwnUserMFA\"\n \n effect = \"Allow\"\n \n actions = [\n \"iam:DeactivateMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ResyncMFADevice\"\n ]\n \n- # Allow for both users with \"path\" and without it\n- resources = [\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\",\n- \"arn:${local.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}\",\n+ resources = [\"arn:${local.partition}:iam::${local.aws_account_id}:user/$${aws:username}\"]\n+\n+ }\n+\n+ statement {\n+ sid = \"DenyAllExceptListedIfNoMFA\"\n+\n+ effect = \"Deny\"\n+\n+ not_actions = [\n+ \"iam:CreateVirtualMFADevice\",\n+ \"iam:EnableMFADevice\",\n+ \"iam:GetUser\",\n+ \"iam:ListMFADevices\",\n+ \"iam:ListVirtualMFADevices\",\n+ \"iam:ResyncMFADevice\",\n+ \"sts:GetSessionToken\"\n ]\n \n- condition {\n- test = \"Bool\"\n- variable = \"aws:MultiFactorAuthPresent\"\n- values = [\"true\"]\n- }\n+ resources = [\"*\"]\n \n condition {\n- test = \"NumericLessThan\"\n- variable = \"aws:MultiFactorAuthAge\"\n- values = [\"3600\"]\n+ test = \"BoolIfExists\"\n+ variable = \"aws:MultiFactorAuthPresent\"\n+ values = [\"false\"]\n }\n }\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- Ensure that GitHub OIDC subject prefixes are normalied for `repo:`\r\n\r\n## Motivation and Context\r\n- All of the `subjects` used in the `iam-github-oidc-role` will need to start with `repo:` so the code originally added that for users. However, nearly all documentation shows the subject with `repo:...` and users add this text into their subjects. This results in subjects that then look like `repo:repo:...` which is incorrect. This change normalizes the text to ensure that subjects only start with `repo:...` regardless of whether the user adds it or not in their provided subjects\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-github-oidc/main.tf\n@@ -37,8 +37,14 @@ module \"iam_github_oidc_provider_disabled\" {\n module \"iam_github_oidc_role\" {\n source = \"../../modules/iam-github-oidc-role\"\n \n+ name = local.name\n+\n # This should be updated to suit your organization, repository, references/branches, etc.\n- subjects = [\"terraform-aws-modules/terraform-aws-iam:*\"]\n+ subjects = [\n+ # You can prepend with `repo:` but it is not required\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n \n policies = {\n additional = aws_iam_policy.additional.arn\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -44,7 +44,8 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"StringLike\"\n variable = \"${local.provider_url}:sub\"\n- values = [for subject in var.subjects : \"repo:${subject}\"]\n+ # Strip `repo:` to normalize for cases where users may prepend it\n+ values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-github-oidc/main.tf\n@@ -37,8 +37,14 @@ module \"iam_github_oidc_provider_disabled\" {\n module \"iam_github_oidc_role\" {\n source = \"../../modules/iam-github-oidc-role\"\n \n+ name = local.name\n+\n # This should be in to suit your organization, repository, references/branches, etc.\n- subjects = [\"terraform-aws-modules/terraform-aws-iam:*\"]\n+ subjects = [\n+ # You can prepend with `repo:` but it is not required\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n \n policies = {\n additional = aws_iam_policy.additional.arn\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -44,7 +44,8 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"StringLike\"\n variable = \"${local.provider_url}:sub\"\n- values = [for subject in var.subjects : \"repo:${subject}\"]\n+ # Strip `repo:` to normalize for cases where users may prepend it\n+ values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-github-oidc/main.tf\n@@ -37,8 +37,14 @@ module \"iam_github_oidc_provider_disabled\" {\n module \"iam_github_oidc_role\" {\n source = \"../../modules/iam-github-oidc-role\"\n \n+ name = local.name\n+\n # This should be updated to suit your organization, repository, references/branches, etc.\n- subjects = [\"terraform-aws-modules/terraform-aws-iam:*\"]\n+ subjects = [\n+ # You can prepend with `repo:` but it is not required\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n \n policies = {\n additional aws_iam_policy.additional.arn\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -44,7 +44,8 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"StringLike\"\n variable = \"${local.provider_url}:sub\"\n- values = [for subject in var.subjects : \"repo:${subject}\"]\n+ # Strip `repo:` to normalize for cases where users may prepend it\n+ values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-github-oidc/main.tf\n@@ -37,8 +37,14 @@ module \"iam_github_oidc_provider_disabled\" {\n module \"iam_github_oidc_role\" {\n source = \"../../modules/iam-github-oidc-role\"\n \n+ name = local.name\n+\n # This should be updated to suit your organization, repository, references/branches, etc.\n- subjects = [\"terraform-aws-modules/terraform-aws-iam:*\"]\n+ subjects = [\n+ # You can prepend with `repo:` but it is not required\n+ \"repo:terraform-aws-modules/terraform-aws-iam:pull_request\",\n+ \"terraform-aws-modules/terraform-aws-iam:ref:refs/heads/master\",\n+ ]\n \n policies = {\n additional = aws_iam_policy.additional.arn\n---\nmodules/iam-github-oidc-role/main.tf\n@@ -44,7 +44,8 @@ data \"aws_iam_policy_document\" \"this\" {\n condition {\n test = \"StringLike\"\n variable = \"${local.provider_url}:sub\"\n- values = [for subject in var.subjects : \"repo:${subject}\"]\n+ # Strip `repo:` to normalize for cases where users may prepend it\n+ values = [for subject in var.subjects : \"repo:${trimprefix(subject, \"repo:\")}\"]\n }\n }\n }\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:\nExternal secrets uses ListSecrets when searching for secrets by tag.\r\n\r\nhttps://github.com/external-secrets/external-secrets/issues/1443\r\n\r\n## Description\r\nAdd `secretsmanager:ListSecrets` to external-secrets policy.\r\n\r\n## Motivation and Context\r\nAllows external secrets controller list all secrets when searching for secrets by tag.\r\n\r\n## Breaking Changes\r\nNo breaking changes.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nI tested it by manually updating the policy in AWS.\r\n\r\nBefore updating it:\r\n\r\n```\r\n{\"level\":\"error\",\"ts\":1667943642.1480799,\"logger\":\"controllers.ExternalSecret\",\"msg\":\"could not get secret data from provider\",\"ExternalSecret\":\"test/linkinbio-api\",\"SecretStore\":\"test/later-test-store\",\"error\":\"AccessDeniedException: User: arn:aws:sts::795986403160:assumed-role/ExternalSecretStore20221107234613050800000003/external-secrets-provider-aws is not authorized to perform: secretsmanager:ListSecrets because no identity-based policy allows the secretsmanager:ListSecrets action\\n\\tstatus code: 400, request id: 31a64aaf-8436-4008-9faf-cd27a56122b2\",\"stacktrace\":\"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\\n\\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:114\\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\\n\\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:311\\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\\n\\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\\n\\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227\"}\r\n```\r\n\r\nAfter updating:\r\n\r\n```\r\n{\"level\":\"info\",\"ts\":1667943672.3597736,\"logger\":\"controllers.ExternalSecret\",\"msg\":\"reconciled secret\",\"ExternalSecret\":\"test/linkinbio-api\",\"SecretStore\":\"test/later-test-store\"}\r\n```\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -414,6 +414,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n+ statement {\n+ actions = [\"secretsmanager:ListSecrets\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n actions = [\n \"secretsmanager:GetResourcePolicy\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -414,6 +414,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n+ statement {\n+ actions = [\"secretsmanager:ListSecrets\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n actions = [\n \"secretsmanager:GetResourcePolicy\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -414,6 +414,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n+ statement {\n+ actions = [\"secretsmanager:ListSecrets\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n actions = [\n \"secretsmanager:GetResourcePolicy\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -414,6 +414,11 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n resources = var.external_secrets_ssm_parameter_arns\n }\n \n+ statement {\n+ actions = [\"secretsmanager:ListSecrets\"]\n+ resources = [\"*\"]\n+ }\n+\n statement {\n actions = [\n \"secretsmanager:GetResourcePolicy\",\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:\nSigned-off-by: Fernando Miguel <[email protected]>\r\n\r\n## Description\r\nThe next version of Karpenter adds support for NTH: https://github.com/aws/karpenter/pull/2546/files\r\n\r\n## Motivation and Context\r\nThis PR adds the IAM changes to this module.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -206,6 +206,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -509,24 +509,25 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n # Karpenter Controller Policy\n ################################################################################\n \n-# curl -fsSL https://karpenter.sh/v0.6.1/getting-started/cloudformation.yaml\n+# https://github.com/aws/karpenter/blob/502d275cc330fb0f2435b124935c49632146d945/website/content/en/v0.19.0/getting-started/getting-started-with-eksctl/cloudformation.yaml#L34\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n statement {\n actions = [\n- \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateFleet\",\n+ \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateTags\",\n- \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n- \"ec2:DescribeSecurityGroups\",\n- \"ec2:DescribeSubnets\",\n- \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n- \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:DescribeSubnets\",\n \"pricing:GetProducts\",\n ]\n \n@@ -583,6 +584,20 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"iam:PassRole\"]\n resources = var.karpenter_controller_node_iam_role_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"sqs:DeleteMessage\",\n+ \"sqs:GetQueueAttributes\",\n+ \"sqs:GetQueueUrl\",\n+ \"sqs:ReceiveMessage\",\n+ ]\n+ <a = [var.karpenter_sqs_queue_arn]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"karpenter_controller\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -215,6 +215,12 @@ variable \"karpenter_subnet_account_id\" {\n default = \"\"\n }\n \n+variable \"karpenter_sqs_queue_arn\" {\n+ description = \"(Optional) ARN of SQS used by Karpenter when native node termination handling is enabled\"\n+ type = string\n+ default = null\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -206,6 +206,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -509,24 +509,25 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n # Karpenter Controller Policy\n ################################################################################\n \n-# curl -fsSL https://karpenter.sh/v0.6.1/getting-started/cloudformation.yaml\n+# https://github.com/aws/karpenter/blob/502d275cc330fb0f2435b124935c49632146d945/website/content/en/v0.19.0/getting-started/getting-started-with-eksctl/cloudformation.yaml#L34\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n statement {\n actions = [\n- \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateFleet\",\n+ \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateTags\",\n- \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n- \"ec2:DescribeSecurityGroups\",\n- \"ec2:DescribeSubnets\",\n- \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n- \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:DescribeSubnets\",\n \"pricing:GetProducts\",\n ]\n \n@@ -583,6 +584,20 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"iam:PassRole\"]\n }\n resources = var.karpenter_controller_node_iam_role_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"sqs:DeleteMessage\",\n+ \"sqs:GetQueueAttributes\",\n+ \"sqs:GetQueueUrl\",\n+ \"sqs:ReceiveMessage\",\n+ ]\n+ resources = [var.karpenter_sqs_queue_arn]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"karpenter_controller\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -215,6 +215,12 @@ variable \"karpenter_subnet_account_id\" {\n default = \"\"\n }\n \n+variable \"karpenter_sqs_queue_arn\" {\n+ description = \"(Optional) ARN of SQS used by Karpenter when native node termination handling is enabled\"\n+ type = string\n+ default = null\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -206,6 +206,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -509,24 +509,25 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n # Karpenter Controller Policy\n ################################################################################\n \n-# curl -fsSL https://karpenter.sh/v0.6.1/getting-started/cloudformation.yaml\n+# https://github.com/aws/karpenter/blob/502d275cc330fb0f2435b124935c49632146d945/website/content/en/v0.19.0/getting-started/getting-started-with-eksctl/cloudformation.yaml#L34\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n statement {\n actions = [\n- \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateFleet\",\n+ \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateTags\",\n- \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n- \"ec2:DescribeSecurityGroups\",\n- \"ec2:DescribeSubnets\",\n- \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n- \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:DescribeSubnets\",\n \"pricing:GetProducts\",\n ]\n \n@@ -583,6 +584,20 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"iam:PassRole\"]\n resources = var.karpenter_controller_node_iam_role_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"sqs:DeleteMessage\",\n+ \"sqs:GetQueueAttributes\",\n+ \"sqs:GetQueueUrl\",\n+ \"sqs:ReceiveMessage\",\n+ ]\n+ resources = [var.karpenter_sqs_queue_arn]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"karpenter_controller\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -215,6 +215,12 @@ variable \"karpenter_subnet_account_id\" {\n default = \"\"\n }\n \n+variable \"karpenter_sqs_queue_arn\" {\n+ description = \"(Optional) ARN of SQS used by Karpenter when native node termination handling is enabled\"\n+ type = string\n+ default = null\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -206,6 +206,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_sqs_queue_arn\"></a> [karpenter\\_sqs\\_queue\\_arn](#input\\_karpenter\\_sqs\\_queue\\_arn) | (Optional) ARN of SQS used by Karpenter when native node termination handling is enabled | `string` | `null` | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no no | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -509,24 +509,25 @@ resource \"aws_iam_role_policy_attachment\" \"fsx_lustre_csi\" {\n # Karpenter Controller Policy\n ################################################################################\n \n-# curl -fsSL https://karpenter.sh/v0.6.1/getting-started/cloudformation.yaml\n+# https://github.com/aws/karpenter/blob/502d275cc330fb0f2435b124935c49632146d945/website/content/en/v0.19.0/getting-started/getting-started-with-eksctl/cloudformation.yaml#L34\n data \"aws_iam_policy_document\" \"karpenter_controller\" {\n count = var.create_role && var.attach_karpenter_controller_policy ? 1 : 0\n \n statement {\n actions = [\n- \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateFleet\",\n+ \"ec2:CreateLaunchTemplate\",\n \"ec2:CreateTags\",\n- \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n- \"ec2:DescribeSecurityGroups\",\n- \"ec2:DescribeSubnets\",\n- \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n- \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeInstanceTypes\",\n+ \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:DescribeSubnets\",\n \"pricing:GetProducts\",\n ]\n \n@@ -583,6 +584,20 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"iam:PassRole\"]\n resources = var.karpenter_controller_node_iam_role_arns\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.karpenter_sqs_queue_arn != null ? [1] : []\n+\n+ content {\n+ actions = [\n+ \"sqs:DeleteMessage\",\n+ \"sqs:GetQueueAttributes\",\n+ \"sqs:GetQueueUrl\",\n+ \"sqs:ReceiveMessage\",\n+ ]\n+ resources = [var.karpenter_sqs_queue_arn]\n+ }\n+ }\n }\n \n resource \"aws_iam_policy\" \"karpenter_controller\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -215,6 +215,12 @@ variable \"karpenter_subnet_account_id\" {\n default = \"\"\n }\n \n+variable \"karpenter_sqs_queue_arn\" {\n+ description = \"(Optional) ARN of SQS used by Karpenter when native node termination handling is enabled\"\n+ type = string\n+ default = null\n+}\n+\n # AWS Load Balancer Controller\n variable \"attach_load_balancer_controller_policy\" {\n description = \"Determines whether to attach the Load Balancer Controller policy to the role\"\n---\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\n- Update GitHub action versions to use latest. This remove warnings related to https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/\r\n- Ensure pre-commit config is aligned with latest\r\n- Add `lock.yml` workflow to automatically lock issues and PRs after 30 days. Theres a lot \"Me too\" or \"I have this issue, when will this get fixed\" on really old/stale issues and in order to properly triage, users need to supply their configurations. This workflow is pulled from the AWS provider's repo to force users to fill out a proper issue ticket and keep chatter out of merged PRs or old issues\r\n\r\n## Motivation and Context\r\n\r\n- Patch warnings on CI checks to keep output clean\r\n- Focus on new issues and PRs\r\n\r\n## Breaking Changes\r\n\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.github/workflows/lock.yml\n@@ -0,0 +1,21 @@\n+name: 'Lock Threads'\n+\n+on:\n+ schedule:\n+ - cron: '50 1 * * *'\n+\n+jobs:\n+ lock:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: dessant/lock-threads@v3\n+ with:\n+ github-token: ${{ secrets.GITHUB_TOKEN }}\n+ issue-comment: >\n+ I'm going to lock this issue because it has been closed for _30 days_ ⏳. This dirs\n- our maintainers find and focus on the active issues.\n+ If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ issue-inactive-days: '30'\n+ pr-comment: >\n+ I'm going to lock this pull request because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ pr-inactive-days: '30'\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -17,11 +17,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,26 +32,26 @@ jobs:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n@@ -62,17 +62,17 @@ jobs:\n needs: collectInputs\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,7 +20,7 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n persist-credentials: false\n fetch-depth: 0\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v4\n+ - uses: actions/stale@v6\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n\n\n---\n\nChoice B:\n.github/workflows/lock.yml\n@@ -0,0 +1,21 @@\n+name: 'Lock Threads'\n+\n+on:\n+ schedule:\n+ - cron: '50 1 * * *'\n+\n+jobs:\n+ lock:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: dessant/lock-threads@v3\n+ with:\n+ github-token: ${{ secrets.GITHUB_TOKEN }}\n+ issue-comment: >\n+ I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ issue-inactive-days: '30'\n+ pr-comment: >\n+ I'm going to lock this pull request because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ pr-inactive-days: '30'\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -17,11 +17,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,26 +32,26 @@ jobs:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n@@ -62,17 +62,17 @@ jobs:\n needs: collectInputs\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,7 +20,7 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n persist-credentials: false\n fetch-depth: 0\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v4\n+ - uses: actions/stale@v6\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n\n\n---\n\nChoice C:\n.github/workflows/lock.yml\n@@ -0,0 +1,21 @@\n+name: 'Lock Threads'\n+\n+on:\n+ schedule:\n+ - cron: '50 1 * * *'\n+\n+jobs:\n+ lock:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: dessant/lock-threads@v3\n+ with:\n+ github-token: ${{ secrets.GITHUB_TOKEN }}\n+ issue-comment: >\n+ I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ issue-inactive-days: '30'\n+ pr-comment: >\n+ I'm going to lock this pull request because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ pr-inactive-days: '30'\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -17,11 +17,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,26 +32,26 @@ jobs:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n@@ -62,17 +62,17 @@ jobs:\n needs: collectInputs\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,7 +20,7 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n persist-credentials: false\n fetch-depth: 0\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v4\n+ - uses: actions/stale@v6\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n\n\n---\n\nChoice D:\n.github/workflows/lock.yml\n@@ -0,0 +1,21 @@\n+name: 'Lock Threads'\n+\n+on:\n+ schedule:\n+ - cron: '50 1 * * *'\n+\n+jobs:\n+ lock:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: dessant/lock-threads@v3\n+ with:\n+ github-token: ${{ secrets.GITHUB_TOKEN }}\n+ issue-comment: >\n+ I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ issue-inactive-days: '30'\n+ pr-comment: >\n+ I'm going to lock this pull request because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.\n+ If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.\n+ pr-inactive-days: '30'\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -17,11 +17,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,26 +32,26 @@ jobs:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n@@ -62,17 +62,17 @@ jobs:\n needs: collectInputs\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,7 +20,7 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v2\n+ uses: actions/checkout@v3\n with:\n persist-credentials: false\n fetch-depth: 0\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v4\n+ - uses: actions/stale@v6\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\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: fully qualified audiences should generate StringEquals but is generating StringLike\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nThere is a bug that causes oidc_fully_qualified_audiences to create StringLike condition instead of StringEquals condition. This is simply because the content is created with StringLike instead of StringEquals\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nSolves bug\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\nI don't know\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_oidc\"></a> [iam\\_assumable\\_role\\_with\\_oidc](#module\\_iam\\_assumable\\_role\\_with\\_oidc) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,23 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_assumable_role_with_oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ assume_role_condition_test = \"StringEquals\"\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringLike\"` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ account test = var.assume_role_condition_test\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringLike\"\n+}\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_oidc\"></a> [iam\\_assumable\\_role\\_with\\_oidc](#module\\_iam\\_assumable\\_role\\_with\\_oidc) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,23 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_assumable_role_with_oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ whether assume_role_condition_test = \"StringEquals\"\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringLike\"` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = var.assume_role_condition_test\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringLike\"\n+}\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_oidc\"></a> [iam\\_assumable\\_role\\_with\\_oidc](#module\\_iam\\_assumable\\_role\\_with\\_oidc) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,23 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_assumable_role_with_oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ assume_role_condition_test = \"StringEquals\"\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringLike\"` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = var.assume_role_condition_test\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringLike\"\n+}\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,7 @@ No providers.\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role-with-oidc | n/a |\n | <a name=\"module_iam_assumable_role_self_assume\"></a> [iam\\_assumable\\_role\\_self\\_assume](#module\\_iam\\_assumable\\_role\\_self\\_assume) | ../../modules/iam-assumable-role-with-oidc | n/a |\n+| <a name=\"module_iam_assumable_role_with_oidc\"></a> [iam\\_assumable\\_role\\_with\\_oidc](#module\\_iam\\_assumable\\_role\\_with\\_oidc) | ../../modules/iam-assumable-role-with-oidc | n/a |\n \n ## Resources\n \n---\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,23 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_assumable_role_with_oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ assume_role_condition_test = \"StringEquals\"\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -39,6 +39,7 @@ No modules.\n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringLike\"` | no |\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = var.assume_role_condition_test\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -105,3 +105,9 @@ variable \"allow_self_assume_role\" {\n type = bool\n default = false\n }\n+\n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type [IAM = string\n+ default = \"StringLike\"\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:\nFix: fully qualified audiences should generate StringEquals but is generating StringLike\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nThere is a bug that causes oidc_fully_qualified_audiences to create StringLike condition instead of StringEquals condition. This is simply because the content is created with StringLike instead of StringEquals\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nSolves bug\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\nI don't know\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,22 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_iam-assumable-role-with-oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,22 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_iam-assumable-role-with-oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,22 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_iam-assumable-role-with-oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role-with-oidc/main.tf\n@@ -50,3 +50,22 @@ module \"iam_assumable_role_self_assume\" {\n \n oidc_fully_qualified_subjects = [\"system:serviceaccount:default:sa1\", \"system:serviceaccount:default:sa2\"]\n }\n+\n+#####################################\n+# IAM assumable role with audience\n+#####################################\n+module \"iam_iam-assumable-role-with-oidc\" {\n+ source = \"../../modules/iam-assumable-role-with-oidc\"\n+\n+ create_role = true\n+\n+ role_name = \"role-with-oidc-github-actions\"\n+\n+ provider_url = \"token.actions.githubusercontent.com\"\n+\n+ role_policy_arns = [\n+ \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\",\n+ ]\n+\n+ oidc_fully_qualified_audiences = [\"sts.amazonaws.com\"]\n+}\n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -75,7 +75,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n for_each = length(var.oidc_fully_qualified_audiences) > 0 ? local.urls : []\n \n content {\n- test = \"StringLike\"\n+ test = \"StringEquals\"\n variable = \"${statement.value}:aud\"\n values = var.oidc_fully_qualified_audiences\n }\n---\n\n\n---\n" } ]
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\nImprove docs for iam-eks-role - inform user that this sub module will not work for multiple regions\r\n\r\n## Motivation and Context\r\nWill help save time if the end user has a multi region setup. This module doesn't support creating a role for multiple EKS clusters in more than 1 region.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\nDocs change for clarity\r\n\r\nprojects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-eks-role/README.md\n@@ -7,6 +7,7 @@ Creates an role role that can be assumed by one or more EKS `ServiceAccount` in o\n - Support multiple `ServiceAccount` in the same cluster, for example when a workload runs in multiple namespaces\n - More suitable for non-cluster admins as implementation is simpler\n - More suitable for when the IAM role and cluster resources are in separate Terraform configurations\n+- Does not support multiple regions, consider using [iam-role-for-service-accounts-eks](https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/modules/iam-role-for-service-accounts-eks/) if role needs to support clusters in multiple regions\n \n This module is for use with AWS EKS. For details of how a `ServiceAccount` in EKS can assume an IAM role, see the [EKS documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/README.md\n@@ -7,6 +7,7 @@ Creates an IAM role a can be assumed by one or more EKS `ServiceAccount` in o\n - Support multiple `ServiceAccount` in the same cluster, for example when a workload runs in multiple namespaces\n - More suitable for non-cluster admins as implementation is simpler\n - More suitable for when the IAM role and cluster resources are in separate Terraform configurations\n+- Does not support multiple regions, consider using [iam-role-for-service-accounts-eks](https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/modules/iam-role-for-service-accounts-eks/) if role needs to support clusters in multiple regions\n \n This module is for use with AWS EKS. For details of how a `ServiceAccount` in EKS can assume an IAM role, see the [EKS documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/README.md\n@@ -7,6 +7,7 @@ Creates an IAM role that can be assumed by one or more EKS `ServiceAccount` in o\n - Support multiple `ServiceAccount` in the same cluster, for example when a workload runs in multiple namespaces\n - More suitable for non-cluster admins as implementation is simpler\n - More suitable for when the IAM role and cluster resources are documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).\n separate Terraform configurations\n+- Does not support multiple regions, consider using [iam-role-for-service-accounts-eks](https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/modules/iam-role-for-service-accounts-eks/) if role needs to support clusters in multiple regions\n \n This module is for use with AWS EKS. For details of how a `ServiceAccount` in EKS can assume an IAM role, see the [EKS documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/README.md\n@@ -7,6 +7,7 @@ Creates an IAM role that can be assumed by one or more EKS `ServiceAccount` in o\n - Support multiple `ServiceAccount` in the same cluster, for example when a workload runs in multiple namespaces\n - More suitable for non-cluster admins as implementation is simpler\n - More suitable for when the IAM role and cluster resources are in separate Terraform configurations\n+- Does not support multiple regions, consider using [iam-role-for-service-accounts-eks](https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/modules/iam-role-for-service-accounts-eks/) if role needs to support clusters in multiple regions\n \n This module is for use with AWS EKS. For details of how a `ServiceAccount` in EKS can assume an IAM role, see the [EKS documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).\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:\nThis change allows creating and adding existing IAM policies to the created user.\r\n\r\n## Description\r\nCreating the user with the corresponding policies on this module makes sense for static policies.\r\n\r\n## Motivation and Context\r\nAvoid creating simple policies and attachments outside of this module.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\nI have tested this with the following code:\r\n\r\n```\r\nmodule \"iam-user\" {\r\n source = \"git::https://github.com/pjrm/terraform-aws-iam.git//modules/iam-user?ref=ft-add-iam-policy-creation-on-iam-user\"\r\n name = \"test-user\"\r\n\r\n create_iam_policies = true\r\n attach_iam_arn_policies = [\"arn:aws:iam::aws:policy/AWSDirectConnectReadOnlyAccess\"]\r\n iam_policies = {\r\n \"example-policy\" = {\r\n policy = jsonencode({\r\n \"Version\" : \"2012-10-17\",\r\n \"Statement\" : [\r\n {\r\n \"Effect\" : \"Allow\",\r\n \"Action\" : \"ec2:*\",\r\n \"Resource\" : \"*\"\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n```\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -44,18 +44,24 @@ No modules.\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n+| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.created_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n+| [aws_iam_user_policy_attachment.existing_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_attach_iam_arn_policies\"></a> [attach\\_iam\\_arn\\_policies](#input\\_attach\\_iam\\_arn\\_policies) | List of existing IAM ARN policies to be attached. | `list(any)` | `[]` | no |\n | <a name=\"input_create_iam_access_key\"></a> [create\\_iam\\_access\\_key](#input\\_create\\_iam\\_access\\_key) | Whether to create IAM access key | `bool` | `true` | no |\n+| <a name=\"input_create_iam_policies\"></a> [create\\_iam\\_policies](#input\\_create\\_iam\\_policies) | Whether to create IAM policies | `bool` | `false` | no |\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_policies\"></a> [iam\\_policies](#input\\_iam\\_policies) | Maps of IAM policies to be created. The Values are passed through to the aws\\_iam\\_policy | `map(any)` | `{}` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -43,3 +43,33 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_policy\" \"this\" {\n+ for_each = {\n+ for key, values in var.iam_policies : key => values\n+ if var.create_iam_policies && length(var.iam_policies) > 0\n+ }\n+\n+ name = each.key\n+ name_prefix = lookup(each.value, \"name_prefix\", null)\n+ path = lookup(each.value, \"path\", null)\n+ description = lookup(each.value, \"description\", null)\n+\n+ policy = each.value.policy\n+\n+ tags = lookup(each.value, \"tags\", null)\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"created_iam_policies\" {\n+ for_each = aws_iam_policy.this\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value.arn\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"existing_iam_policies\" {\n+ for_each = toset(var.attach_iam_arn_policies)\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/variables.tf\n@@ -16,6 +16,24 @@ variable \"create_iam_access_key\" {\n default = true\n be \n+variable \"create_iam_policies\" {\n+ description = \"Whether to create IAM policies\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"iam_policies\" {\n+ description = \"Maps of IAM policies to be created. The Values are passed through to the aws_iam_policy\"\n+ type = map(any)\n+ default = {}\n+}\n+\n+variable \"attach_iam_arn_policies\" {\n+ description = \"List of existing IAM ARN policies to be attached.\"\n+ type = list(any)\n+ default = []\n+}\n+\n variable \"name\" {\n description = \"Desired name for the IAM user\"\n type = string\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -44,18 +44,24 @@ No modules.\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n+| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.created_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n+| [aws_iam_user_policy_attachment.existing_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_attach_iam_arn_policies\"></a> [attach\\_iam\\_arn\\_policies](#input\\_attach\\_iam\\_arn\\_policies) | List of existing IAM ARN policies to be attached. | `list(any)` | `[]` | no |\n | <a name=\"input_create_iam_access_key\"></a> [create\\_iam\\_access\\_key](#input\\_create\\_iam\\_access\\_key) | Whether to create IAM access key | `bool` | `true` | no |\n+| <a name=\"input_create_iam_policies\"></a> [create\\_iam\\_policies](#input\\_create\\_iam\\_policies) | Whether to create IAM policies | `bool` | `false` | no |\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_policies\"></a> [iam\\_policies](#input\\_iam\\_policies) | Maps of IAM policies to be created. The Values are passed through to the aws\\_iam\\_policy | `map(any)` | `{}` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -43,3 +43,33 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_policy\" \"this\" {\n+ for_each = {\n+ for key, values in var.iam_policies : key => values\n+ if var.create_iam_policies && length(var.iam_policies) > 0\n+ }\n+\n+ name = each.key\n+ name_prefix = lookup(each.value, \"name_prefix\", null)\n+ path = lookup(each.value, \"path\", null)\n+ description = lookup(each.value, \"description\", null)\n+\n+ policy = each.value.policy\n+\n+ tags = lookup(each.value, \"tags\", null)\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"created_iam_policies\" {\n+ for_each = aws_iam_policy.this\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value.arn\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"existing_iam_policies\" {\n+ for_each = toset(var.attach_iam_arn_policies)\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/variables.tf\n@@ -16,6 +16,24 @@ variable \"create_iam_access_key\" {\n default = true\n }\n \n+variable \"create_iam_policies\" {\n+ description = \"Whether to create IAM policies\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"iam_policies\" {\n+ description = \"Maps of IAM policies to be created. The Values are passed through to the aws_iam_policy\"\n+ type = map(any)\n+ default = {}\n+}\n+\n+variable \"attach_iam_arn_policies\" {\n+ description = \"List of existing IAM ARN policies to be attached.\"\n+ type = list(any)\n+ default = []\n+}\n+\n variable \"name\" {\n description = \"Desired name for the IAM user\"\n type = string\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -44,18 +44,24 @@ No modules.\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n+| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.created_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n+| [aws_iam_user_policy_attachment.existing_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_attach_iam_arn_policies\"></a> [attach\\_iam\\_arn\\_policies](#input\\_attach\\_iam\\_arn\\_policies) | List of existing IAM ARN policies to be attached. | `list(any)` | `[]` | no |\n | <a name=\"input_create_iam_access_key\"></a> [create\\_iam\\_access\\_key](#input\\_create\\_iam\\_access\\_key) | Whether to create IAM access key | `bool` | `true` | no |\n+| <a name=\"input_create_iam_policies\"></a> [create\\_iam\\_policies](#input\\_create\\_iam\\_policies) | Whether to create IAM policies | `bool` | `false` | no |\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_policies\"></a> [iam\\_policies](#input\\_iam\\_policies) | Maps of IAM policies to be created. The Values are passed through to the aws\\_iam\\_policy | `map(any)` | `{}` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -43,3 +43,33 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_policy\" \"this\" {\n+ for_each = {\n+ for key, values in var.iam_policies : key => values\n+ if var.create_iam_policies && length(var.iam_policies) > 0\n+ }\n+\n+ name = each.key\n+ name_prefix = lookup(each.value, \"name_prefix\", null)\n+ path = lookup(each.value, \"path\", null)\n+ description = lookup(each.value, \"description\", null)\n+\n+ policy = each.value.policy\n+\n+ tags = lookup(each.value, \"tags\", null)\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"created_iam_policies\" {\n+ for_each = aws_iam_policy.this\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value.arn\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"existing_iam_policies\" {\n+ for_each = toset(var.attach_iam_arn_policies)\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/variables.tf\n@@ -16,6 +16,24 @@ variable \"create_iam_access_key\" {\n default = true\n }\n \n+variable \"create_iam_policies\" {\n+ description = \"Whether to create IAM policies\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"iam_policies\" {\n+ description = \"Maps of IAM policies to be created. The Values are passed through to the aws_iam_policy\"\n+ type = map(any)\n+ default = {}\n+}\n+\n+variable \"attach_iam_arn_policies\" {\n+ description = \"List of existing IAM ARN policies to be attached.\"\n+ type = list(any)\n+ default = = []\n+}\n+\n variable \"name\" {\n description = \"Desired name for the IAM user\"\n type = string\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -44,18 +44,24 @@ No modules.\n |------|------|\n | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n | [aws_iam_access_key.this_no_pgp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |\n+| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |\n | [aws_iam_user_login_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |\n+| [aws_iam_user_policy_attachment.created_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n+| [aws_iam_user_policy_attachment.existing_iam_policies](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |\n | [aws_iam_user_ssh_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_ssh_key) | resource |\n \n ## Inputs\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_attach_iam_arn_policies\"></a> [attach\\_iam\\_arn\\_policies](#input\\_attach\\_iam\\_arn\\_policies) | List of existing IAM ARN policies to be attached. | `list(any)` | `[]` | no |\n | <a name=\"input_create_iam_access_key\"></a> [create\\_iam\\_access\\_key](#input\\_create\\_iam\\_access\\_key) | Whether to create IAM access key | `bool` | `true` | no |\n+| <a name=\"input_create_iam_policies\"></a> [create\\_iam\\_policies](#input\\_create\\_iam\\_policies) | Whether to create IAM policies | `bool` | `false` | Values |\n | <a name=\"input_create_iam_user_login_profile\"></a> [create\\_iam\\_user\\_login\\_profile](#input\\_create\\_iam\\_user\\_login\\_profile) | Whether to create IAM user login profile | `bool` | `true` | no |\n | <a name=\"input_create_user\"></a> [create\\_user](#input\\_create\\_user) | Whether to create the IAM user | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | When destroying this user, destroy even if it has non-Terraform-managed IAM access keys, login profile or MFA devices. Without force\\_destroy a user with non-Terraform-managed access keys and login profile will fail to be destroyed. | `bool` | `false` | no |\n+| <a name=\"input_iam_policies\"></a> [iam\\_policies](#input\\_iam\\_policies) | Maps of IAM policies to be created. The Values are passed through to the aws\\_iam\\_policy | `map(any)` | `{}` | no |\n | <a name=\"input_name\"></a> [name](#input\\_name) | Desired name for the IAM user | `string` | n/a | yes |\n | <a name=\"input_password_length\"></a> [password\\_length](#input\\_password\\_length) | The length of the generated password | `number` | `20` | no |\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n---\nmodules/iam-user/main.tf\n@@ -43,3 +43,33 @@ resource \"aws_iam_user_ssh_key\" \"this\" {\n encoding = var.ssh_key_encoding\n public_key = var.ssh_public_key\n }\n+\n+resource \"aws_iam_policy\" \"this\" {\n+ for_each = {\n+ for key, values in var.iam_policies : key => values\n+ if var.create_iam_policies && length(var.iam_policies) > 0\n+ }\n+\n+ name = each.key\n+ name_prefix = lookup(each.value, \"name_prefix\", null)\n+ path = lookup(each.value, \"path\", null)\n+ description = lookup(each.value, \"description\", null)\n+\n+ policy = each.value.policy\n+\n+ tags = lookup(each.value, \"tags\", null)\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"created_iam_policies\" {\n+ for_each = aws_iam_policy.this\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value.arn\n+}\n+\n+resource \"aws_iam_user_policy_attachment\" \"existing_iam_policies\" {\n+ for_each = toset(var.attach_iam_arn_policies)\n+\n+ user = aws_iam_user.this[0].name\n+ policy_arn = each.value\n+}\n---\nmodules/iam-user/variables.tf\n@@ -16,6 +16,24 @@ variable \"create_iam_access_key\" {\n default = true\n }\n \n+variable \"create_iam_policies\" {\n+ description = \"Whether to create IAM policies\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"iam_policies\" {\n+ description = \"Maps of IAM policies to be created. The Values are passed through to the aws_iam_policy\"\n+ type = map(any)\n+ default = {}\n+}\n+\n+variable \"attach_iam_arn_policies\" {\n+ description = \"List of existing IAM ARN policies to be attached.\"\n+ type = list(any)\n+ default = []\n+}\n+\n variable \"name\" {\n description = \"Desired name for the IAM user\"\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:\nBug fix: Self assume role condition\r\n\r\n## Description\r\nAdd missing locals in [iam-assumable-role-with-oidc](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-role-with-oidc). \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -7,6 +7,7 @@ locals {\n ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ partition = data.aws_partition.current\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -32,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = [\"arn:${local.partition}:iam::${local.aws_account_id}:role${var.role_path}${local.role_name_condition}\"]\n }\n }\n }\n@@ -47,7 +48,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ identifiers = [\"arn:${local.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n }\n \n dynamic \"condition\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -7,6 +7,7 @@ locals {\n ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n \n- role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ partition = data.aws_partition.current\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -32,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = [\"arn:${local.partition}:iam::${local.aws_account_id}:role${var.role_path}${local.role_name_condition}\"]\n }\n }\n }\n@@ -47,7 +48,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ identifiers = [\"arn:${local.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n }\n \n dynamic \"condition\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -7,6 +7,7 @@ locals {\n ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+ partition = data.aws_partition.current\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -32,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = [\"arn:${local.partition}:iam::${local.aws_account_id}:role${var.role_path}${local.role_name_condition}\"]\n }\n }\n }\n@@ -47,7 +48,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ identifiers = [\"arn:${local.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n }\n \n dynamic \"condition\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -7,6 +7,7 @@ locals {\n ]\n number_of_role_policy_arns = coalesce(var.number_of_role_policy_arns, length(var.role_policy_arns))\n role_name_condition = var.role_name != ? var.role_name : \"${var.role_name_prefix}*\"\n+ partition = data.aws_partition.current\n }\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -32,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n condition {\n test = \"ArnLike\"\n variable = \"aws:PrincipalArn\"\n- values = [\"arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}\"]\n+ values = [\"arn:${local.partition}:iam::${local.aws_account_id}:role${var.role_path}${local.role_name_condition}\"]\n }\n }\n }\n@@ -47,7 +48,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n principals {\n type = \"Federated\"\n \n- identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n+ identifiers = [\"arn:${local.partition}:iam::${local.aws_account_id}:oidc-provider/${statement.value}\"]\n }\n \n dynamic \"condition\" {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- Correct tflint errors for latest version of tflint\r\n\r\n## Motivation and Context\r\n- Resolves tflint `Warning: List items should be accessed using square brackets (terraform_deprecated_index)`\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -95,14 +95,14 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.assume_role_with_oidc[0].json\n \n tags = var.tags\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -65,6 +65,6 @@ resource \"aws_iam_role\" \"this\" {\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-group-with-policies/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- group_name = element(concat(aws_iam_group.this.*.id, [var.name]), 0)\n+ group_name = var.create_group ? aws_iam_group.this[0].id : var.name\n }\n \n resource \"aws_iam_group\" \"this\" {\n@@ -37,7 +37,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\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+ policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n }\n \n ###############\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -5,13 +5,7 @@ data \"aws_caller_identity\" \"current\" {\n data \"aws_partition\" \"current\" {}\n \n locals {\n- aws_account_id = element(\n- concat(\n- data.aws_caller_identity.current.*.account_id,\n- [var.aws_account_id],\n- ),\n- 0,\n- )\n+ aws_account_id = try(data.aws_caller_identity.current[0].account_id, var.aws_account_id)\n }\n \n data \"aws_iam_policy_document\" \"iam_self_management\" {\n---\nmodules/iam-read-only-policy/main.tf\n@@ -82,9 +82,9 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n- data.aws_iam_policy_document.console_services.*.json,\n- data.aws_iam_policy_document.sts.*.json,\n- data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.console_services[*].json,\n+ data.aws_iam_policy_document.sts[*].json,\n+ data.aws_iam_policy_document.logs_query[*].json,\n [var.additional_policy_json]\n )\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -95,14 +95,14 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.assume_role_with_oidc[0].json\n \n tags = var.tags\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -65,6 +65,6 @@ resource \"aws_iam_role\" \"this\" {\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-group-with-policies/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- group_name = element(concat(aws_iam_group.this.*.id, [var.name]), 0)\n+ group_name = var.create_group ? aws_iam_group.this[0].id : var.name\n }\n \n resource \"aws_iam_group\" \"this\" {\n@@ -37,7 +37,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\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+ policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n }\n \n ###############\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -5,13 +5,7 @@ data \"aws_caller_identity\" \"current\" {\n data \"aws_partition\" \"current\" {}\n \n locals {\n- aws_account_id = element(\n- concat(\n- data.aws_caller_identity.current.*.account_id,\n- [var.aws_account_id],\n- ),\n- 0,\n- )\n+ aws_account_id = try(data.aws_caller_identity.current[0].account_id, var.aws_account_id)\n }\n \n data \"aws_iam_policy_document\" \"iam_self_management\" {\n---\nmodules/iam-read-only-policy/main.tf\n@@ -82,9 +82,9 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n- data.aws_iam_policy_document.console_services.*.json,\n- data.aws_iam_policy_document.sts.*.json,\n- data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.console_services[*].json,\n+ data.aws_iam_policy_document.sts[*].json,\n+ data.aws_iam_policy_document.logs_query[*].json,\n [var.additional_policy_json]\n )\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -95,14 +95,14 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.assume_role_with_oidc[0].json\n \n tags = var.tags\n }\n \n resource \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -65,6 +65,6 @@ resource \"aws_iam_role\" \"this\" {\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-group-with-policies/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- group_name = element(concat(aws_iam_group.this.*.id, [var.name]), 0)\n+ group_name = var.create_group ? aws_iam_group.this[0].id : var.name\n }\n \n resource \"aws_iam_group\" \"this\" {\n@@ -37,7 +37,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\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+ policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n }\n \n ###############\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -5,13 +5,7 @@ data \"aws_caller_identity\" \"current\" {\n data \"aws_partition\" \"current\" {}\n \n locals {\n- aws_account_id = element(\n- concat(\n- data.aws_caller_identity.current.*.account_id,\n- [var.aws_account_id],\n- ),\n- 0,\n- )\n+ aws_account_id = try(data.aws_caller_identity.current[0].account_id, var.aws_account_id)\n }\n \n data \"aws_iam_policy_document\" \"iam_self_management\" {\n---\nmodules/iam-read-only-policy/main.tf\n@@ -82,9 +82,9 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n- data.aws_iam_policy_document.console_services.*.json,\n- data.aws_iam_policy_document.sts.*.json,\n- data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.console_services[*].json,\n+ data.aws_iam_policy_document.sts[*].json,\n+ data.aws_iam_policy_document.logs_query[*].json,\n [var.additional_policy_json]\n )\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -95,14 +95,14 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.assume_role_with_oidc[0].json\n \n tags = var.tags\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-assumable-role-with-saml/main.tf\n@@ -65,6 +65,6 @@ resource \"aws_iam_role\" \"this\" {\n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n count = var.create_role ? local.number_of_role_policy_arns : 0\n \n- role = join(\"\", aws_iam_role.this.*.name)\n+ role = aws_iam_role.this[0].name\n policy_arn = var.role_policy_arns[count.index]\n }\n---\nmodules/iam-group-with-policies/main.tf\n@@ -1,5 +1,5 @@\n locals {\n- group_name = element(concat(aws_iam_group.this.*.id, [var.name]), 0)\n+ group_name = var.create_group ? aws_iam_group.this[0].id : var.name\n }\n \n resource \"aws_iam_group\" \"this\" {\n@@ -37,7 +37,7 @@ resource \"aws_iam_group_policy_attachment\" \"custom\" {\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+ policy_arn = element(aws_iam_policy.custom[*].arn, count.index)\n }\n \n ###############\n---\nmodules/iam-group-with-policies/policies.tf\n@@ -5,13 +5,7 @@ data \"aws_caller_identity\" \"current\" {\n data \"aws_partition\" \"current\" {}\n \n locals {\n- aws_account_id = element(\n- concat(\n- data.aws_caller_identity.current.*.account_id,\n- [var.aws_account_id],\n- ),\n- 0,\n- )\n+ aws_account_id = try(data.aws_caller_identity.current[0].account_id, var.aws_account_id)\n }\n \n data \"aws_iam_policy_document\" \"iam_self_management\" {\n---\nmodules/iam-read-only-policy/main.tf\n@@ -82,9 +82,9 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n data \"aws_iam_policy_document\" +5,7 {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n- data.aws_iam_policy_document.console_services.*.json,\n- data.aws_iam_policy_document.sts.*.json,\n- data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.console_services[*].json,\n+ data.aws_iam_policy_document.sts[*].json,\n+ data.aws_iam_policy_document.logs_query[*].json,\n [var.additional_policy_json]\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:\nFixes an issue where the policy was not sufficient if you use security group ids in the Karpenter `AWSNodeTemplate` instead of relying on discovery tags. Then the security groups weren't tagged, which led to insufficient permissions for Karpenter to launch the node.\r\n\r\n## Description\r\nRemoves the need for the security group to be tagged with the Karpenter discovery tag\r\nfor Karpenter to be able to use it when launching an instance.\r\n\r\n## Motivation and Context\r\n\r\n- Resolves #295 \r\n\r\nIf we create an AWSNodeTemplate like this:\r\n```yaml\r\napiVersion: karpenter.k8s.aws/v1alpha1\r\nkind: AWSNodeTemplate\r\nmetadata:\r\n name: default\r\nspec:\r\n subnetSelector:\r\n aws-ids: subnet-abc,subnet-xyz\r\n securityGroupSelector:\r\n aws-ids: sg-abc,sg-xyz\r\n tags:\r\n karpenter.sh/discovery/foo-cluster: foo-cluster\r\n```\r\nwhich is perfectly valid according to Karpenter docs, we will not\r\nbe able to use the module policy as is, since the security group we are referring to doesn't have the correct discovery tag (since we don't want to use discovery tags).\r\n\r\nThe change here changes the policy such that this constraint is relaxed. This makes the security group part of the policy behave like the subnet part, which wasn't dependent on the tag being present.\r\n\r\n## Breaking Changes\r\nNo breaking changes, just a little bit more permissive policy.\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- [x] I have executed `pre-commit run -a` on my pull request\r\n- [x] I have updated the policy manually and verified in karpenter \r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -547,7 +547,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"ec2:RunInstances\"]\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n ]\n \n condition {\n@@ -563,6 +562,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -547,7 +547,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"ec2:RunInstances\"]\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n ]\n \n condition {\n@@ -563,6 +562,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -547,7 +547,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"ec2:RunInstances\"]\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n ]\n \n condition {\n@@ -563,6 +562,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -547,7 +547,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n actions = [\"ec2:RunInstances\"]\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n ]\n \n condition {\n@@ -563,6 +562,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\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:\nAdded additional policies required for targetgroup binding only to work with AWS LBC\r\n\r\n## Description\r\nAdds two additional policies to the subset of policies that are in effect when only using TargetGroupBinding policies with the AWS Load Balancer Controller.\r\n\r\n## Motivation and Context\r\nThe policies applied when using only `var.attach_load_balancer_controller_targetgroup_binding_only_policy = true`\r\nis not sufficient for target group binding to work in latest version of AWS LBC. Not sure when the issue arose, and it may be related to how I define inline ingresses. Nonetheless I am only using TargetGroupBinding resources and the policy fails for that use case. More details described here: [issue](https://github.com/terraform-aws-modules/terraform-aws-iam/issues/291)\r\n\r\n## Breaking Changes\r\nThis doesn't break backwards compatibility\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- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -863,12 +863,14 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeVpcs\",\n+ \"ec2:AuthorizeSecurityGroupIngress\",\n+ \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n- \"elasticloadbalancing:DeregisterTargets\"\n+ \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -863,12 +863,14 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeVpcs\",\n+ \"ec2:DescribeInstances\",\n \"ec2:DescribeVpcs\",\n+ \"ec2:AuthorizeSecurityGroupIngress\",\n+ \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n- \"elasticloadbalancing:DeregisterTargets\"\n+ \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -863,12 +863,14 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeVpcs\",\n+ \"ec2:AuthorizeSecurityGroupIngress\",\n+ \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n- \"elasticloadbalancing:DeregisterTargets\"\n+ \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -863,12 +863,14 @@ data \"aws_iam_policy_document\" \"load_balancer_controller_targetgroup_only\" {\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeVpcs\",\n+ \"ec2:AuthorizeSecurityGroupIngress\",\n+ \"ec2:RevokeSecurityGroupIngress\",\n \"elasticloadbalancing:DescribeTargetGroups\",\n \"elasticloadbalancing:DescribeTargetHealth\",\n \"elasticloadbalancing:ModifyTargetGroup\",\n \"elasticloadbalancing:ModifyTargetGroupAttributes\",\n \"elasticloadbalancing:RegisterTargets\",\n- \"elasticloadbalancing:DeregisterTargets\"\n+ \"elasticloadbalancing:DeregisterTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\nAdded support for wildcards in service account conditions, to more closely align with similar support on `iam-assumable-role-with-oidc` submodule. I've also updated the documentation with `terraform-docs` as noted in the pre-commit hooks.\n\n## Motivation and Context\n<!--- Why is this change required? What problem does it solve? -->\n<!--- If it fixes an open issue, please link to the issue here. -->\nAllows people to enable many service accounts in an EKS cluster to assume this role without explicitly adding each service account name to the trust policy. This is also backwards compatible and follows a similar variable conventions which exists in another submodule in this repository.\n\n## Breaking Changes\n<!-- Does this break backwards compatibility with the current major version? -->\n<!-- If so, please provide an explanation why it is necessary. -->\nNone. Recommending a minor version bump due to an additional variable, but has an empty default.\n\n## How Has This Been Tested?\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\n<!--- Please describe how you tested your changes -->\n- [X] I have executed `pre-commit run -a` on my pull request\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\n\n\n---\n\nChoice A:\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n+| <a name=\"input_cluster_service_accounts_with_wildcards\"></a> [cluster\\_service\\_accounts\\_with\\_wildcards](#input\\_cluster\\_service\\_accounts\\_with\\_wildcards) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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` | `43200` | no |\n---\nmodules/iam-eks-role/main.tf\n@@ -3,10 +3,15 @@ data \"aws_partition\" \"current\" {}\n \n locals {\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+\n+ eks_cluster_names = toset(distinct(concat(\n+ keys(var.cluster_service_accounts),\n+ keys(var.cluster_service_accounts_with_wildcards)\n+ )))\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = local.eks_cluster_names\n \n name = each.key\n }\n@@ -56,6 +61,29 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.cluster_service_accounts_with_wildcards\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+\n+ principals {\n+ type = \"Federated\"\n+\n+ identifiers = [\n+ \"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}\"\n+ ]\n+ }\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n+ values = [for s in statement.value : \"system:serviceaccount:${s}\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -46,6 +46,12 @@ variable \"cluster_service_accounts\" {\n default = {}\n }\n \n+variable \"cluster_service_accounts_with_wildcards\" {\n+ description = \"EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details\"\n+ type = map(list(string))\n+ default = {}\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add the the IAM role\"\n type = map(any)\n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n+| <a name=\"input_cluster_service_accounts_with_wildcards\"></a> [cluster\\_service\\_accounts\\_with\\_wildcards](#input\\_cluster\\_service\\_accounts\\_with\\_wildcards) | EKS cluster and k8s ServiceAccount default Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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` | `43200` | no |\n---\nmodules/iam-eks-role/main.tf\n@@ -3,10 +3,15 @@ data \"aws_partition\" \"current\" {}\n \n locals {\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+\n+ eks_cluster_names = toset(distinct(concat(\n+ keys(var.cluster_service_accounts),\n+ keys(var.cluster_service_accounts_with_wildcards)\n+ )))\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = local.eks_cluster_names\n \n name = each.key\n }\n@@ -56,6 +61,29 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.cluster_service_accounts_with_wildcards\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+\n+ principals {\n+ type = \"Federated\"\n+\n+ identifiers = [\n+ \"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}\"\n+ ]\n+ }\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n+ values = [for s in statement.value : \"system:serviceaccount:${s}\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -46,6 +46,12 @@ variable \"cluster_service_accounts\" {\n default = {}\n }\n \n+variable \"cluster_service_accounts_with_wildcards\" {\n+ description = \"EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details\"\n+ type = map(list(string))\n+ default = {}\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add the the IAM role\"\n type = map(any)\n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n+| <a name=\"input_cluster_service_accounts_with_wildcards\"></a> [cluster\\_service\\_accounts\\_with\\_wildcards](#input\\_cluster\\_service\\_accounts\\_with\\_wildcards) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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` | `43200` | no |\n---\nmodules/iam-eks-role/main.tf\n@@ -3,10 +3,15 @@ data \"aws_partition\" \"current\" {}\n \n locals {\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+\n+ eks_cluster_names = toset(distinct(concat(\n+ keys(var.cluster_service_accounts),\n+ keys(var.cluster_service_accounts_with_wildcards)\n+ )))\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = local.eks_cluster_names\n \n name = each.key\n }\n@@ -56,6 +61,29 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.cluster_service_accounts_with_wildcards\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+\n+ principals {\n+ type = \"Federated\"\n+\n+ identifiers = [\n+ \"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}\"\n+ ]\n+ }\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n+ values = [for \"aws_iam_policy_document\" in statement.value : \"system:serviceaccount:${s}\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -46,6 +46,12 @@ variable \"cluster_service_accounts\" {\n default = {}\n }\n \n+variable \"cluster_service_accounts_with_wildcards\" {\n+ description = \"EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details\"\n+ type = map(list(string))\n+ default = {}\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add the the IAM role\"\n type = map(any)\n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/README.md\n@@ -108,6 +108,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_allow_self_assume_role\"></a> [allow\\_self\\_assume\\_role](#input\\_allow\\_self\\_assume\\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |\n | <a name=\"input_cluster_service_accounts\"></a> [cluster\\_service\\_accounts](#input\\_cluster\\_service\\_accounts) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n+| <a name=\"input_cluster_service_accounts_with_wildcards\"></a> [cluster\\_service\\_accounts\\_with\\_wildcards](#input\\_cluster\\_service\\_accounts\\_with\\_wildcards) | EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details | `map(list(string))` | `{}` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `true` | no |\n | <a name=\"input_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` | `43200` | no |\n---\nmodules/iam-eks-role/main.tf\n@@ -3,10 +3,15 @@ data \"aws_partition\" \"current\" {}\n \n locals {\n role_name_condition = var.role_name != null ? var.role_name : \"${var.role_name_prefix}*\"\n+\n+ eks_cluster_names = toset(distinct(concat(\n+ keys(var.cluster_service_accounts),\n+ keys(var.cluster_service_accounts_with_wildcards)\n+ )))\n }\n \n data \"aws_eks_cluster\" \"main\" {\n- for_each = var.cluster_service_accounts\n+ for_each = local.eks_cluster_names\n \n name = each.key\n }\n@@ -56,6 +61,29 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = var.cluster_service_accounts_with_wildcards\n+\n+ content {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRoleWithWebIdentity\"]\n+\n+ principals {\n+ type = \"Federated\"\n+\n+ identifiers = [\n+ \"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}\"\n+ ]\n+ }\n+\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"${replace(data.aws_eks_cluster.main[statement.key].identity[0].oidc[0].issuer, \"https://\", \"\")}:sub\"\n+ values `false` [for s in statement.value : \"system:serviceaccount:${s}\"]\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-eks-role/variables.tf\n@@ -46,6 +46,12 @@ variable \"cluster_service_accounts\" {\n default = {}\n }\n \n+variable \"cluster_service_accounts_with_wildcards\" {\n+ description = \"EKS cluster and k8s ServiceAccount pairs. Each EKS cluster can have multiple k8s ServiceAccount. See README for details\"\n+ type = map(list(string))\n+ default = {}\n+}\n+\n variable \"tags\" {\n description = \"A map of tags to add the the IAM role\"\n type = map(any)\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\nAdding the following permissions to IAM users created from the iam-group-with-policies module. \r\n```\r\n\"iam:ListUserTags\"\r\n\"iam:TagUser\"\r\n\"iam:UntagUser\"\r\n```\r\nFor instance, user will now be able to label their own access keys.\r\n\r\n## Motivation and Context\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/286\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-group-with-policies/policies.tf\n@@ -39,6 +39,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateUser\",\n \"iam:UploadSigningCertificate\",\n \"iam:UploadSSHPublicKey\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n # Allow for both users with \"path\" and without it\n---\n\n\n---\n\nChoice B:\nmodules/iam-group-with-policies/policies.tf\n@@ -39,6 +39,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateUser\",\n modules/iam-group-with-policies/policies.tf\n@@ \"iam:UploadSigningCertificate\",\n \"iam:UploadSSHPublicKey\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n # Allow for both users with \"path\" and without it\n---\n\n\n---\n\nChoice C:\nmodules/iam-group-with-policies/policies.tf\n@@ -39,6 +39,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateUser\",\n \"iam:UploadSigningCertificate\",\n \"iam:UploadSSHPublicKey\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n # Allow for both users with \"path\" and without it\n---\n\n\n---\n\nChoice D:\nmodules/iam-group-with-policies/policies.tf\n@@ -39,6 +39,9 @@ data \"aws_iam_policy_document\" \"iam_self_management\" {\n \"iam:UpdateUser\",\n \"iam:UploadSigningCertificate\",\n \"iam:UploadSSHPublicKey\",\n+ \"iam:TagUser\",\n+ \"iam:ListUserTags\",\n+ \"iam:UntagUser\",\n ]\n \n # Allow for both users with \"path\" and without it\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdds the ability to implement self-assume permission for IAM assumable role with OIDC.\r\n\r\n## Motivation and Context\r\nAWS is [changing the way IAM role trust policies work](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/). Before, they implicitly allowed the role to assume itself. After the change, an explicit permission is needed.\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\nTested via Terraform Enterprise on multiple environments, with prior config (without the new variable input) and with `explicit_permission_to_assume_self = true`.\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,8 @@ No modules.\n | [aws_iam_role_policy_attachment.custom](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.assume_role_with_oidc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.assume_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n \n ## Inputs\n@@ -41,6 +43,7 @@ No modules.\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n+| <a name=\"explicit_permission_to_assume_self\"></a> [explicit\\_permission\\_to\\_assume\\_self](#input\\_explicit\\_permission\\_to\\_assume\\_self) | Whether the role Trusted Policy should allow the role to assume itself | `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---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -62,6 +62,28 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"assume_self\" {\n+ count = var.explicit_permission_to_assume_self ? 1 : 0\n+\n+ statement {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ ]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role${var.role_path}${var.role_name}\"]\n+ }\n+ }\n+}\n+\n+data \"aws_iam_policy_document\" \"combined\" {\n+ source_policy_documents = concat(\n+ try([data.aws_iam_policy_document.assume_role_with_oidc[0].json], []),\n+ try([data.aws_iam_policy_document.assume_self[0].json], [])\n+ )\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -74,7 +96,7 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.combined.json\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -99,3 +99,9 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"explicit_permission_to_assume_self\" {\n+ description = \"Whether the role Trusted Policy should allow the role to assume itself\"\n+ type = bool\n+ default = false\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,8 @@ No modules.\n | [aws_iam_role_policy_attachment.custom](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.assume_role_with_oidc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.assume_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n \n ## Inputs\n@@ -41,6 +43,7 @@ var.role_permissions_boundary_arn\n modules.\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n+| <a name=\"explicit_permission_to_assume_self\"></a> [explicit\\_permission\\_to\\_assume\\_self](#input\\_explicit\\_permission\\_to\\_assume\\_self) | Whether the role Trusted Policy should allow the role to assume itself | `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---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -62,6 +62,28 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"assume_self\" {\n+ count = var.explicit_permission_to_assume_self ? 1 : 0\n+\n+ statement {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ ]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role${var.role_path}${var.role_name}\"]\n+ }\n+ }\n+}\n+\n+data \"aws_iam_policy_document\" \"combined\" {\n+ source_policy_documents = concat(\n+ try([data.aws_iam_policy_document.assume_role_with_oidc[0].json], []),\n+ try([data.aws_iam_policy_document.assume_self[0].json], [])\n+ )\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -74,7 +96,7 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.combined.json\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -99,3 +99,9 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"explicit_permission_to_assume_self\" {\n+ description = \"Whether the role Trusted Policy should allow the role to assume itself\"\n+ type = bool\n+ default = false\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,8 @@ No modules.\n | [aws_iam_role_policy_attachment.custom](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.assume_role_with_oidc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.assume_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | | source |\n+| [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n \n ## Inputs\n@@ -41,6 +43,7 @@ No modules.\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no |\n+| <a name=\"explicit_permission_to_assume_self\"></a> [explicit\\_permission\\_to\\_assume\\_self](#input\\_explicit\\_permission\\_to\\_assume\\_self) | Whether the role Trusted Policy should allow the role to assume itself | `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---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -62,6 +62,28 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"assume_self\" {\n+ count = var.explicit_permission_to_assume_self ? 1 : 0\n+\n+ statement {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ ]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role${var.role_path}${var.role_name}\"]\n+ }\n+ }\n+}\n+\n+data \"aws_iam_policy_document\" \"combined\" {\n+ source_policy_documents = concat(\n+ try([data.aws_iam_policy_document.assume_role_with_oidc[0].json], []),\n+ try([data.aws_iam_policy_document.assume_self[0].json], [])\n+ )\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -74,7 +96,7 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.combined.json\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -99,3 +99,9 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"explicit_permission_to_assume_self\" {\n+ description = \"Whether the role Trusted Policy should allow the role to assume itself\"\n+ type = bool\n+ default = false\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -32,6 +32,8 @@ No modules.\n | [aws_iam_role_policy_attachment.custom](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.assume_role_with_oidc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.assume_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n \n ## Inputs\n@@ -41,6 +43,7 @@ No modules.\n | <a name=\"input_aws_account_id\"></a> [aws\\_account\\_id](#input\\_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 | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `false` | no <a name=\"explicit_permission_to_assume_self\"></a> [explicit\\_permission\\_to\\_assume\\_self](#input\\_explicit\\_permission\\_to\\_assume\\_self) | Whether the role Trusted Policy should allow the role to assume itself | `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---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -62,6 +62,28 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"assume_self\" {\n+ count = var.explicit_permission_to_assume_self ? 1 : 0\n+\n+ statement {\n+ actions = [\n+ \"sts:AssumeRole\",\n+ ]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role${var.role_path}${var.role_name}\"]\n+ }\n+ }\n+}\n+\n+data \"aws_iam_policy_document\" \"combined\" {\n+ source_policy_documents = concat(\n+ try([data.aws_iam_policy_document.assume_role_with_oidc[0].json], []),\n+ try([data.aws_iam_policy_document.assume_self[0].json], [])\n+ )\n+}\n+\n resource \"aws_iam_role\" \"this\" {\n count = var.create_role ? 1 : 0\n \n@@ -74,7 +96,7 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = join(\"\", data.aws_iam_policy_document.assume_role_with_oidc.*.json)\n+ assume_role_policy = data.aws_iam_policy_document.combined.json\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -99,3 +99,9 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"explicit_permission_to_assume_self\" {\n+ description = \"Whether the role Trusted Policy should allow the role to assume itself\"\n+ type = bool\n+ default = false\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- Add support for spot request permissions with Karpenter IRSA role\r\n\r\n## Motivation and Context\r\n- Resolves #276 \r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.74.1\n+ rev: v1.75.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.74.1\n+ rev: v1.75.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*::image/*\",\n id: \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.74.1\n+ rev: v1.75.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n -571,6 \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.74.1\n+ rev: v1.75.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*::image/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:spot-instances-request/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\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:\nCloses https://github.com/terraform-aws-modules/terraform-aws-iam/issues/274\n\n---\n\nChoice A:\nmodules/iam-user/outputs.tf\n@@ -1,6 +1,7 @@\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+ 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+ = length(compact(aws_iam_access_key.this[*].encrypted_ses_smtp_password_v4)) > 0\n }\n \n output \"iam_user_name\" {\n@@ -120,15 +121,15 @@ EOF\n \n output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n description = \"Decrypt SES SMTP password command\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_ses_smtp_password_v4_pgp_message\" {\n description = \"Encrypted SES SMTP password\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/outputs.tf\n@@ -1,6 +1,7 @@\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+ 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+ has_encrypted_ses_smtp_password_v4 = length(compact(aws_iam_access_key.this[*].encrypted_ses_smtp_password_v4)) > 0\n }\n \n output \"iam_user_name\" {\n@@ -120,15 +121,15 @@ EOF\n \n output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n description = \"Decrypt SES SMTP password command\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_ses_smtp_password_v4_pgp_message\" {\n description = \"Encrypted SES SMTP password\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/outputs.tf\n@@ -1,6 +1,7 @@\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+ 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+ has_encrypted_ses_smtp_password_v4 = length(compact(aws_iam_access_key.this[*].encrypted_ses_smtp_password_v4)) > 0\n }\n \n output \"iam_user_name\" {\n@@ -120,15 +121,15 @@ EOF\n \n output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n description = \"Decrypt SES SMTP password command\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_ses_smtp_password_v4_pgp_message\" {\n description = \"Encrypted SES SMTP password\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/outputs.tf\n@@ -1,6 +1,7 @@\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+ 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+ has_encrypted_ses_smtp_password_v4 = length(compact(aws_iam_access_key.this[*].encrypted_ses_smtp_password_v4)) > 0\n }\n \n output \"iam_user_name\" {\n@@ -120,15 +121,15 @@ EOF\n \n output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n description = \"Decrypt SES SMTP password command\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null : <<EOF\n echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n EOF\n \n }\n \n output \"keybase_ses_smtp_password_v4_pgp_message\" {\n description = \"Encrypted SES SMTP password\"\n- value = !local.has_encrypted_secret ? null : <<EOF\n+ value = !local.has_encrypted_ses_smtp_password_v4 ? null <<EOF\n -----BEGIN PGP MESSAGE-----\n Version: Keybase OpenPGP v2.0.76\n Comment: https://keybase.io/crypto\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:\nUpdated Karpenter Controller IAM policy.\r\n\r\n## Description\r\nAdded missing actions to the Karpenter controller IAM policy\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n\r\nIf you are using the Karpenter terraform IRSA module you will get a lot of permission issues like the one below:\r\n```\r\n2022-08-30T19:58:50.621Z\tERROR\tcontroller.provisioning\tProvisioning failed, launching node, creating cloud provider instance, getting launch template configs, getting launch templates, describing images [{\r\n Name: \"image-id\",\r\n Values: [\"ami-0ab0c02538ad82487\"]\r\n}], UnauthorizedOperation: You are not authorized to perform this operation.\r\n\tstatus code: 403, request id: c83c94ec-972d-4d1a-9c2e-7ecaa64c1771\t{\"commit\": \"639756a\"}\r\n```\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\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\nThose IAM policy changes were tested manually on the AWS console.\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -531,24 +531,23 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:RunInstances\",\n+ \"iam:PassRole\",\n \"pricing:GetProducts\",\n+ \"ssm:GetParameter\",\n ]\n-\n- resources = [\"*\"]\n }\n \n statement {\n- actions = [\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n-\n+ sid = \"ConditionalEC2Termination\"\n+ effect = \"Allow\"\n resources = [\"*\"]\n+ actions = [\"ec2:TerminateInstances\"]\n \n condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n- values = [var.karpenter_controller_cluster_id]\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/Name\"\n+ values = [\"*karpenter*\"]\n }\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -531,24 +531,23 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:RunInstances\",\n+ \"iam:PassRole\",\n \"pricing:GetProducts\",\n+ \"ssm:GetParameter\",\n ]\n-\n- resources = [\"*\"]\n }\n \n statement {\n- actions = [\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n-\n+ sid = \"ConditionalEC2Termination\"\n+ effect = \"Allow\"\n resources = [\"*\"]\n+ actions = [\"ec2:TerminateInstances\"]\n \n condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n- values = [var.karpenter_controller_cluster_id]\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/Name\"\n+ values = [\"*karpenter*\"]\n }\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -531,24 +531,23 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:RunInstances\",\n+ \"iam:PassRole\",\n \"pricing:GetProducts\",\n+ \"ssm:GetParameter\",\n ]\n-\n- resources = [\"*\"]\n }\n \n statement {\n- actions = [\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n-\n+ sid = \"ConditionalEC2Termination\"\n+ effect = \"Allow\"\n resources = [\"*\"]\n+ actions = [\"ec2:TerminateInstances\"]\n \n condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n- values = [var.karpenter_controller_cluster_id]\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/Name\"\n+ values = [\"*karpenter*\"]\n }\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -531,24 +531,23 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeSpotPriceHistory\",\n+ \"ec2:RunInstances\",\n+ \"iam:PassRole\",\n \"pricing:GetProducts\",\n+ \"ssm:GetParameter\",\n ]\n-\n- resources = [\"*\"]\n }\n \n statement {\n- actions = [\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n-\n+ sid = \"ConditionalEC2Termination\"\n+ effect = \"Allow\"\n resources = [\"*\"]\n+ actions = [\"ec2:TerminateInstances\"]\n \n condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n- values = [var.karpenter_controller_cluster_id]\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/Name\"\n+ values = [\"*karpenter*\"]\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\nDetails in the issue: https://github.com/terraform-aws-modules/terraform-aws-iam/issues/270\r\n\r\n## Motivation and Context\r\nFor clarity, change the `karpenter_controller_cluster_id` to required.\r\n\r\n## Breaking Changes\r\nNo breaking changes, only a documentation change\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -202,7 +202,7 @@ No modules.\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n-| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | yes |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -202,7 +202,7 @@ No modules.\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n-| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | yes |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -202,7 +202,7 @@ No modules.\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no no | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n-| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | yes |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -202,7 +202,7 @@ No modules.\n | <a name=\"input_external_secrets_ssm_parameter_arns\"></a> [external\\_secrets\\_ssm\\_parameter\\_arns](#input\\_external\\_secrets\\_ssm\\_parameter\\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | name=\"input_external_secrets_ssm_parameter_arns\"></a> | <pre>[<br> \"arn:aws:ssm:*:*:parameter/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n | <a name=\"input_fsx_lustre_csi_service_role_arns\"></a> [fsx\\_lustre\\_csi\\_service\\_role\\_arns](#input\\_fsx\\_lustre\\_csi\\_service\\_role\\_arns) | Service role ARNs to allow FSx for Lustre CSI create and manage FSX for Lustre service linked roles | `list(string)` | <pre>[<br> \"arn:aws:iam::*:role/aws-service-role/s3.data-source.lustre.fsx.amazonaws.com/*\"<br>]</pre> | no |\n-| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | yes |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_subnet_account_id\"></a> [karpenter\\_subnet\\_account\\_id](#input\\_karpenter\\_subnet\\_account\\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `\"\"` | no |\n---\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\nResolves #244\r\n\r\n## Motivation and Context\r\nWorks around https://github.com/hashicorp/terraform-provider-aws/issues/23567\n\n---\n\nChoice A:\nmodules/iam-user/main.tf\n@@ -16,6 +16,11 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n pgp_key is var.pgp_key\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n+\n+ # TODO: Remove once https://github.com/hashicorp/terraform-provider-aws/issues/23567 is resolved\n+ lifecycle {\n+ ignore_changes = [password_reset_required]\n+ }\n }\n \n resource \"aws_iam_access_key\" \"this\" {\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/main.tf\n@@ -16,6 +16,11 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n pgp_key = var.pgp_key\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n+\n+ # TODO: Remove once https://github.com/hashicorp/terraform-provider-aws/issues/23567 is resolved\n+ lifecycle {\n+ ignore_changes = [password_reset_required]\n+ }\n }\n \n resource \"aws_iam_access_key\" \"this\" {\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/main.tf\n@@ -16,6 +16,11 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n pgp_key = var.pgp_key\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n+\n+ # TODO: Remove once https://github.com/hashicorp/terraform-provider-aws/issues/23567 is resolved\n+ lifecycle {\n+ ignore_changes = [password_reset_required]\n+ }\n }\n = resource \"aws_iam_access_key\" \"this\" {\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/main.tf\n@@ -16,6 +16,11 @@ resource \"aws_iam_user_login_profile\" \"this\" {\n pgp_key = var.pgp_key\n password_length = var.password_length\n password_reset_required = var.password_reset_required\n+\n+ # TODO: Remove once https://github.com/hashicorp/terraform-provider-aws/issues/23567 lifecycle resolved\n+ lifecycle {\n+ ignore_changes = [password_reset_required]\n+ }\n }\n \n resource \"aws_iam_access_key\" \"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\ncluster_autoscaler missing required policy `autoscaling:SetDesiredCapacity` to scaling\r\n\r\n## Motivation and Context\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/263\r\n\r\n## Breaking Changes\r\nNo Breaking Changes\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n statement = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\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 permission to `cluster_autoscaler` to fix missing permission issue\r\n\r\n## Motivation and Context\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/263\r\n\r\n## Breaking Changes\r\nNo Breaking Changes\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement \"cluster_autoscaler\" actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 \"cluster_autoscaler\" data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -63,6 +63,7 actions data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \n statement {\n actions = [\n+ \"autoscaling:SetDesiredCapacity\",\n \"autoscaling:DescribeAutoScalingGroups\",\n \"autoscaling:DescribeAutoScalingInstances\",\n \"autoscaling:DescribeLaunchConfigurations\",\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:\nDraft PR until more conversation happens around this change; after which I will do what is required in \"How Has This Been Tested?\"\r\n\r\n\r\n## Description\r\n\r\nThe example policy, which is used by this module, provided by the official aws-ebs-csi-driver is too lax (https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json).\r\n\r\nThis policy presents the following issues:\r\n\r\n* It allows the IAM Role to delete *any* EBS volume tagged with \"CSIVolumeName\" OR \"ebs.csi.aws.com/cluster\" OR \"kubernetes.io/cluster/*\"\r\n* It allows the IAM Role to delete *any* EBS snapshot tagged with \"CSIVolumeSnapshotName\" OR \"ebs.csi.aws.com/cluster\" OR \"kubernetes.io/cluster/*\"\r\n\r\nThis means the EBS CSI IAM Role can delete any volume or snapshot from any other cluster.\r\n\r\nThis commit changes this policy and replaces the OR conditions by AND conditions, as well as restricting `kubernetes.io/cluster/*` to `kubernetes.io/cluster/EKS_CLUSTER_ID`.\r\n\r\nThis means the EBS CSI IAM Role can only delete volume or snapshot it owns.\r\n\r\n## Breaking Changes\r\n\r\nThis change requires passing a mandatory `cluster_id` argument to the module.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -170,33 +170,21 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\"ec2:CreateVolume\"]\n resources = [\"*\"]\n \n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/CSIVolumeName\"\n+ values = [\"*\"]\n+ }\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n values = [\n true\n ]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n- condition {\n- test = \"StringLike\"\n- variable = \"aws:RequestTag/CSIVolumeName\"\n- values = [\"*\"]\n- }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n+ variable = \"aws:RequestTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -207,29 +195,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n- values = [\"*\"]\n+ variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [true]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -243,17 +219,16 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n values = [true]\n }\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n+ values = [\"owned\"]\n+ }\n }\n \n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -295,3 +295,8 @@ variable \"node_termination_handler_sqs_queue_arns\" {\n type = list(string)\n default = [\"*\"]\n }\n+\n+variable \"cluster_id\" {\n+ description = \"The EKS Cluster ID\"\n+ type = string\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -170,33 +170,21 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\"ec2:CreateVolume\"]\n resources = [\"*\"]\n \n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/CSIVolumeName\"\n+ values = [\"*\"]\n+ }\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n values = [\n true\n ]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n- condition {\n- test = \"StringLike\"\n- variable = \"aws:RequestTag/CSIVolumeName\"\n- values = [\"*\"]\n- }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n+ variable = \"aws:RequestTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -207,29 +195,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n- values = [\"*\"]\n+ variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [true]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -243,17 +219,16 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n values = [true]\n }\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n+ values = [\"owned\"]\n+ }\n }\n \n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -295,3 +295,8 @@ variable \"node_termination_handler_sqs_queue_arns\" {\n type = list(string)\n default = [\"*\"]\n }\n+\n+variable \"cluster_id\" {\n+ description = \"The EKS Cluster ID\"\n+ type = string\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -170,33 +170,21 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\"ec2:CreateVolume\"]\n resources = [\"*\"]\n \n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/CSIVolumeName\"\n+ values = [\"*\"]\n+ }\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n values = [\n true\n ]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n- condition {\n- = \"StringLike\"\n- variable = \"aws:RequestTag/CSIVolumeName\"\n- values = [\"*\"]\n- }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n+ variable = \"aws:RequestTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -207,29 +195,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n- values = [\"*\"]\n+ variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [true]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -243,17 +219,16 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n values = [true]\n }\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n+ values = [\"owned\"]\n+ }\n }\n \n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -295,3 +295,8 @@ variable \"node_termination_handler_sqs_queue_arns\" {\n type = list(string)\n default = [\"*\"]\n }\n+\n+variable \"cluster_id\" {\n+ description = \"The EKS Cluster ID\"\n+ type = string\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -170,33 +170,21 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\"ec2:CreateVolume\"]\n resources = [\"*\"]\n \n+ condition {\n+ test = \"StringLike\"\n+ variable = \"aws:RequestTag/CSIVolumeName\"\n+ values = [\"*\"]\n+ }\n condition {\n test = \"StringLike\"\n variable = \"aws:RequestTag/ebs.csi.aws.com/cluster\"\n values = [\n true\n ]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n- condition {\n- test = \"StringLike\"\n- variable = \"aws:RequestTag/CSIVolumeName\"\n- values = [\"*\"]\n- }\n- }\n-\n- statement {\n- actions = [\"ec2:CreateVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"aws:RequestTag/kubernetes.io/cluster/*\"\n+ variable = \"aws:RequestTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -207,29 +195,17 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n- values = [true]\n+ variable = \"ec2:ResourceTag/CSIVolumeName\"\n+ values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/CSIVolumeName\"\n- values = [\"*\"]\n+ variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n+ values = [true]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteVolume\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n- variable = \"ec2:ResourceTag/kubernetes.io/cluster/*\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n values = [\"owned\"]\n }\n }\n@@ -243,17 +219,16 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:ResourceTag/CSIVolumeSnapshotName\"\n values = [\"*\"]\n }\n- }\n-\n- statement {\n- actions = [\"ec2:DeleteSnapshot\"]\n- resources = [\"*\"]\n-\n condition {\n test = \"StringLike\"\n variable = \"ec2:ResourceTag/ebs.csi.aws.com/cluster\"\n values = [true]\n }\n+ condition {\n+ test = \"StringLike\"\n+ variable = \"ec2:ResourceTag/kubernetes.io/cluster/${var.cluster_id}\"\n+ values = [\"owned\"]\n+ }\n }\n \n dynamic \"statement\" {\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -295,3 +295,8 @@ variable \"node_termination_handler_sqs_queue_arns\" {\n type = list(string)\n default = [\"*\"]\n }\n+\n+variable \"cluster_id\" {\n+ description = \"The EKS Cluster ID\"\n+ type = string\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- Add additional permission for `karpenter` IAM policy added in v0.14.0 release, which allows the use of custom AMIs without the need for an entire launch template\r\n\r\n## Motivation and Context\r\n- Support additional permission required in v0.14.0 https://karpenter.sh/v0.14.0/upgrade-guide/#upgrading-to-v0140\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.2\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -523,6 +523,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateFleet\",\n \"ec2:CreateTags\",\n \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSubnets\",\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.2\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ \"aws_iam_policy_document\" +523,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateFleet\",\n \"ec2:CreateTags\",\n \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSubnets\",\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.2\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -523,6 +523,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:CreateFleet\",\n \"ec2:CreateTags\",\n \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeImages\",\n terraform_fmt\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSubnets\",\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.2\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -523,6 +523,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n - \"ec2:CreateTags\",\n \"ec2:DescribeLaunchTemplates\",\n+ \"ec2:DescribeImages\",\n \"ec2:DescribeInstances\",\n \"ec2:DescribeSecurityGroups\",\n \"ec2:DescribeSubnets\",\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 the way to expose encrypted ses_smtp_password_v4 in output.\r\n\r\n## Motivation and Context\r\nCurrently `iam_access_key_ses_smtp_password_v4` is empty if entity encrypted with pgp key.\r\nThe way to expose an encrypted ses_smtp_password_v4 was introduced in https://github.com/hashicorp/terraform-provider-aws/pull/19579\r\n\r\n## Breaking Changes\r\nMost likely not\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -15,8 +15,10 @@ When `pgp_key` is specified as `keybase:username`, make sure that that user has\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n+- `keybase_ses_smtp_password_v4_decrypt_command`\n - `keybase_password_pgp_message`\n - `keybase_secret_key_pgp_message`\n+- `keybase_ses_smtp_password_v4_pgp_message`\n \n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n@@ -70,6 +72,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_access_key_encrypted_secret\"></a> [iam\\_access\\_key\\_encrypted\\_secret](#output\\_iam\\_access\\_key\\_encrypted\\_secret) | The encrypted secret, base64 encoded |\n+| <a name=\"output_iam_access_key_encrypted_ses_smtp_password_v4\"></a> [iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4](#output\\_iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4) | The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | <a name=\"output_iam_access_key_id\"></a> [iam\\_access\\_key\\_id](#output\\_iam\\_access\\_key\\_id) | The access key ID |\n | <a name=\"output_iam_access_key_key_fingerprint\"></a> [iam\\_access\\_key\\_key\\_fingerprint](#output\\_iam\\_access\\_key\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the secret |\n | <a [iam\\_access\\_key\\_secret](#output\\_iam\\_access\\_key\\_secret) | The access key secret |\n@@ -87,5 +90,7 @@ No modules.\n | <a name=\"output_keybase_password_pgp_message\"></a> [keybase\\_password\\_pgp\\_message](#output\\_keybase\\_password\\_pgp\\_message) | Encrypted password |\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n+| <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n+| <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/outputs.tf\n@@ -57,10 +57,15 @@ output \"iam_access_key_encrypted_secret\" {\n \n output \"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 = try(aws_iam_access_key.this[0].ses_smtp_password_v4, aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n+ value = try(aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n sensitive = true\n }\n \n+output \"iam_access_key_encrypted_ses_smtp_password_v4\" {\n+ description = \"The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n+ value = try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")\n+}\n+\n output \"iam_access_key_status\" {\n description = \"Active or Inactive. Keys are initially active, but can be made inactive by other means.\"\n value = try(aws_iam_access_key.this[0].status, aws_iam_access_key.this_no_pgp[0].status, \"\")\n@@ -113,6 +118,27 @@ EOF\n \n }\n \n+output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n+ description = \"Decrypt SES SMTP password command\"\n+ value = !local.has_encrypted_secret ? null : <<EOF\n+echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n+EOF\n+\n+}\n+\n+output \"keybase_ses_smtp_password_v4_pgp_message\" {\n+ description = \"Encrypted SES SMTP password\"\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+\n+${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\n+-----END PGP MESSAGE-----\n+EOF\n+\n+}\n+\n output \"iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].ssh_public_key_id, \"\")\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -15,8 +15,10 @@ When `pgp_key` is specified as `keybase:username`, make sure that that user has\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n+- `keybase_ses_smtp_password_v4_decrypt_command`\n - `keybase_password_pgp_message`\n - `keybase_secret_key_pgp_message`\n+- `keybase_ses_smtp_password_v4_pgp_message`\n \n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n@@ -70,6 +72,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_access_key_encrypted_secret\"></a> [iam\\_access\\_key\\_encrypted\\_secret](#output\\_iam\\_access\\_key\\_encrypted\\_secret) | The encrypted secret, base64 encoded |\n+| <a name=\"output_iam_access_key_encrypted_ses_smtp_password_v4\"></a> [iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4](#output\\_iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4) | The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | <a name=\"output_iam_access_key_id\"></a> [iam\\_access\\_key\\_id](#output\\_iam\\_access\\_key\\_id) | The access key ID |\n | <a name=\"output_iam_access_key_key_fingerprint\"></a> [iam\\_access\\_key\\_key\\_fingerprint](#output\\_iam\\_access\\_key\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the secret |\n | <a name=\"output_iam_access_key_secret\"></a> [iam\\_access\\_key\\_secret](#output\\_iam\\_access\\_key\\_secret) | The access key secret |\n@@ -87,5 +90,7 @@ No modules.\n | <a name=\"output_keybase_password_pgp_message\"></a> [keybase\\_password\\_pgp\\_message](#output\\_keybase\\_password\\_pgp\\_message) | Encrypted password |\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt <!-- secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n+| <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n+| <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/outputs.tf\n@@ -57,10 +57,15 @@ output \"iam_access_key_encrypted_secret\" {\n \n output \"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 = try(aws_iam_access_key.this[0].ses_smtp_password_v4, aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n+ value = try(aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n sensitive = true\n }\n \n+output \"iam_access_key_encrypted_ses_smtp_password_v4\" {\n+ description = \"The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n+ value = try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")\n+}\n+\n output \"iam_access_key_status\" {\n description = \"Active or Inactive. Keys are initially active, but can be made inactive by other means.\"\n value = try(aws_iam_access_key.this[0].status, aws_iam_access_key.this_no_pgp[0].status, \"\")\n@@ -113,6 +118,27 @@ EOF\n \n }\n \n+output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n+ description = \"Decrypt SES SMTP password command\"\n+ value = !local.has_encrypted_secret ? null : <<EOF\n+echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n+EOF\n+\n+}\n+\n+output \"keybase_ses_smtp_password_v4_pgp_message\" {\n+ description = \"Encrypted SES SMTP password\"\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+\n+${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\n+-----END PGP MESSAGE-----\n+EOF\n+\n+}\n+\n output \"iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].ssh_public_key_id, \"\")\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -15,8 +15,10 @@ When `pgp_key` is specified as `keybase:username`, make sure that that user has\n This module outputs commands and PGP messages which can be @@ either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n+- `keybase_ses_smtp_password_v4_decrypt_command`\n - `keybase_password_pgp_message`\n - `keybase_secret_key_pgp_message`\n+- `keybase_ses_smtp_password_v4_pgp_message`\n \n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n@@ -70,6 +72,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_access_key_encrypted_secret\"></a> [iam\\_access\\_key\\_encrypted\\_secret](#output\\_iam\\_access\\_key\\_encrypted\\_secret) | The encrypted secret, base64 encoded |\n+| <a name=\"output_iam_access_key_encrypted_ses_smtp_password_v4\"></a> [iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4](#output\\_iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4) | The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | <a name=\"output_iam_access_key_id\"></a> [iam\\_access\\_key\\_id](#output\\_iam\\_access\\_key\\_id) | The access key ID |\n | <a name=\"output_iam_access_key_key_fingerprint\"></a> [iam\\_access\\_key\\_key\\_fingerprint](#output\\_iam\\_access\\_key\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the secret |\n | <a name=\"output_iam_access_key_secret\"></a> [iam\\_access\\_key\\_secret](#output\\_iam\\_access\\_key\\_secret) | The access key secret |\n@@ -87,5 +90,7 @@ No modules.\n | <a name=\"output_keybase_password_pgp_message\"></a> [keybase\\_password\\_pgp\\_message](#output\\_keybase\\_password\\_pgp\\_message) | Encrypted password |\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n+| <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n+| <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/outputs.tf\n@@ -57,10 +57,15 @@ output \"iam_access_key_encrypted_secret\" {\n \n output \"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 = try(aws_iam_access_key.this[0].ses_smtp_password_v4, aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n+ value = try(aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n sensitive = true\n }\n \n+output \"iam_access_key_encrypted_ses_smtp_password_v4\" {\n+ description = \"The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n+ value = try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")\n+}\n+\n output \"iam_access_key_status\" {\n description = \"Active or Inactive. Keys are initially active, but can be made inactive by other means.\"\n value = try(aws_iam_access_key.this[0].status, aws_iam_access_key.this_no_pgp[0].status, \"\")\n@@ -113,6 +118,27 @@ EOF\n \n }\n \n+output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n+ description = \"Decrypt SES SMTP password command\"\n+ value = !local.has_encrypted_secret ? null : <<EOF\n+echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n+EOF\n+\n+}\n+\n+output \"keybase_ses_smtp_password_v4_pgp_message\" {\n+ description = \"Encrypted SES SMTP password\"\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+\n+${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\n+-----END PGP MESSAGE-----\n+EOF\n+\n+}\n+\n output \"iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].ssh_public_key_id, \"\")\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -15,8 +15,10 @@ When `pgp_key` is specified as `keybase:username`, make sure that that user has\n This module outputs commands and PGP messages which can be decrypted either using [keybase.io web-site](https://keybase.io/decrypt) or using command line to get user's password and user's secret key:\n - `keybase_password_decrypt_command`\n - `keybase_secret_key_decrypt_command`\n+- `keybase_ses_smtp_password_v4_decrypt_command`\n - `keybase_password_pgp_message`\n - `keybase_secret_key_pgp_message`\n+- `keybase_ses_smtp_password_v4_pgp_message`\n \n <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n ## Requirements\n@@ -70,6 +72,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_access_key_encrypted_secret\"></a> [iam\\_access\\_key\\_encrypted\\_secret](#output\\_iam\\_access\\_key\\_encrypted\\_secret) | The encrypted secret, base64 encoded |\n+| <a name=\"output_iam_access_key_encrypted_ses_smtp_password_v4\"></a> [iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4](#output\\_iam\\_access\\_key\\_encrypted\\_ses\\_smtp\\_password\\_v4) | The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm |\n | <a name=\"output_iam_access_key_id\"></a> [iam\\_access\\_key\\_id](#output\\_iam\\_access\\_key\\_id) | The access key ID |\n | <a name=\"output_iam_access_key_key_fingerprint\"></a> [iam\\_access\\_key\\_key\\_fingerprint](#output\\_iam\\_access\\_key\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the secret |\n | <a name=\"output_iam_access_key_secret\"></a> [iam\\_access\\_key\\_secret](#output\\_iam\\_access\\_key\\_secret) | The access key secret |\n@@ -87,5 +90,7 @@ No modules.\n | <a name=\"output_keybase_password_pgp_message\"></a> [keybase\\_password\\_pgp\\_message](#output\\_keybase\\_password\\_pgp\\_message) | Encrypted password |\n | <a name=\"output_keybase_secret_key_decrypt_command\"></a> [keybase\\_secret\\_key\\_decrypt\\_command](#output\\_keybase\\_secret\\_key\\_decrypt\\_command) | Decrypt access secret key command |\n | <a name=\"output_keybase_secret_key_pgp_message\"></a> [keybase\\_secret\\_key\\_pgp\\_message](#output\\_keybase\\_secret\\_key\\_pgp\\_message) | Encrypted access secret key |\n+| <a name=\"output_keybase_ses_smtp_password_v4_decrypt_command\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_decrypt\\_command) | Decrypt SES SMTP password command |\n+| <a name=\"output_keybase_ses_smtp_password_v4_pgp_message\"></a> [keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message](#output\\_keybase\\_ses\\_smtp\\_password\\_v4\\_pgp\\_message) | Encrypted SES SMTP password |\n | <a name=\"output_pgp_key\"></a> [pgp\\_key](#output\\_pgp\\_key) | PGP key used to encrypt sensitive data for this user (if empty - secrets are not encrypted) |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-user/outputs.tf\n@@ -57,10 +57,15 @@ output \"iam_access_key_encrypted_secret\" {\n \n output \"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 = try(aws_iam_access_key.this[0].ses_smtp_password_v4, aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n+ value = try(aws_iam_access_key.this_no_pgp[0].ses_smtp_password_v4, \"\")\n sensitive = true\n }\n \n+output \"iam_access_key_encrypted_ses_smtp_password_v4\" {\n+ description = \"The encrypted secret access key converted into an SES SMTP password by applying AWS's Sigv4 conversion algorithm\"\n+ value = try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")\n+}\n+\n output \"iam_access_key_status\" {\n description = \"Active or Inactive. Keys are initially active, but can be made inactive by other means.\"\n value = try(aws_iam_access_key.this[0].status, aws_iam_access_key.this_no_pgp[0].status, \"\")\n@@ -113,6 +118,27 @@ EOF\n \n }\n \n+output \"keybase_ses_smtp_password_v4_decrypt_command\" {\n+ description = \"Decrypt SES SMTP password command\"\n+ value = !local.has_encrypted_secret ? null : <<EOF\n+echo \"${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\" | base64 --decode | keybase pgp decrypt\n+EOF\n+\n+}\n+\n+output \"keybase_ses_smtp_password_v4_pgp_message\" {\n+ description = \"Encrypted SES SMTP password\"\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+\n+${try(aws_iam_access_key.this[0].encrypted_ses_smtp_password_v4, \"\")}\n+-----END PGP MESSAGE-----\n+EOF\n+\n+}\n+\n output \"iam_user_ssh_key_ssh_public_key_id\" {\n description = \"The unique identifier for the SSH public key\"\n value = try(aws_iam_user_ssh_key.this[0].ssh_public_key_id, \"\")\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- Add additional Karpenter permissions for [spot pricing improvements](https://github.com/tzneal/karpenter/blob/main/website/content/en/preview/upgrade-guide/_index.md#upgrading-to-v0130)\r\n\r\n## Motivation and Context\r\n- Changes in v0.13.0 release have added additional permission requirements \r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.1\n+ rev: v1.72.2\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n \n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -529,6 +529,8 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeSpotPriceHistory\",\n+ \"pricing:GetProducts\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.1\n+ rev: v1.72.2\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -529,6 +529,8 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeSpotPriceHistory\",\n+ \"pricing:GetProducts\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.1\n+ rev: v1.72.2\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -529,6 +529,8 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeSpotPriceHistory\",\n+ \"pricing:GetProducts\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.72.1\n+ rev: v1.72.2\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -529,6 +529,8 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DescribeInstanceTypeOfferings\",\n \"ec2:DescribeAvailabilityZones\",\n+ \"ec2:DescribeSpotPriceHistory\",\n+ \"pricing:GetProducts\",\n ]\n \n resources = [\"*\"]\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:\nWhen Karpenter provisioners are using a custom `LaunchTemplate` there is a chance that it includes a custom key-pair.\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:key-pair/*\",\n ]\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n local.account_id)}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:key-pair/*\",\n ]\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:key-pair/*\",\n ]\n {\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -571,6 +571,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n data local.account_id)}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:key-pair/*\",\n ]\n }\n \n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-eks-role/main.tf\n@@ -77,4 +77,6 @@ resource \"aws_iam_role_policy_attachment\" \"custom\" {\n \n role = aws_iam_role.this[0].name\n policy_arn = each.key\n+\n+ depends_on = [var.role_policy_arns]\n }\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -39,8 +39,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"this\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/main.tf\n@@ -77,4 +77,6 @@ resource \"aws_iam_role_policy_attachment\" \"custom\" {\n \n role = aws_iam_role.this[0].name\n policy_arn = each.key\n+\n+ depends_on = [var.role_policy_arns]\n }\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -39,8 +39,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"this\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/main.tf\n@@ -77,4 +77,6 @@ resource \"aws_iam_role_policy_attachment\" \"custom\" {\n \n role = aws_iam_role.this[0].name\n policy_arn = each.key\n+\n+ depends_on = [var.role_policy_arns]\n }\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -39,8 +39,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"this\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/main.tf\n@@ -77,4 +77,6 @@ resource \"aws_iam_role_policy_attachment\" \"custom\" {\n \n role = aws_iam_role.this[0].name\n policy_arn = each.key\n+\n+ depends_on = [var.role_policy_arns]\n }\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -39,8 +39,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"this\" {\n- @@ = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\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 1. Update License\r\n 2. Update terraform latest version \r\n 3. Add version.tf in example\n\n---\n\nChoice A:\nexamples/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n \">= }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-eks-role/versions.tf\n@@ -1,8 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n- random = \">= 2\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-complete/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.34\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-eks-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.35\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\n\n\n---\n\nChoice B:\nexamples/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-eks-role/versions.tf\n@@ -1,8 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n- random = \">= 2\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-complete/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.34\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-eks-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.35\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\n\n\n---\n\nChoice C:\nexamples/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-eks-role/versions.tf\n@@ -1,8 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n- random = \">= 2\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-complete/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.34\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-eks-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.35\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\n\n\n---\n\nChoice D:\nexamples/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = }\n-}\n+}\n\\ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-eks-role/versions.tf\n@@ -1,8 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n- random = \">= 2\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-complete/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nexamples/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-account/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-oidc/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.34\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles-with-saml/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-assumable-roles/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-eks-role/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-assumable-roles-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-group-with-policies/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 3.35\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-read-only-policy/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\n---\nmodules/iam-user/versions.tf\n@@ -1,7 +1,11 @@\n+# Terraform version\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.14.0\"\n \n required_providers {\n- aws = \">= 2.50\"\n+ aws = {\n+ source = \"hashicorp/aws\"\n+ version = \">= 3.1.15\"\n+ }\n }\n-}\n+}\n\\ No newline at end of file\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- Avoid restricting Karpenter `RunInstances` subnets by tag key\r\n\r\n## Motivation and Context\r\n- Avoid having to over-tag VPC subnets for multiple Karpenter instances to run in a shared environment; restrictions are already set on launch template and security group\r\n\r\n## Breaking Changes\r\n- No; permissions are the same except now a tag is not required on the subnets for Karpenter to function\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.68.1\n+ rev: v1.71.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -552,7 +552,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n \n condition {\n@@ -569,6 +568,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n }\n \n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.68.1\n+ rev: v1.71.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -552,7 +552,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n \n condition {\n@@ -569,6 +568,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n }\n ]\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.68.1\n+ rev: v1.71.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -552,7 +552,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n \n condition {\n@@ -569,6 +568,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n }\n \n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: rev: v1.71.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -552,7 +552,6 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\n \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n \n condition {\n@@ -569,6 +568,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*:${coalesce(var.karpenter_subnet_account_id, local.account_id)}:subnet/*\",\n ]\n }\n \n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n\r\nChanged the name of the service account from `aws-ebs-csi-driver` to `ebs-csi-controller-sa`\r\n\r\n## Motivation and Context\r\nebs-csi plugin expects a specific service account name as mentioned here - https://docs.aws.amazon.com/eks/latest/userguide/csi-iam-role.html\r\n\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -90,7 +90,7 @@ module \"ebs_csi_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-ebs-csi-driver\"]\n+ namespace_service_accounts = [\"kube-system:ebs-csi-controller-sa\"]\n }\n }\n \n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -90,7 +90,7 @@ module \"ebs_csi_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-ebs-csi-driver\"]\n+ namespace_service_accounts = [\"kube-system:ebs-csi-controller-sa\"]\n }\n }\n \n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -90,7 +90,7 @@ module \"ebs_csi_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-ebs-csi-driver\"]\n+ namespace_service_accounts = [\"kube-system:ebs-csi-controller-sa\"]\n }\n }\n \n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -90,7 +90,7 @@ module \"ebs_csi_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-ebs-csi-driver\"]\n+ namespace_service_accounts = [\"kube-system:ebs-csi-controller-sa\"]\n module }\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- fixed invalid iam policy for app mesh controller.\r\n- https://github.com/terraform-aws-modules/terraform-aws-iam/pull/231#discussion_r856940564\r\n## Motivation and Context\r\n- Fixed invalid policy\r\n\r\n## Breaking Changes\r\n- none\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -947,9 +947,9 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \n statement {\n actions = [\n- \"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"\n+ \"iam:CreateServiceLinkedRole\"\n ]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -947,9 +947,9 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \n statement {\n actions = [\n- \"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"\n+ \"iam:CreateServiceLinkedRole\"\n ]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -947,9 +947,9 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \n statement {\n actions = [\n- \"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"\n+ \"iam:CreateServiceLinkedRole\"\n ]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n condition {\n test = \"StringLike\"\n test variable = \"iam:AWSServiceName\"\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -947,9 +947,9 @@ data \"aws_iam_policy_document\" \"appmesh_controller\" {\n \n statement {\n actions = [\n- \"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"\n+ \"iam:CreateServiceLinkedRole\"\n ]\n- resources = [\"*\"]\n+ resources = [\"arn:${local.partition}:iam::*:role/aws-service-role/appmesh.${local.dns_suffix}/AWSServiceRoleForAppMesh\"]\n condition {\n test = \"StringLike\"\n variable = \"iam:AWSServiceName\"\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis is a revised version of MR [229](https://github.com/terraform-aws-modules/terraform-aws-iam/pull/229)\r\nIt will fix all hardcoded arn to be partition targeted.\r\n\r\n## Motivation and Context\r\nCloses #226\r\n\r\n## Breaking Changes\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [*] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\r\nI have successfully launched Karpenter on \"aws-cn\" partiton.\r\nI will also create another MR for Karpenter examples in terraform-aws-modules.\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -18,6 +18,14 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n+\n+ # https://aws.amazon.com/premiumsupport/knowledge-center/eks-troubleshoot-oidc-and-irsa/?nc1=h_ls\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -550,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -565,10 +565,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -1144,7 +1144,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -18,6 +18,14 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n+\n+ # https://aws.amazon.com/premiumsupport/knowledge-center/eks-troubleshoot-oidc-and-irsa/?nc1=h_ls\n+ @@ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -550,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -565,10 +565,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -1144,7 +1144,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -18,6 +18,14 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n+\n+ # https://aws.amazon.com/premiumsupport/knowledge-center/eks-troubleshoot-oidc-and-irsa/?nc1=h_ls\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -550,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -565,10 +565,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -1144,7 +1144,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -18,6 +18,14 @@ data \"aws_iam_policy_document\" \"this\" {\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n+\n+ # https://aws.amazon.com/premiumsupport/knowledge-center/eks-troubleshoot-oidc-and-irsa/?nc1=h_ls\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n }\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -550,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -565,10 +565,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -1144,7 +1144,7 @@ \"karpenter_controller\" \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThe example attaches the wrong policy.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,7 +51,7 @@ module \"cert_manager_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n role_name = \"cert-manager\"\n- attach_external_dns_policy = true\n+ attach_cert_manager_policy = true\n cert_manager_hosted_zone_arns = [\"arn:aws:route53:::hostedzone/IClearlyMadeThisUp\"]\n \n oidc_providers = {\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,7 +51,7 @@ module \"cert_manager_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n role_name = \"cert-manager\"\n- attach_external_dns_policy = true\n+ attach_cert_manager_policy = cert_manager_hosted_zone_arns = [\"arn:aws:route53:::hostedzone/IClearlyMadeThisUp\"]\n \n oidc_providers = {\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,7 +51,7 @@ module \"cert_manager_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n role_name = \"cert-manager\"\n- attach_external_dns_policy = true\n+ attach_cert_manager_policy = true\n cert_manager_hosted_zone_arns = [\"arn:aws:route53:::hostedzone/IClearlyMadeThisUp\"]\n \n oidc_providers = {\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -51,7 +51,7 @@ module \"cert_manager_irsa_role\" {\n source = \"../../modules/iam-role-for-service-accounts-eks\"\n \n role_name = \"cert-manager\"\n- attach_external_dns_policy = true\n+ attach_cert_manager_policy = true\n cert_manager_hosted_zone_arns = [\"arn:aws:route53:::hostedzone/IClearlyMadeThisUp\"]\n \n oidc_providers = {\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\nFixes permissions for the AWS EFS CSI Driver IRSA.\r\n\r\n## Motivation and Context\r\nNecessary permissions for operation are omitted per the reference policy: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json\r\n\r\n## Breaking Changes\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -317,8 +317,10 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n \n statement {\n actions = [\n+ \"ec2:DescribeAvailabilityZones\",\n \"elasticfilesystem:DescribeAccessPoints\",\n \"elasticfilesystem:DescribeFileSystems\",\n+ \"elasticfilesystem:DescribeMountTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -317,8 +317,10 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n statement {\n actions = [\n+ \"ec2:DescribeAvailabilityZones\",\n \"elasticfilesystem:DescribeAccessPoints\",\n \"elasticfilesystem:DescribeFileSystems\",\n+ \"elasticfilesystem:DescribeMountTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -317,8 +317,10 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n \n statement {\n actions = [\n+ \"ec2:DescribeAvailabilityZones\",\n \"ec2:DescribeAvailabilityZones\",\n \"elasticfilesystem:DescribeAccessPoints\",\n \"elasticfilesystem:DescribeFileSystems\",\n+ \"elasticfilesystem:DescribeMountTargets\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -317,8 +317,10 @@ data \"aws_iam_policy_document\" \"efs_csi\" {\n \n statement {\n actions = [\n+ \"ec2:DescribeAvailabilityZones\",\n \"elasticfilesystem:DescribeAccessPoints\",\n \"elasticfilesystem:DescribeFileSystems\",\n+ \"elasticfilesystem:DescribeMountTargets\",\n \n resources = [\"*\"]\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- karpenter_controller_cluster_ids changed to karpenter_controller_cluster_id, but the README sample did not change.\r\n - https://github.com/terraform-aws-modules/terraform-aws-iam/pull/209\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -62,7 +62,7 @@ module \"karpenter_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n attach_vpc_cni_policy = true\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -62,7 +62,7 @@ module \"karpenter_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n attach_vpc_cni_policy = true\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -62,7 +62,7 @@ module \"karpenter_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n attach_vpc_cni_policy = true\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -62,7 +62,7 @@ module \"karpenter_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n attach_vpc_cni_policy = true\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n\r\nThis fix will replace all hardcoded aws arn to be parition targed\r\n\r\n## Motivation and Context\r\n\r\nhttps://github.com/terraform-aws-modules/terraform-aws-iam/issues/226\r\n\r\n## Breaking Changes\r\n\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [*] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\nI have successfully launched Karpenter on \"aws-cn\" partiton. This fix should also make \"aws-gov\" work as well\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -15,7 +15,13 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = var.assume_role_condition_test\n- variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -26,7 +26,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \"route53:ListResourceRecordSets\"\n ]\n \n- resources = var.cert_manager_hosted_zone_arns\n+ resources = [for s in var.cert_manager_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -263,7 +263,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n \n condition {\n test = \"Bool\"\n@@ -284,7 +284,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n }\n@@ -375,7 +375,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n \n statement {\n actions = [\"route53:ChangeResourceRecordSets\"]\n- resources = var.external_dns_hosted_zone_arns\n+ resources = [for s in var.external_dns_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -416,7 +416,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.external_secrets_ssm_parameter_arns\n+ resources = [for s in var.external_secrets_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -426,7 +426,8 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n ]\n- resources = var.external_secrets_secrets_manager_arns\n+\n+ resources = [for s in var.external_secrets_secrets_manager_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -462,7 +463,8 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"iam:AttachRolePolicy\",\n \"iam:PutRolePolicy\"\n ]\n- resources = var.fsx_lustre_csi_service_role_arns\n+\n+ resources = [for s in var.fsx_lustre_csi_service_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -548,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,21 +565,21 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.karpenter_controller_ssm_parameter_arns\n+ resources = [for s in var.karpenter_controller_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n actions = [\"iam:PassRole\"]\n- resources = var.karpenter_controller_node_iam_role_arns\n+ resources = [for s in var.karpenter_controller_node_iam_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -911,7 +913,7 @@ data \"aws_iam_policy_document\" \"amazon_managed_service_prometheus\" {\n \"aps:GetMetricMetadata\",\n ]\n \n- resources = var.amazon_managed_service_prometheus_workspace_arns\n+ resources = [for s in var.amazon_managed_service_prometheus_workspace_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -958,7 +960,7 data \"aws_iam_policy_document\" \"node_termination_handler\" {\n \"sqs:ReceiveMessage\",\n ]\n \n- resources = var.node_termination_handler_sqs_queue_arns\n+ resources = [for s in var.node_termination_handler_sqs_queue_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -987,7 +989,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -15,7 +15,13 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = var.assume_role_condition_test\n- variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -26,7 +26,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \"route53:ListResourceRecordSets\"\n ]\n \n- resources = var.cert_manager_hosted_zone_arns\n+ resources = [for s in var.cert_manager_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -263,7 +263,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n \n condition {\n test = \"Bool\"\n@@ -284,7 +284,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n }\n@@ -375,7 +375,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n \n statement {\n actions = [\"route53:ChangeResourceRecordSets\"]\n- resources = var.external_dns_hosted_zone_arns\n+ resources = [for s in var.external_dns_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -416,7 +416,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.external_secrets_ssm_parameter_arns\n+ resources = [for s in var.external_secrets_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -426,7 +426,8 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n ]\n- resources = var.external_secrets_secrets_manager_arns\n+\n+ resources = [for s in var.external_secrets_secrets_manager_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -462,7 +463,8 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"iam:AttachRolePolicy\",\n \"iam:PutRolePolicy\"\n ]\n- \n- resources = var.fsx_lustre_csi_service_role_arns\n+\n+ resources = [for s in var.fsx_lustre_csi_service_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -548,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,21 +565,21 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.karpenter_controller_ssm_parameter_arns\n+ resources = [for s in var.karpenter_controller_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n actions = [\"iam:PassRole\"]\n- resources = var.karpenter_controller_node_iam_role_arns\n+ resources = [for s in var.karpenter_controller_node_iam_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -911,7 +913,7 @@ data \"aws_iam_policy_document\" \"amazon_managed_service_prometheus\" {\n \"aps:GetMetricMetadata\",\n ]\n \n- resources = var.amazon_managed_service_prometheus_workspace_arns\n+ resources = [for s in var.amazon_managed_service_prometheus_workspace_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -958,7 +960,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n \"sqs:ReceiveMessage\",\n ]\n \n- resources = var.node_termination_handler_sqs_queue_arns\n+ resources = [for s in var.node_termination_handler_sqs_queue_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -987,7 +989,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -15,7 +15,13 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = var.assume_role_condition_test\n- variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -26,7 +26,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \"route53:ListResourceRecordSets\"\n ]\n \n- resources = var.cert_manager_hosted_zone_arns\n+ resources = [for s in var.cert_manager_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -263,7 +263,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n \n condition {\n test = \"Bool\"\n@@ -284,7 +284,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n }\n@@ -375,7 +375,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n \n statement {\n actions = [\"route53:ChangeResourceRecordSets\"]\n- resources = var.external_dns_hosted_zone_arns\n+ resources = [for s in var.external_dns_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -416,7 +416,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.external_secrets_ssm_parameter_arns\n+ resources = [for s in var.external_secrets_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -426,7 +426,8 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n ]\n- resources = var.external_secrets_secrets_manager_arns\n+\n+ resources = [for s in var.external_secrets_secrets_manager_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -462,7 +463,8 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"iam:AttachRolePolicy\",\n \"iam:PutRolePolicy\"\n ]\n- resources = var.fsx_lustre_csi_service_role_arns\n+\n+ resources = [for s in var.fsx_lustre_csi_service_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -548,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- var.node_termination_handler_sqs_queue_arns \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,21 +565,21 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.karpenter_controller_ssm_parameter_arns\n+ resources = [for s in var.karpenter_controller_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n actions = [\"iam:PassRole\"]\n- resources = var.karpenter_controller_node_iam_role_arns\n+ resources = [for s in var.karpenter_controller_node_iam_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -911,7 +913,7 @@ data \"aws_iam_policy_document\" \"amazon_managed_service_prometheus\" {\n \"aps:GetMetricMetadata\",\n ]\n \n- resources = var.amazon_managed_service_prometheus_workspace_arns\n+ resources = [for s in var.amazon_managed_service_prometheus_workspace_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -958,7 +960,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n \"sqs:ReceiveMessage\",\n ]\n \n- resources = var.node_termination_handler_sqs_queue_arns\n+ resources = [for s in var.node_termination_handler_sqs_queue_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -987,7 +989,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -15,7 +15,13 @@ data \"aws_iam_policy_document\" \"this\" {\n \n condition {\n test = var.assume_role_condition_test\n- variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud\"\n+ values = [\"sts.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = var.assume_role_condition_test\n+ variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:aud:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -26,7 +26,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \"route53:ListResourceRecordSets\"\n ]\n \n- resources = var.cert_manager_hosted_zone_arns\n+ resources = [for s in var.cert_manager_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -263,7 +263,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n \n condition {\n test = \"Bool\"\n@@ -284,7 +284,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = var.ebs_csi_kms_cmk_ids\n+ resources = [for s in var.ebs_csi_kms_cmk_ids : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n }\n@@ -375,7 +375,7 @@ data \"aws_iam_policy_document\" \"external_dns\" {\n \n statement {\n actions = [\"route53:ChangeResourceRecordSets\"]\n- resources = var.external_dns_hosted_zone_arns\n+ resources = [for s in var.external_dns_hosted_zone_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -416,7 +416,7 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.external_secrets_ssm_parameter_arns\n+ resources = [for s in var.external_secrets_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -426,7 +426,8 @@ data \"aws_iam_policy_document\" \"external_secrets\" {\n \"secretsmanager:DescribeSecret\",\n \"secretsmanager:ListSecretVersionIds\",\n ]\n- resources = var.external_secrets_secrets_manager_arns\n+\n+ resources = [for s in var.external_secrets_secrets_manager_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -462,7 +463,8 @@ data \"aws_iam_policy_document\" \"fsx_lustre_csi\" {\n \"iam:AttachRolePolicy\",\n \"iam:PutRolePolicy\"\n ]\n- resources = var.fsx_lustre_csi_service_role_arns\n+\n+ resources = [for s in var.fsx_lustre_csi_service_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n@@ -548,9 +550,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,21 +565,21 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n statement {\n actions = [\"ssm:GetParameter\"]\n- resources = var.karpenter_controller_ssm_parameter_arns\n+ resources = [for s in var.karpenter_controller_ssm_parameter_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n \n statement {\n actions = [\"iam:PassRole\"]\n- resources = var.karpenter_controller_node_iam_role_arns\n+ resources = [for s in var.karpenter_controller_node_iam_role_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -911,7 +913,7 @@ data \"aws_iam_policy_document\" \"amazon_managed_service_prometheus\" {\n \"aps:GetMetricMetadata\",\n ]\n \n- resources = var.amazon_managed_service_prometheus_workspace_arns\n+ resources = [for s in var.amazon_managed_service_prometheus_workspace_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -958,7 +960,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n \"sqs:ReceiveMessage\",\n ]\n \n- resources = var.node_termination_handler_sqs_queue_arns\n+ resources = [for s in var.node_termination_handler_sqs_queue_arns : replace(s, \"arn:aws:\", \"arn:${local.partition}:\")]\n }\n }\n \n@@ -987,7 +989,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\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\nThis commit fix https://github.com/terraform-aws-modules/terraform-aws-iam/issues/226\r\n\r\n## Motivation and Context\r\n\r\nKarpterner added recently ignores aws_parition. It should follow the pattern used in aws load-balancer, VPN-CNI, etc \n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -548,9 +548,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,10 +563,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -987,7 +987,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n var.vpc_cni_enable_ipv4 actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -548,9 +548,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,10 +563,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -987,7 +987,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -548,9 +548,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,10 +563,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -987,7 +987,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -17,7 +17,7 @@ data \"aws_iam_policy_document\" \"cert_manager\" {\n \n statement {\n actions = [\"route53:GetChange\"]\n- resources = [\"arn:aws:route53:::change/*\"]\n+ resources = [\"arn:${local.partition}:route53:::change/*\"]\n }\n \n statement {\n@@ -548,9 +548,9 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n- \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n- \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:subnet/*\",\n ]\n \n condition {\n@@ -563,10 +563,10 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n statement {\n actions = [\"ec2:RunInstances\"]\n resources = [\n- \"arn:aws:ec2:*::image/*\",\n- \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n- \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n- \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ \"arn:${local.partition}:ec2:*::image/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:${local.partition}:ec2:*:${local.account_id}:network-interface/*\",\n ]\n }\n \n@@ -987,7 +987,7 @@ resource \"aws_iam_role_policy_attachment\" \"node_termination_handler\" {\n data \"aws_iam_policy_document\" \"vpc_cni\" {\n count = var.create_role && var.attach_vpc_cni_policy ? 1 : 0\n \n- # arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\n+ # arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy\n dynamic \"statement\" {\n for_each = var.vpc_cni_enable_ipv4 ? [1] : []\n content {\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\nThe [AWS documentation](https://docs.aws.amazon.com/eks/latest/userguide/managing-vpc-cni.html) uses a service account name `aws-node` instead of `aws-vpc-cni`, the Helm chart name.\r\n\r\n## Motivation and Context\r\n\r\nDon't want someone to be misled by current documentation.\r\n\r\n## Breaking Changes\r\n\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nI've successfully used `aws-node` in my projects and was forced to double-check the AWS documentation after seeing the example here.\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -255,7 +255,7 @@ module \"vpc_cni_ipv4_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n namespace_service_accounts }\n \n@@ -272,7 +272,7 @@ module \"vpc_cni_ipv6_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n }\n \n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -255,7 +255,7 @@ module \"vpc_cni_ipv4_irsa_role\" {\n oidc_providers = {\n ex = {\n examples/iam-role-for-service-accounts-eks/main.tf\n@@ provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n }\n \n@@ -272,7 +272,7 @@ module \"vpc_cni_ipv6_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n }\n \n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -255,7 +255,7 @@ module \"vpc_cni_ipv4_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n }\n \n@@ -272,7 +272,7 @@ module \"vpc_cni_ipv6_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n }\n \n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -255,7 +255,7 @@ module \"vpc_cni_ipv4_irsa_role\" {\n oidc_providers {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\n }\n }\n \n@@ -272,7 +272,7 @@ module \"vpc_cni_ipv6_irsa_role\" {\n oidc_providers = {\n ex = {\n provider_arn = module.eks.oidc_provider_arn\n- namespace_service_accounts = [\"kube-system:aws-vpc-cni\"]\n+ namespace_service_accounts = [\"kube-system:aws-node\"]\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\n<!--- Describe your changes in detail -->\r\nReplace `provider_arns` with `provider_arn` in documentation\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\n```\r\nTerraform fmt............................................................Passed\r\nTerraform validate.......................................................Failed\r\n- hook id: terraform_validate\r\n- exit code: 1\r\n\r\nValidation failed: examples/iam-assumable-roles-with-saml\r\n╷\r\n│ Error: Missing required provider\r\n│ \r\n│ This configuration requires provider registry.terraform.io/hashicorp/aws,\r\n│ but that provider isn't available. You may be able to install it\r\n│ automatically by running:\r\n│ terraform init\r\n╵\r\n\r\nTerraform docs...........................................................Passed\r\nTerraform validate with tflint...........................................Passed\r\ncheck for merge conflicts................................................Passed\r\nfix end of files.........................................................Passed\r\n```\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -168,7 +168,7 @@ No modules.\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC | where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -41,7 +41,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -168,7 +168,7 @@ No modules.\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -41,7 +41,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC name=\"input_role_description\"></a> where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -168,7 +168,7 @@ No modules.\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -41,7 +41,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n type = any\n default = {}\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -168,7 +168,7 @@ No modules.\n | <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n-| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the List `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n+| <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |\n | <a name=\"input_role_description\"></a> [role\\_description](#input\\_role\\_description) | IAM Role description | `string` | `null` | no |\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | Name of IAM role | `string` | `null` | no |\n | <a name=\"input_role_name_prefix\"></a> [role\\_name\\_prefix](#input\\_role\\_name\\_prefix) | IAM role name prefix | `string` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -41,7 +41,7 @@ variable \"role_policy_arns\" {\n }\n \n variable \"oidc_providers\" {\n- description = \"Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts`\"\n+ description = \"Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts`\"\n type = any\n default = {}\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\nFixed typo in IRSA module README\r\n\r\n## Motivation and Context\r\nFixes annoying typo\r\n\r\n## Breaking Changes\r\nno\r\n\r\n## How Has This Been Tested?\r\nI've read this line twice\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -6,7 +6,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n-- [Node Termination Hanlder](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n+- [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n - [EFS Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -6,7 +6,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n-- [Node Termination Hanlder](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n+- [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -6,7 +6,7 @@ Creates an IAM role which can be assumed by AWS - `ServiceAccount`s with optio\n - [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n-- [Node Termination Hanlder](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n+- [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -6,7 +6,7 @@ Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optio\n - [EBS Binding Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)\n - [EFS CSI Driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/iam-policy-example.json)\n - [VPC CNI](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html)\n-- [Node Termination Hanlder](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n+- [Node Termination Handler](https://github.com/aws/aws-node-termination-handler#5-create-an-iam-role-for-the-pods)\n - [Karpenter](https://github.com/aws/karpenter/blob/main/website/content/en/preview/getting-started/cloudformation.yaml)\n - [Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/install/iam_policy.json)\n - [Load Balancer Controller Target Group Binding Only](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/#iam-permission-subset-for-those-who-use-targetgroupbinding-only-and-dont-plan-to-use-the-aws-load-balancer-controller-to-manage-security-group-rules)\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 variable to allow changing tag condition on Karpenter `iam-role-for-service-accounts-eks` policy\r\n\r\n## Motivation and Context\r\n- https://github.com/aws/karpenter/issues/1488#issuecomment-1097007799\r\n- This change will give users more control over the IAM condition of the Karpenter policy, allowing for situations where multiple clusters in the same account are provisioned with Karpenter managing scaling\r\n\r\n## Breaking Changes\r\n- No, current static value is now the default variable value\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -23,7 = @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.1.0\n+ rev: v4.2.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -165,6 +165,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -454,7 +454,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n@@ -469,7 +469,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -165,6 +165,12 @@ variable \"karpenter_controller_cluster_id\" {\n default = \"*\"\n }\n \n+variable \"karpenter_tag_key\" {\n+ description = \"Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner\"\n+ type = string\n+ default = \"karpenter.sh/discovery\"\n+}\n+\n variable \"karpenter_controller_ssm_parameter_arns\" {\n description = \"List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter\"\n type = list(string)\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.1.0\n+ rev: v4.2.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -165,6 +165,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes should `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -454,7 +454,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n@@ -469,7 +469,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -165,6 +165,12 @@ variable \"karpenter_controller_cluster_id\" {\n default = \"*\"\n }\n \n+variable \"karpenter_tag_key\" {\n+ description = \"Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner\"\n+ type = string\n+ default = \"karpenter.sh/discovery\"\n+}\n+\n variable \"karpenter_controller_ssm_parameter_arns\" {\n description = \"List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter\"\n type = list(string)\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.1.0\n+ rev: v4.2.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -165,6 +165,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -454,7 +454,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n@@ -469,7 +469,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -165,6 +165,12 @@ variable \"karpenter_controller_cluster_id\" {\n default = \"*\"\n }\n \n+variable \"karpenter_tag_key\" {\n+ description = \"Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner\"\n+ type = string\n+ default = \"karpenter.sh/discovery\"\n+}\n+\n variable \"karpenter_controller_ssm_parameter_arns\" {\n description = \"List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter\"\n type = list(string)\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -23,7 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.1.0\n+ rev: v4.2.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -165,6 +165,7 @@ No modules.\n | <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n+| <a name=\"input_karpenter_tag_key\"></a> [karpenter\\_tag\\_key](#input\\_karpenter\\_tag\\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `\"karpenter.sh/discovery\"` | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n | <a name=\"input_node_termination_handler_sqs_queue_arns\"></a> [node\\_termination\\_handler\\_sqs\\_queue\\_arns](#input\\_node\\_termination\\_handler\\_sqs\\_queue\\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_oidc_providers\"></a> [oidc\\_providers](#input\\_oidc\\_providers) | Map of OIDC providers where each provdier map should contain the `provider`, `provider_arns`, and `namespace_service_accounts` | `any` | `{}` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -454,7 +454,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n@@ -469,7 +469,7 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n \n condition {\n test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ variable = \"ec2:ResourceTag/${var.karpenter_tag_key}\"\n values = [var.karpenter_controller_cluster_id]\n }\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -165,6 +165,12 @@ variable \"karpenter_controller_cluster_id\" {\n default = \"*\"\n }\n \n+variable \"karpenter_tag_key\" {\n+ description = \"Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner\"\n+ type = string\n+ default = \"karpenter.sh/discovery\"\n+}\n+\n variable \"karpenter_controller_ssm_parameter_arns\" {\n description = \"List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter\"\n type = list(string)\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nUpdates the required terraform version for iam-user to `>= 0.15.0`\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\nThe [`sensitive` function](https://www.terraform.io/language/functions/sensitive) is only available in terraform v0.15 and later.\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, it is already broken for user's using terraform 0.14 and below.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/iam-user/README.md\n@@ -20,7 +20,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nexamples/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15\"\n \n required_providers {\n aws = {\n---\nmodules/iam-user/README.md\n@@ -23,7 +23,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | | 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nmodules/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n\nChoice B:\nexamples/iam-user/README.md\n@@ -20,7 +20,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nexamples/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15\"\n \n required_providers {\n aws = {\n---\nmodules/iam-user/README.md\n@@ -23,7 +23,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name required_providers Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nmodules/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n\nChoice C:\nexamples/iam-user/README.md\n@@ -20,7 +20,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nexamples/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15\"\n \n required_providers {\n aws = {\n---\nmodules/iam-user/README.md\n@@ -23,7 +23,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nmodules/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n\nChoice D:\nexamples/iam-user/README.md\n@@ -20,7 +20,7 @@ Run `terraform destroy` when you don't need these resources.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | |\n 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nexamples/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15\"\n \n required_providers {\n aws = {\n---\nmodules/iam-user/README.md\n@@ -23,7 +23,7 @@ This module outputs commands and PGP messages which can be decrypted either usin\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.15.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n---\nmodules/iam-user/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.15.0\"\n \n required_providers {\n aws = {\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:\nFixed #213\r\nFixed #212\n\n---\n\nChoice A:\nexamples/iam-user/README.md\n@@ -55,6 +55,7 @@ No inputs.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_unique_id\"></a> [iam\\_user\\_unique\\_id](#output\\_iam\\_user\\_unique\\_id) | The unique ID assigned by AWS |\n | <a name=\"output_keybase_password_decrypt_command\"></a> [keybase\\_password\\_decrypt\\_command](#output\\_keybase\\_password\\_decrypt\\_command) | Decrypt user password command |\n---\nexamples/iam-user/outputs.tf\n@@ -23,6 +23,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value module.iam_user.iam_user_login_profile_encrypted_password\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = module.iam_user.iam_user_login_profile_password\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = module.iam_user.iam_access_key_id\n---\nmodules/iam-user/outputs.tf\n@@ -30,7 +30,7 @@ output \"iam_user_login_profile_encrypted_password\" {\n \n output \"iam_user_login_profile_password\" {\n description = \"The user password\"\n- value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ value = lookup(try(aws_iam_user_login_profile.this[0], {}), \"password\", sensitive(\"\"))\n sensitive = true\n }\n \n---\n\n\n---\n\nChoice B:\nexamples/iam-user/README.md\n@@ -55,6 +55,7 @@ No inputs.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a -30,7 [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_unique_id\"></a> [iam\\_user\\_unique\\_id](#output\\_iam\\_user\\_unique\\_id) | The unique ID assigned by AWS |\n | <a name=\"output_keybase_password_decrypt_command\"></a> [keybase\\_password\\_decrypt\\_command](#output\\_keybase\\_password\\_decrypt\\_command) | Decrypt user password command |\n---\nexamples/iam-user/outputs.tf\n@@ -23,6 +23,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = module.iam_user.iam_user_login_profile_encrypted_password\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = module.iam_user.iam_user_login_profile_password\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = module.iam_user.iam_access_key_id\n---\nmodules/iam-user/outputs.tf\n@@ -30,7 +30,7 @@ output \"iam_user_login_profile_encrypted_password\" {\n \n output \"iam_user_login_profile_password\" {\n description = \"The user password\"\n- value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ value = lookup(try(aws_iam_user_login_profile.this[0], {}), \"password\", sensitive(\"\"))\n sensitive = true\n }\n \n---\n\n\n---\n\nChoice C:\nexamples/iam-user/README.md\n@@ -55,6 +55,7 @@ No inputs.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_unique_id\"></a> [iam\\_user\\_unique\\_id](#output\\_iam\\_user\\_unique\\_id) | The unique ID assigned by AWS |\n | <a name=\"output_keybase_password_decrypt_command\"></a> [keybase\\_password\\_decrypt\\_command](#output\\_keybase\\_password\\_decrypt\\_command) | Decrypt user password command |\n---\nexamples/iam-user/outputs.tf\n@@ -23,6 +23,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = module.iam_user.iam_user_login_profile_encrypted_password\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = module.iam_user.iam_user_login_profile_password\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value | = module.iam_user.iam_access_key_id\n---\nmodules/iam-user/outputs.tf\n@@ -30,7 +30,7 @@ output \"iam_user_login_profile_encrypted_password\" {\n \n output \"iam_user_login_profile_password\" {\n description = \"The user password\"\n- value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ value = lookup(try(aws_iam_user_login_profile.this[0], {}), \"password\", sensitive(\"\"))\n sensitive = true\n }\n \n---\n\n\n---\n\nChoice D:\nexamples/iam-user/README.md\n@@ -55,6 +55,7 @@ No inputs.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_unique_id\"></a> [iam\\_user\\_unique\\_id](#output\\_iam\\_user\\_unique\\_id) | The unique ID assigned by AWS |\n | <a name=\"output_keybase_password_decrypt_command\"></a> [keybase\\_password\\_decrypt\\_command](#output\\_keybase\\_password\\_decrypt\\_command) | Decrypt user password command |\n---\nexamples/iam-user/outputs.tf\n@@ -23,6 +23,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = module.iam_user.iam_user_login_profile_encrypted_password\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = module.iam_user.iam_user_login_profile_password\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = module.iam_user.iam_access_key_id\n---\nmodules/iam-user/outputs.tf\n@@ -30,7 +30,7 @@ output \"iam_user_login_profile_encrypted_password\" {\n \n output \"iam_user_login_profile_password\" {\n description = \"The user password\"\n- value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ value = lookup(try(aws_iam_user_login_profile.this[0], {}), \"password\", sensitive(\"\"))\n sensitive = true\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\nRevert AWS provider version requirement for recent release, in order to prevent something like the following error out of a `terraform init`:\r\n\r\n```\r\n│ Error: Failed to query available provider packages\r\n│ \r\n│ Could not retrieve the list of available versions for provider hashicorp/aws:\r\n│ no available releases match the given constraints >= 2.45.0, ~> 3.0, < 4.0.0,\r\n│ >= 4.1.0\r\n```\r\n\r\n## Motivation and Context\r\nNot break compatibility in workspaces that still couldn't upgrade their AWS provider -- but probably should eventually.\r\n\r\n## Breaking Changes\r\nThe opposite, actually.\r\n\r\n## How Has This Been Tested?\r\n`terraform init` working again.\r\n\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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) | >= 4.1.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n \n ## Modules\n \n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.1.0\"\n+ version = \">= 2.50\"\n [aws](#provider\\_aws) }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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) | >= 4.1.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n \n ## Modules\n \n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.1.0\"\n+ version = \">= 2.50\"\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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) | >= 4.1.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n ## Modules\n \n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.1.0\"\n+ version = \">= 2.50\"\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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) | >= 4.1.0 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 2.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n \n ## Modules\n \n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.1.0\"\n+ version = \">= 2.50\"\n }\n }\n }\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- Permit `RunInstances` permission for Karpenter when request contains `karpenter.sh/discovery` tag key with cluster ID as the value\r\n\r\n## Motivation and Context\r\n- https://github.com/aws/karpenter/pull/1332#discussion_r832425261\r\n- This restricts the role to only allow create/destroy operations on resources tagged with `{\"karpenter.sh/discovery\": \"<CLUSTER_ID>\"}` \r\n\r\n## Breaking Changes\r\n- No - it currently does not work as written so therefore the changes are not breaking\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\t- Tested in conjunction with https://github.com/aws/karpenter/pull/1332 \r\n\n\n---\n\nChoice A:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -153,7 +153,7 @@ module \"karpenter_controller_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n oidc_providers = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -124,6 +124,7 @@ No modules.\n | [aws_iam_role_policy_attachment.node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n+| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.ebs_csi](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.external_dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -151,7 +152,7 @@ No modules.\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow external DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n-| <a name=\"input_karpenter_controller_cluster_ids\"></a> [karpenter\\_controller\\_cluster\\_ids](#input\\_karpenter\\_controller\\_cluster\\_ids) | List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy | `list(string)` | `[]` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1,6 +1,8 @@\n data \"aws_partition\" \"current\" {}\n+data \"aws_caller_identity\" \"current\" {}\n \n locals {\n+ account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n }\n@@ -442,25 +444,46 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\"*\"]\n }\n \n- dynamic \"statement\" {\n- for_each = toset(var.karpenter_controller_cluster_ids)\n- content {\n- actions = [\n- \"ec2:RunInstances\",\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n+ statement {\n+ actions = [\n+ \"ec2:TerminateInstances\",\n+ \"ec2:DeleteLaunchTemplate\",\n+ ]\n \n- resources = [\"*\"]\n+ resources = [\"*\"]\n \n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n- values = [statement.value]\n- }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n }\n }\n \n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*::image/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ ]\n+ }\n+\n statement {\n actions = [\"ssm:GetParameter\"]\n resources = var.karpenter_controller_ssm_parameter_arns\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -152,10 +152,10 @@ variable \"attach_karpenter_controller_policy\" {\n default = false\n }\n \n-variable \"karpenter_controller_cluster_ids\" {\n- description = \"List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy\"\n- type = list(string)\n- default = []\n+variable \"karpenter_controller_cluster_id\" {\n+ description = \"Cluster ID where the Karpenter controller is provisioned/managing\"\n+ type = string\n+ default = \"*\"\n }\n \n variable \"karpenter_controller_ssm_parameter_arns\" {\n---\n\n\n---\n\nChoice B:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -153,7 +153,7 @@ module \"karpenter_controller_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n oidc_providers = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -124,6 +124,7 @@ No modules.\n | [aws_iam_role_policy_attachment.node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n+| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.ebs_csi](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.external_dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -151,7 +152,7 @@ No modules.\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow external DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n-| <a name=\"input_karpenter_controller_cluster_ids\"></a> [karpenter\\_controller\\_cluster\\_ids](#input\\_karpenter\\_controller\\_cluster\\_ids) \"karpenter_controller\"\n List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy | `list(string)` | `[]` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1,6 +1,8 @@\n data \"aws_partition\" \"current\" {}\n+data \"aws_caller_identity\" \"current\" {}\n \n locals {\n+ account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n }\n@@ -442,25 +444,46 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\"*\"]\n }\n \n- dynamic \"statement\" {\n- for_each = toset(var.karpenter_controller_cluster_ids)\n- content {\n- actions = [\n- \"ec2:RunInstances\",\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n+ statement {\n+ actions = [\n+ \"ec2:TerminateInstances\",\n+ \"ec2:DeleteLaunchTemplate\",\n+ ]\n \n- resources = [\"*\"]\n+ resources = [\"*\"]\n \n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n- values = [statement.value]\n- }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n }\n }\n \n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*::image/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ ]\n+ }\n+\n statement {\n actions = [\"ssm:GetParameter\"]\n resources = var.karpenter_controller_ssm_parameter_arns\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -152,10 +152,10 @@ variable \"attach_karpenter_controller_policy\" {\n default = false\n }\n \n-variable \"karpenter_controller_cluster_ids\" {\n- description = \"List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy\"\n- type = list(string)\n- default = []\n+variable \"karpenter_controller_cluster_id\" {\n+ description = \"Cluster ID where the Karpenter controller is provisioned/managing\"\n+ type = string\n+ default = \"*\"\n }\n \n variable \"karpenter_controller_ssm_parameter_arns\" {\n---\n\n\n---\n\nChoice C:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -153,7 +153,7 @@ module \"karpenter_controller_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n oidc_providers = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -124,6 +124,7 @@ No resources | [aws_iam_role_policy_attachment.node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n+| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.ebs_csi](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.external_dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -151,7 +152,7 @@ No modules.\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow external DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n-| <a name=\"input_karpenter_controller_cluster_ids\"></a> [karpenter\\_controller\\_cluster\\_ids](#input\\_karpenter\\_controller\\_cluster\\_ids) | List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy | `list(string)` | `[]` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1,6 +1,8 @@\n data \"aws_partition\" \"current\" {}\n+data \"aws_caller_identity\" \"current\" {}\n \n locals {\n+ account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n }\n@@ -442,25 +444,46 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\"*\"]\n }\n \n- dynamic \"statement\" {\n- for_each = toset(var.karpenter_controller_cluster_ids)\n- content {\n- actions = [\n- \"ec2:RunInstances\",\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n+ statement {\n+ actions = [\n+ \"ec2:TerminateInstances\",\n+ \"ec2:DeleteLaunchTemplate\",\n+ ]\n \n- resources = [\"*\"]\n+ resources = [\"*\"]\n \n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n- values = [statement.value]\n- }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n }\n }\n \n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*::image/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ ]\n+ }\n+\n statement {\n actions = [\"ssm:GetParameter\"]\n resources = var.karpenter_controller_ssm_parameter_arns\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -152,10 +152,10 @@ variable \"attach_karpenter_controller_policy\" {\n default = false\n }\n \n-variable \"karpenter_controller_cluster_ids\" {\n- description = \"List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy\"\n- type = list(string)\n- default = []\n+variable \"karpenter_controller_cluster_id\" {\n+ description = \"Cluster ID where the Karpenter controller is provisioned/managing\"\n+ type = string\n+ default = \"*\"\n }\n \n variable \"karpenter_controller_ssm_parameter_arns\" {\n---\n\n\n---\n\nChoice D:\nexamples/iam-role-for-service-accounts-eks/main.tf\n@@ -153,7 +153,7 @@ module \"karpenter_controller_irsa_role\" {\n role_name = \"karpenter_controller\"\n attach_karpenter_controller_policy = true\n \n- karpenter_controller_cluster_ids = [module.eks.cluster_id]\n+ karpenter_controller_cluster_id = module.eks.cluster_id\n karpenter_controller_node_iam_role_arns = [module.eks.eks_managed_node_groups[\"default\"].iam_role_arn]\n \n oidc_providers = {\n---\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -124,6 +124,7 @@ No modules.\n | [aws_iam_role_policy_attachment.node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n | [aws_iam_role_policy_attachment.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n+| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_iam_policy_document.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.ebs_csi](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.external_dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -151,7 +152,7 @@ No modules.\n | <a name=\"input_ebs_csi_kms_cmk_ids\"></a> [ebs\\_csi\\_kms\\_cmk\\_ids](#input\\_ebs\\_csi\\_kms\\_cmk\\_ids) | KMS CMK IDs to allow EBS CSI to manage encrypted volumes | `list(string)` | `[]` | no |\n | <a name=\"input_external_dns_hosted_zone_arns\"></a> [external\\_dns\\_hosted\\_zone\\_arns](#input\\_external\\_dns\\_hosted\\_zone\\_arns) | Route53 hosted zone ARNs to allow external DNS to manage records | `list(string)` | <pre>[<br> \"arn:aws:route53:::hostedzone/*\"<br>]</pre> | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `true` | no |\n-| <a name=\"input_karpenter_controller_cluster_ids\"></a> [karpenter\\_controller\\_cluster\\_ids](#input\\_karpenter\\_controller\\_cluster\\_ids) | List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy | `list(string)` | `[]` | no |\n+| <a name=\"input_karpenter_controller_cluster_id\"></a> [karpenter\\_controller\\_cluster\\_id](#input\\_karpenter\\_controller\\_cluster\\_id) | Cluster ID where the Karpenter controller is provisioned/managing | `string` | `\"*\"` | no |\n | <a name=\"input_karpenter_controller_node_iam_role_arns\"></a> [karpenter\\_controller\\_node\\_iam\\_role\\_arns](#input\\_karpenter\\_controller\\_node\\_iam\\_role\\_arns) | List of node IAM role ARNs Karpenter can use to launch nodes | `list(string)` | <pre>[<br> \"*\"<br>]</pre> | no |\n | <a name=\"input_karpenter_controller_ssm_parameter_arns\"></a> [karpenter\\_controller\\_ssm\\_parameter\\_arns](#input\\_karpenter\\_controller\\_ssm\\_parameter\\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> \"arn:aws:ssm:*:*:parameter/aws/service/*\"<br>]</pre> | no |\n | <a name=\"input_max_session_duration\"></a> [max\\_session\\_duration](#input\\_max\\_session\\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |\n---\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -1,6 +1,8 @@\n data \"aws_partition\" \"current\" {}\n+data \"aws_caller_identity\" \"current\" {}\n \n locals {\n+ account_id = data.aws_caller_identity.current.account_id\n partition = data.aws_partition.current.partition\n dns_suffix = data.aws_partition.current.dns_suffix\n }\n@@ -442,25 +444,46 @@ data \"aws_iam_policy_document\" \"karpenter_controller\" {\n resources = [\"*\"]\n }\n \n- dynamic \"statement\" {\n- for_each = toset(var.karpenter_controller_cluster_ids)\n- content {\n- actions = [\n- \"ec2:RunInstances\",\n- \"ec2:TerminateInstances\",\n- \"ec2:DeleteLaunchTemplate\",\n- ]\n+ statement {\n+ actions = [\n+ \"ec2:TerminateInstances\",\n+ \"ec2:DeleteLaunchTemplate\",\n+ ]\n \n- resources = [\"*\"]\n+ resources = [\"*\"]\n \n- condition {\n- test = \"StringEquals\"\n- variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n- values = [statement.value]\n- }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n }\n }\n \n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*:${local.account_id}:launch-template/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:security-group/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:subnet/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"ec2:ResourceTag/karpenter.sh/discovery\"\n+ values = [var.karpenter_controller_cluster_id]\n+ }\n+ }\n+\n+ statement {\n+ actions = [\"ec2:RunInstances\"]\n+ resources = [\n+ \"arn:aws:ec2:*::image/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:instance/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:volume/*\",\n+ \"arn:aws:ec2:*:${local.account_id}:network-interface/*\",\n+ ]\n+ }\n+\n statement {\n actions = [\"ssm:GetParameter\"]\n resources = var.karpenter_controller_ssm_parameter_arns\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -152,10 +152,10 @@ variable \"attach_karpenter_controller_policy\" {\n default = false\n }\n \n-variable \"karpenter_controller_cluster_ids\" {\n- description = \"List of cluster IDs to appropriately scope EC2 permissions within the Karpenter Controller policy\"\n- type = list(string)\n- default = []\n+variable \"karpenter_controller_cluster_id\" {\n+ description = \"Cluster ID where the Karpenter controller is provisioned/managing\"\n+ type = string\n+ default = \"*\"\n }\n \n variable \"karpenter_controller_ssm_parameter_arns\" {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis will make the `pgp_key` argument optional in all configurations and add the unencrypted user password to the list of outputs. This will also raise the minimum required `aws` provider version to `4.1.0`\r\n\r\n## Motivation and Context\r\nWhen trying to create an iam user without a `pgp_key` but with an `iam_user_login_profile` the creation would fail.\r\nSince version `4.1.0` of the `aws` provider the `pgp_key` argument of the resource `aws_iam_user_login_profile` is **optional**. Thus the constraint that a `pgp_key` is required when using `create_iam_user_login_profile = true` is not needed anymore.\r\n\r\n👉 [Terraform docs for `aws_iam_user_login_profile` (`4.1.0`)](https://registry.terraform.io/providers/hashicorp/aws/4.1.0/docs/resources/iam_user_login_profile)\r\n\r\n## Breaking Changes\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\n\n---\n\nChoice A:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.1.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n \n ## Modules\n \n@@ -59,7 +59,7 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true` | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -78,6 +78,7 @@ No modules.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_ssh_key_fingerprint\"></a> [iam\\_user\\_ssh\\_key\\_fingerprint](#output\\_iam\\_user\\_ssh\\_key\\_fingerprint) | The MD5 message digest of the SSH public key |\n | <a name=\"output_iam_user_ssh_key_ssh_public_key_id\"></a> [iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id](#output\\_iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id) | The unique identifier for the SSH public key |\n---\nmodules/iam-user/outputs.tf\n@@ -28,6 +28,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = try(aws_iam_user_login_profile.this[0].encrypted_password, \"\")\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = try(aws_iam_access_key.this[0].id, aws_iam_access_key.this_no_pgp[0].id, \"\")\n---\nmodules/iam-user/variables.tf\n@@ -34,7 +34,7 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true`\"\n+ description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 2.50\"\n+ version = \">= 4.1.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.1.0 |\n \n ## Providers\n \n | Name | be |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n \n ## Modules\n \n@@ -59,7 +59,7 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true` | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -78,6 +78,7 @@ No modules.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_ssh_key_fingerprint\"></a> [iam\\_user\\_ssh\\_key\\_fingerprint](#output\\_iam\\_user\\_ssh\\_key\\_fingerprint) | The MD5 message digest of the SSH public key |\n | <a name=\"output_iam_user_ssh_key_ssh_public_key_id\"></a> [iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id](#output\\_iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id) | The unique identifier for the SSH public key |\n---\nmodules/iam-user/outputs.tf\n@@ -28,6 +28,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = try(aws_iam_user_login_profile.this[0].encrypted_password, \"\")\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = try(aws_iam_access_key.this[0].id, aws_iam_access_key.this_no_pgp[0].id, \"\")\n---\nmodules/iam-user/variables.tf\n@@ -34,7 +34,7 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true`\"\n+ description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 2.50\"\n+ version = \">= 4.1.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.1.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n \n ## Modules\n \n@@ -59,7 +59,7 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n @@ <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true` | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -78,6 +78,7 @@ No modules.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_ssh_key_fingerprint\"></a> [iam\\_user\\_ssh\\_key\\_fingerprint](#output\\_iam\\_user\\_ssh\\_key\\_fingerprint) | The MD5 message digest of the SSH public key |\n | <a name=\"output_iam_user_ssh_key_ssh_public_key_id\"></a> [iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id](#output\\_iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id) | The unique identifier for the SSH public key |\n---\nmodules/iam-user/outputs.tf\n@@ -28,6 +28,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = try(aws_iam_user_login_profile.this[0].encrypted_password, \"\")\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = try(aws_iam_access_key.this[0].id, aws_iam_access_key.this_no_pgp[0].id, \"\")\n---\nmodules/iam-user/variables.tf\n@@ -34,7 +34,7 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true`\"\n+ description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 2.50\"\n+ version = \">= 4.1.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-user/README.md\n@@ -24,13 +24,13 @@ This module outputs commands and PGP messages which can be decrypted either usin\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.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.1.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.1.0 |\n \n ## Modules\n \n@@ -59,7 +59,7 @@ No modules.\n | <a name=\"input_password_reset_required\"></a> [password\\_reset\\_required](#input\\_password\\_reset\\_required) | Whether the user should be forced to reset the generated password on first login. | `bool` | `true` | no |\n | <a name=\"input_path\"></a> [path](#input\\_path) | Desired path for the IAM user | `string` | `\"/\"` | no |\n | <a name=\"input_permissions_boundary\"></a> [permissions\\_boundary](#input\\_permissions\\_boundary) | The ARN of the policy that is used to set the permissions boundary for the user. | `string` | `\"\"` | no |\n-| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true` | `string` | `\"\"` | no |\n+| <a name=\"input_pgp_key\"></a> [pgp\\_key](#input\\_pgp\\_key) | Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. | `string` | `\"\"` | no |\n | <a name=\"input_ssh_key_encoding\"></a> [ssh\\_key\\_encoding](#input\\_ssh\\_key\\_encoding) | Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use SSH. To retrieve the public key in PEM format, use PEM | `string` | `\"SSH\"` | no |\n | <a name=\"input_ssh_public_key\"></a> [ssh\\_public\\_key](#input\\_ssh\\_public\\_key) | The SSH public key. The public key must be encoded in ssh-rsa format or PEM format | `string` | `\"\"` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n@@ -78,6 +78,7 @@ No modules.\n | <a name=\"output_iam_user_arn\"></a> [iam\\_user\\_arn](#output\\_iam\\_user\\_arn) | The ARN assigned by AWS for this user |\n | <a name=\"output_iam_user_login_profile_encrypted_password\"></a> [iam\\_user\\_login\\_profile\\_encrypted\\_password](#output\\_iam\\_user\\_login\\_profile\\_encrypted\\_password) | The encrypted password, base64 encoded |\n | <a name=\"output_iam_user_login_profile_key_fingerprint\"></a> [iam\\_user\\_login\\_profile\\_key\\_fingerprint](#output\\_iam\\_user\\_login\\_profile\\_key\\_fingerprint) | The fingerprint of the PGP key used to encrypt the password |\n+| <a name=\"output_iam_user_login_profile_password\"></a> [iam\\_user\\_login\\_profile\\_password](#output\\_iam\\_user\\_login\\_profile\\_password) | The user password |\n | <a name=\"output_iam_user_name\"></a> [iam\\_user\\_name](#output\\_iam\\_user\\_name) | The user's name |\n | <a name=\"output_iam_user_ssh_key_fingerprint\"></a> [iam\\_user\\_ssh\\_key\\_fingerprint](#output\\_iam\\_user\\_ssh\\_key\\_fingerprint) | The MD5 message digest of the SSH public key |\n | <a name=\"output_iam_user_ssh_key_ssh_public_key_id\"></a> [iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id](#output\\_iam\\_user\\_ssh\\_key\\_ssh\\_public\\_key\\_id) | The unique identifier for the SSH public key |\n---\nmodules/iam-user/outputs.tf\n@@ -28,6 +28,12 @@ output \"iam_user_login_profile_encrypted_password\" {\n value = try(aws_iam_user_login_profile.this[0].encrypted_password, \"\")\n }\n \n+output \"iam_user_login_profile_password\" {\n+ description = \"The user password\"\n+ value = try(aws_iam_user_login_profile.this[0].password, \"\")\n+ sensitive = true\n+}\n+\n output \"iam_access_key_id\" {\n description = \"The access key ID\"\n value = try(aws_iam_access_key.this[0].id, aws_iam_access_key.this_no_pgp[0].id, \"\")\n---\nmodules/iam-user/variables.tf\n@@ -34,7 +34,7 @@ variable \"force_destroy\" {\n }\n \n variable \"pgp_key\" {\n- description = \"Either base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key. `pgp_key` is required when `create_iam_user_login_profile` is set to `true`\"\n+ description = \"Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:username`. Used to encrypt password and access key.\"\n type = string\n default = \"\"\n }\n---\nmodules/iam-user/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 2.50\"\n+ version = \">= 4.1.0\"\n }\n }\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nFixed a typo causing plan/apply to fail when `ebs_csi_kms_cmk_ids` is set in the `\"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"` module.\r\n\r\n## Motivation and Context\r\nWithout this change, setting `ebs_csi_kms_cmk_ids` results in the following error (`statement.value` is `1` instead of the list of CMK ARNs):\r\n```\r\n╷\r\n│ Error: Incorrect attribute value type\r\n│ \r\n│ on .terraform/modules/[redacted].aws_ebs_csi_driver_irsa/modules/iam-role-for-service-accounts-eks/policies.tf line 259, in data \"aws_iam_policy_document\" \"ebs_csi\":\r\n│ 259: resources = statement.value\r\n│ \r\n│ Inappropriate value for attribute \"resources\": set of string required.\r\n╵\r\n╷\r\n│ Error: Incorrect attribute value type\r\n│ \r\n│ on .terraform/modules/[redacted].aws_ebs_csi_driver_irsa/modules/iam-role-for-service-accounts-eks/policies.tf line 281, in data \"aws_iam_policy_document\" \"ebs_csi\":\r\n│ 281: resources = statement.value\r\n│ \r\n│ Inappropriate value for attribute \"resources\": set of string required.\r\n```\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\nTested, with and without setting `ebs_csi_kms_cmk_ids`, as well as with 0, 1 and multiple values.\r\n\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -256,7 +256,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n \n condition {\n test = \"Bool\"\n@@ -277,7 +277,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -256,7 +256,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n \n condition {\n test data \"Bool\"\n@@ -277,7 +277,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -256,7 +256,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n \n condition {\n test = \"Bool\"\n@@ -277,7 +277,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -256,7 +256,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:RevokeGrant\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n \n condition {\n test \"Bool\"\n@@ -277,7 +277,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:DescribeKey\",\n ]\n \n- resources = statement.value\n+ resources = var.ebs_csi_kms_cmk_ids\n }\n }\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- Add variable to change IAM condition test operator to suite; defaults to `StringEquals`\r\n- Correct parameter name usage in `README.md` (`service_accounts` -> `namespace_service_accounts`) to be correct\r\n\r\n## Motivation and Context\r\n- Closes #198\r\n- Closes #200\r\n\r\n## Breaking Changes\r\n- No\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-role-for-service-accounts-eks/README.md\n@@ -20,12 +20,12 @@ module \"iam_eks_role\" {\n \n oidc_providers = {\n one = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n- service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n }\n two = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n- service_accounts = [\"default:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n }\n }\n }\n@@ -44,8 +44,8 @@ module \"vpc_cni_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -64,8 +64,8 @@ module \"karpenter_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -138,6 +138,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` `\"StringEquals\"` | no |\n | <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -14,7 +14,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -64,6 +64,12 @@ variable \"max_session_duration\" {\n default = null\n }\n \n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -20,12 +20,12 @@ module \"iam_eks_role\" {\n \n oidc_providers = {\n one = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n- service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n }\n two = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n- service_accounts = [\"default:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n }\n }\n }\n@@ -44,8 +44,8 @@ module \"vpc_cni_irsa_role\" {\n \n oidc_providers = {\n main = {\n- \"karpenter_irsa_role\" provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -64,8 +64,8 @@ module \"karpenter_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -138,6 +138,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -14,7 +14,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -64,6 +64,12 @@ variable \"max_session_duration\" {\n default = null\n }\n \n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -20,12 +20,12 @@ module \"iam_eks_role\" {\n \n oidc_providers = {\n one = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n- service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n }\n two = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n- service_accounts = [\"default:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n }\n }\n }\n@@ -44,8 +44,8 @@ module \"vpc_cni_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -64,8 +64,8 @@ module \"karpenter_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -138,6 +138,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -14,7 +14,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -64,6 +64,12 @@ variable \"max_session_duration\" {\n default = null\n }\n \n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n+\n ################################################################################\n # Policies\n ################################################################################\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/README.md\n@@ -20,12 +20,12 @@ module \"iam_eks_role\" {\n \n oidc_providers = {\n one = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n- service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D\"\n+ namespace_service_accounts = [\"default:my-app-staging\", \"canary:my-app-staging\"]\n }\n two = {\n- provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n- service_accounts = [\"default:my-app-staging\"]\n+ provider_arn = \"arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G\"\n+ namespace_service_accounts = [\"default:my-app-staging\"]\n }\n }\n }\n@@ -44,8 +44,8 @@ module \"vpc_cni_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -64,8 +64,8 @@ module \"karpenter_irsa_role\" {\n \n oidc_providers = {\n main = {\n- provider_arn = module.eks.oidc_provider_arn\n- service_accounts = [\"default:my-app\", \"canary:my-app\"]\n+ provider_arn = module.eks.oidc_provider_arn\n+ namespace_service_accounts = [\"default:my-app\", \"canary:my-app\"]\n }\n }\n }\n@@ -138,6 +138,7 @@ No modules.\n \n | Name | Description | Type | Default | Required |\n |------|-------------|------|---------|:--------:|\n+| <a name=\"input_assume_role_condition_test\"></a> [assume\\_role\\_condition\\_test](#input\\_assume\\_role\\_condition\\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `\"StringEquals\"` | no |\n | <a name=\"input_attach_cluster_autoscaler_policy\"></a> [attach\\_cluster\\_autoscaler\\_policy](#input\\_attach\\_cluster\\_autoscaler\\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_ebs_csi_policy\"></a> [attach\\_ebs\\_csi\\_policy](#input\\_attach\\_ebs\\_csi\\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |\n | <a name=\"input_attach_external_dns_policy\"></a> [attach\\_external\\_dns\\_policy](#input\\_attach\\_external\\_dns\\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |\n---\nmodules/iam-role-for-service-accounts-eks/main.tf\n@@ -14,7 +14,7 @@ data \"aws_iam_policy_document\" \"this\" {\n }\n \n condition {\n- test = \"StringEquals\"\n+ test = var.assume_role_condition_test\n variable = \"${replace(statement.value.provider_arn, \"/^(.*provider/)/\", \"\")}:sub\"\n values = [for sa in statement.value.namespace_service_accounts : \"system:serviceaccount:${sa}\"]\n }\n---\nmodules/iam-role-for-service-accounts-eks/variables.tf\n@@ -64,6 +64,12 @@ variable \"max_session_duration\" {\n default = null\n }\n \n+variable \"assume_role_condition_test\" {\n+ description = \"Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role\"\n+ type = string\n+ default = \"StringEquals\"\n+}\n+\n ################################################################################\n # Policies\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 is the same method as is used in iam-assumable-role-with-oidc. Since the argument to count is a list, not a set, the number of elements doesn't depend on the values, and terraform can decide how many elements are needed before creating the policies.\r\n\r\n## Motivation and Context\r\nThis fixes https://github.com/terraform-aws-modules/terraform-aws-iam/issues/193\r\n\r\nThis issue is a blocker for using this module in automation.\r\n\r\n## Breaking Changes\r\nThis changes the address of the `aws_iam_role_policy_attachment` resource, since it's index by a number instead of a string.\r\nThis will cause the resource to be recreated when applying the module after changes.\r\n\r\nThere are no changes to the outputs of the module, and the created resources should be identical.\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\nThis was also tested in our automated tests, which create a role and a policy to attach to a service account, like so:\r\n\r\n```\r\nresource \"aws_iam_policy\" \"foo\" {\r\n name = \"${var.cluster_name}-foo\"\r\n policy = data.aws_iam_policy_document.foo.json\r\n}\r\n\r\nmodule \"foo_role\" {\r\n source = \"terraform-aws-modules/iam/aws//modules/iam-eks-role\"\r\n version = \"4.13.1\"\r\n\r\n role_description = \"IRSA role for foo\"\r\n role_name_prefix = \"foo-\"\r\n role_policy_arns = [aws_iam_policy.foo.arn]\r\n\r\n cluster_service_accounts = {\r\n (var.cluster_name) = [\"${var.namespace}:${local.service_account_name}\"]\r\n }\r\n}\r\n```\r\n\r\nThe change has no effects on the code that uses the module - except that it works when applying in an empty workspace.\r\n\n\n---\n\nChoice A:\nmodules/iam-eks-role/main.tf\n@@ -73,8 +73,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/main.tf\n@@ -73,8 +73,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/main.tf\n@@ -73,8 +73,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if modules/iam-eks-role/main.tf\n@@ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn = var.role_policy_arns[count.index]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/main.tf\n@@ -73,8 +73,8 @@ resource \"aws_iam_role\" \"this\" {\n }\n \n resource \"aws_iam_role_policy_attachment\" \"custom\" {\n- for_each = toset([for arn in var.role_policy_arns : arn if var.create_role])\n+ count = var.create_role ? length(var.role_policy_arns) : 0\n \n role = aws_iam_role.this[0].name\n- policy_arn = each.key\n+ policy_arn : var.role_policy_arns[count.index]\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- Trigger release for adding `ec2:DescribeInstanceTypes` patched in #192; simple comma \"no-op\" additions were added to ensure change set triggers release workflow\r\n\r\n## Motivation and Context\r\n- The title was malformed in #192 which means that the release process was not executed properly (ignored). This is just a simple no-op process to trigger a release for that change\r\n- Closes #195\r\n\r\n## Breaking Changes\r\n- No\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<!--- 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-role-for-service-accounts-eks/policies.tf\n@@ -143,7 +143,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:CreateAction\"\n values = [\n \"CreateVolume\",\n- \"CreateSnapshot\"\n+ \"CreateSnapshot\",\n ]\n }\n }\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\n \"kms:CreateGrant\",\n \"kms:ListGrants\",\n- \"kms:RevokeGrant\"\n+ \"kms:RevokeGrant\",\n ]\n \n resources = statement.value\n@@ -274,7 +274,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:ReEncrypt*\",\n \"kms:GenerateDataKey*\",\n- \"kms:DescribeKey\"\n+ \"kms:DescribeKey\",\n ]\n \n resources = statement.value\n@@ -323,7 +323,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\"\n+ \"ec2:UnassignPrivateIpAddresses\",\n ]\n resources = [\"*\"]\n }\n@@ -339,7 +339,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\"\n+ \"ec2:DescribeInstanceTypes\",\n ]\n resources = [\"*\"]\n }\n@@ -392,7 +392,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n statement {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:ReceiveMessage\"\n+ \"sqs:ReceiveMessage\",\n ]\n \n resources = var.node_termination_handler_sqs_queue_arns\n@@ -565,7 +565,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n- \"ec2:CreateSecurityGroup\"\n+ \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -143,7 +143,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:CreateAction\"\n values = [\n \"CreateVolume\",\n- \"CreateSnapshot\"\n+ \"CreateSnapshot\",\n ]\n }\n }\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\n \"kms:CreateGrant\",\n \"kms:ListGrants\",\n- \"kms:RevokeGrant\"\n+ \"kms:RevokeGrant\",\n ]\n \n resources = statement.value\n@@ -274,7 +274,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:Decrypt\",\n \"kms:ReEncrypt*\",\n \"kms:GenerateDataKey*\",\n- \"kms:DescribeKey\"\n+ \"kms:DescribeKey\",\n ]\n \n resources = statement.value\n@@ -323,7 +323,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\"\n+ \"ec2:UnassignPrivateIpAddresses\",\n ]\n resources = [\"*\"]\n }\n@@ -339,7 +339,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\"\n+ \"ec2:DescribeInstanceTypes\",\n ]\n resources = [\"*\"]\n }\n@@ -392,7 +392,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n statement {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:ReceiveMessage\"\n+ \"sqs:ReceiveMessage\",\n ]\n \n resources = var.node_termination_handler_sqs_queue_arns\n@@ -565,7 +565,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n- \"ec2:CreateSecurityGroup\"\n+ \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -143,7 +143,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:CreateAction\"\n values = [\n \"CreateVolume\",\n- \"CreateSnapshot\"\n+ \"CreateSnapshot\",\n ]\n }\n }\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\n \"kms:CreateGrant\",\n \"kms:ListGrants\",\n- \"kms:RevokeGrant\"\n+ \"kms:RevokeGrant\",\n ]\n \n resources = statement.value\n@@ -274,7 +274,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:Decrypt\",\n \"kms:ReEncrypt*\",\n \"kms:GenerateDataKey*\",\n- \"kms:DescribeKey\"\n+ \"kms:DescribeKey\",\n ]\n \n resources = statement.value\n@@ -323,7 +323,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstanceTypes\",\n \"ec2:DetachNetworkInterface\",\n \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\"\n+ \"ec2:UnassignPrivateIpAddresses\",\n ]\n resources = [\"*\"]\n }\n@@ -339,7 +339,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\"\n+ \"ec2:DescribeInstanceTypes\",\n ]\n resources = [\"*\"]\n }\n@@ -392,7 +392,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n statement {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:ReceiveMessage\"\n+ \"sqs:ReceiveMessage\",\n ]\n \n resources = var.node_termination_handler_sqs_queue_arns\n@@ -565,7 +565,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n- \"ec2:CreateSecurityGroup\"\n+ \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -143,7 +143,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n variable = \"ec2:CreateAction\"\n values = [\n \"CreateVolume\",\n- \"CreateSnapshot\"\n+ \"CreateSnapshot\",\n ]\n }\n }\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n actions = [\n \"kms:CreateGrant\",\n \"kms:ListGrants\",\n- \"kms:RevokeGrant\"\n+ \"kms:RevokeGrant\",\n ]\n \n resources = statement.value\n@@ -274,7 +274,7 @@ data \"aws_iam_policy_document\" \"ebs_csi\" {\n \"kms:Decrypt\",\n \"kms:ReEncrypt*\",\n \"kms:GenerateDataKey*\",\n- \"kms:DescribeKey\"\n+ \"kms:DescribeKey\",\n ]\n \n resources = statement.value\n@@ -323,7 +323,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstanceTypes\",\n \"CreateSnapshot\"\n+ \"ec2:ModifyNetworkInterfaceAttribute\",\n- \"ec2:UnassignPrivateIpAddresses\"\n+ \"ec2:UnassignPrivateIpAddresses\",\n ]\n resources = [\"*\"]\n }\n@@ -339,7 +339,7 @@ data \"aws_iam_policy_document\" \"vpc_cni\" {\n \"ec2:DescribeInstances\",\n \"ec2:DescribeTags\",\n \"ec2:DescribeNetworkInterfaces\",\n- \"ec2:DescribeInstanceTypes\"\n+ \"ec2:DescribeInstanceTypes\",\n ]\n resources = [\"*\"]\n }\n@@ -392,7 +392,7 @@ data \"aws_iam_policy_document\" \"node_termination_handler\" {\n statement {\n actions = [\n \"sqs:DeleteMessage\",\n- \"sqs:ReceiveMessage\"\n+ \"sqs:ReceiveMessage\",\n ]\n \n resources = var.node_termination_handler_sqs_queue_arns\n@@ -565,7 +565,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n actions = [\n \"ec2:AuthorizeSecurityGroupIngress\",\n \"ec2:RevokeSecurityGroupIngress\",\n- \"ec2:CreateSecurityGroup\"\n+ \"ec2:CreateSecurityGroup\",\n ]\n resources = [\"*\"]\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nCorrects a typo in the variable description for `var.custom_role_trust_policy`.\r\n\r\n## Motivation and Context\r\nNoticed while reviewing docs.\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\nN/A\r\n\n\n---\n\nChoice A:\nmodules/iam-assumable-role/README.md\n@@ -46,7 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -77,7 +77,7 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custorm role trust policy\"\n+ description = \"A custom role trust policy\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/README.md\n@@ -46,7 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether | create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -77,7 +77,7 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custorm role trust policy\"\n+ description = \"A custom role trust policy\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/README.md\n@@ -46,7 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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` an no |\n | <a name=\"input_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -77,7 +77,7 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custorm role trust policy\"\n+ description = \"A custom role trust policy\"\n type = string\n default = \"\"\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/README.md\n@@ -46,7 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n-| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custom role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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 | <a | `3600` | no |\n | <a name=\"input_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/variables.tf\n@@ -77,7 +77,7 @@ variable \"custom_role_policy_arns\" {\n }\n \n variable \"custom_role_trust_policy\" {\n- description = \"A custorm role trust policy\"\n+ description = \"A custom role trust policy\"\n type = 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\ncluster-autoscaler >=[v1.23.0](https://github.com/kubernetes/autoscaler/releases/tag/cluster-autoscaler-1.23.0) requires an extra IAM permission - ec2:DescribeInstanceTypes\r\n\r\n## Motivation and Context\r\nThe merging of https://github.com/kubernetes/autoscaler/pull/4468 means that the default configuration of the CA will now require an extra IAM permission - `ec2:DescribeInstanceTypes`\r\n\r\n## Breaking Changes\r\nNo breaking change.\n\n---\n\nChoice A:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -20,6 +20,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"autoscaling:DescribeLaunchConfigurations\",\n \"autoscaling:DescribeTags\",\n \"ec2:DescribeLaunchTemplateVersions\",\n+ \"ec2:DescribeInstanceTypes\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -20,6 +20,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"autoscaling:DescribeLaunchConfigurations\",\n \"autoscaling:DescribeTags\",\n \"ec2:DescribeLaunchTemplateVersions\",\n+ \"ec2:DescribeInstanceTypes\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -20,6 +20,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"autoscaling:DescribeLaunchConfigurations\",\n \"autoscaling:DescribeTags\",\n \"ec2:DescribeLaunchTemplateVersions\",\n+ \"ec2:DescribeInstanceTypes\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -20,6 +20,7 @@ data \"aws_iam_policy_document\" \"cluster_autoscaler\" {\n \"autoscaling:DescribeLaunchConfigurations\",\n \"autoscaling:DescribeTags\",\n \"ec2:DescribeLaunchTemplateVersions\",\n+ \"ec2:DescribeInstanceTypes\",\n ]\n \n resources = [\"*\"]\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- Correct permission on AWS load balancer controller; looks like it was a copy past error https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/694a0b14184e388806f9f34be0dd9075aa8fb0a7/docs/install/iam_policy.json#L216\r\n\r\n## Motivation and Context\r\n- Closes #190 \r\n\r\n## Breaking Changes\r\n- No\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-role-for-service-accounts-eks/policies.tf\n@@ -718,7 +718,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n ]\n- resources = [\"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+ resources = [\"*\"]\n }\n }\n \n---\n\n\n---\n\nChoice B:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -718,7 +718,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n data ]\n- resources = [\"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+ resources = [\"*\"]\n }\n }\n \n---\n\n\n---\n\nChoice C:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -718,7 +718,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n ]\n- resources \"load_balancer_controller\" [\"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+ resources = [\"*\"]\n }\n }\n \n---\n\n\n---\n\nChoice D:\nmodules/iam-role-for-service-accounts-eks/policies.tf\n@@ -718,7 +718,7 @@ data \"aws_iam_policy_document\" \"load_balancer_controller\" {\n \"elasticloadbalancing:RemoveListenerCertificates\",\n \"elasticloadbalancing:ModifyRule\",\n ]\n- resources = [\"arn:${local.partition}:elasticloadbalancing:*:*:targetgroup/*/*\"]\n+ resources = [\"*\"]\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\nAdded Cost Explorer to default console services defaults.\r\n \r\n## Motivation and Context\r\nAWS updated home screen and now it shows data from cost explorer thus generating Cloud Trail accessed denied events if policy does not container Cost Explorer\r\n\r\n## Breaking Changes\r\nN/A\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\nPlus local tests\n\n---\n\nChoice A:\nmodules/iam-read-only-policy/README.md\n@@ -46,7 +46,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n-| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\"<br>]</pre> | no |\n+| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -60,5 +60,5 @@ variable \"allow_web_console_services\" {\n variable \"web_console_services\" {\n description = \"List of web console services to allow\"\n type = list(string)\n- default = [\"resource-groups\", \"tag\", \"health\"]\n+ default = [\"resource-groups\", \"tag\", \"health\", \"ce\"]\n }\n---\n\n\n---\n\nChoice B:\nmodules/iam-read-only-policy/README.md\n@@ -46,7 +46,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n-| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\"<br>]</pre> | no |\n+| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> [\"resource-groups\", \"ce\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -60,5 +60,5 @@ variable \"allow_web_console_services\" {\n variable \"web_console_services\" {\n description = \"List of web console services to allow\"\n type = list(string)\n- default = [\"resource-groups\", \"tag\", \"health\"]\n+ default = [\"resource-groups\", \"tag\", \"health\", \"ce\"]\n }\n---\n\n\n---\n\nChoice C:\nmodules/iam-read-only-policy/README.md\n@@ -46,7 +46,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n-| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\"<br>]</pre> | no |\n+| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -60,5 +60,5 @@ variable \"allow_web_console_services\" {\n variable \"web_console_services\" {\n description = \"List of web console services to allow\"\n type `\"/\"` = list(string)\n- default = [\"resource-groups\", \"tag\", \"health\"]\n+ default = [\"resource-groups\", \"tag\", \"health\", \"ce\"]\n }\n---\n\n\n---\n\nChoice D:\nmodules/iam-read-only-policy/README.md\n@@ -46,7 +46,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_tags\"></a> [tags](#input\\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |\n-| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\"<br>]</pre> \"ce\"<br>]</pre> no |\n+| <a name=\"input_web_console_services\"></a> [web\\_console\\_services](#input\\_web\\_console\\_services) | List of web console services to allow | `list(string)` | <pre>[<br> \"resource-groups\",<br> \"tag\",<br> \"health\",<br> \"ce\"<br>]</pre> | no |\n \n ## Outputs\n \n---\nmodules/iam-read-only-policy/variables.tf\n@@ -60,5 +60,5 @@ variable \"allow_web_console_services\" {\n variable \"web_console_services\" {\n description = \"List of web console services to allow\"\n type = list(string)\n- default = [\"resource-groups\", \"tag\", \"health\"]\n+ default = [\"resource-groups\", \"tag\", \"health\", \"ce\"]\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\nAdded a variable to provide a list of IAM actions that will by denied. Default is set to s3:GetObject. See motivation and context for explanation why\r\n \r\n## Motivation and Context\r\nBased on the feedback from security community I want to add default deny actions since people can accidentally grant s3:GetObject and of objects are not encrypted with KMS CMK then S3 will be able to read object and return it to requester which might be undesired/can cause security issue\r\n\r\n## Breaking Changes\r\nN/A\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\nPlus local tests\n\n---\n\nChoice A:\nexamples/iam-read-only-policy/main.tf\n@@ -32,6 +32,7 @@ module \"read_only_iam_policy\" {\n description = \"My read only example policy\"\n \n allowed_services = local.allowed_services\n+ denied_actions = [\"s3:GetObject\", \"dynamodb:GetRecords\"]\n \n tags = {\n PolicyDescription = \"My read only example policy\"\n---\nmodules/iam-read-only-policy/README.md\n@@ -29,6 +29,7 @@ No modules.\n | [aws_iam_policy_document.allowed_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.console_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.deny](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.logs_query](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.sts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n@@ -42,6 +43,7 @@ No modules.\n | <a name=\"input_allow_web_console_services\"></a> [allow\\_web\\_console\\_services](#input\\_allow\\_web\\_console\\_services) | Allows List/Get/Describe/View actions for services used when browsing AWS console (e.g. resource-groups, tag, health services) | `bool` | `true` | no |\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_denied_actions\"></a> [denied\\_actions](#input\\_denied\\_actions) | List of actions to deny by default | `list(string)` | <pre>[<br> \"s3:GetObject\"<br>]</pre> | no |\n | <a name=\"input_description\"></a> [description](#input\\_description) | The description of the policy of `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-read-only-policy/main.tf\n@@ -79,12 +79,24 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"deny\" {\n+ count = length(var.denied_actions) > 0 ? 1 : 0\n+\n+ statement {\n+ effect = \"Deny\"\n+ sid = \"Deny\"\n+ actions = var.denied_actions\n+ resources = [\"*\"]\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n data.aws_iam_policy_document.console_services.*.json,\n data.aws_iam_policy_document.sts.*.json,\n data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.deny.*.json,\n [var.additional_policy_json]\n )\n }\n---\nmodules/iam-read-only-policy/variables.tf\n@@ -27,6 +27,12 @@ variable \"allowed_services\" {\n type = list(string)\n }\n \n+variable \"denied_actions\" {\n+ description = \"List of actions to deny by default\"\n+ type = list(string)\n+ default = [\"s3:GetObject\"]\n+}\n+\n variable \"additional_policy_json\" {\n description = \"JSON policy document if you want to add custom actions\"\n type = string\n---\n\n\n---\n\nChoice B:\nexamples/iam-read-only-policy/main.tf\n@@ -32,6 +32,7 @@ module \"read_only_iam_policy\" {\n description = \"My read only example policy\"\n \n allowed_services = local.allowed_services\n+ denied_actions = [\"s3:GetObject\", \"dynamodb:GetRecords\"]\n \n tags = {\n PolicyDescription = \"My read only example policy\"\n---\nmodules/iam-read-only-policy/README.md\n@@ -29,6 +29,7 @@ No modules.\n | [aws_iam_policy_document.allowed_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.console_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.deny](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.logs_query](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.sts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n@@ -42,6 +43,7 @@ No modules.\n | <a name=\"input_allow_web_console_services\"></a> [allow\\_web\\_console\\_services](#input\\_allow\\_web\\_console\\_services) | Allows List/Get/Describe/View actions for services when browsing AWS console (e.g. resource-groups, tag, health services) | `bool` | `true` | no |\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_denied_actions\"></a> [denied\\_actions](#input\\_denied\\_actions) | List of actions to deny by default | `list(string)` | <pre>[<br> \"s3:GetObject\"<br>]</pre> | 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-read-only-policy/main.tf\n@@ -79,12 +79,24 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"deny\" {\n+ count = length(var.denied_actions) > 0 ? 1 : 0\n+\n+ statement {\n+ effect = \"Deny\"\n+ sid = \"Deny\"\n+ actions = var.denied_actions\n+ resources = [\"*\"]\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n data.aws_iam_policy_document.console_services.*.json,\n data.aws_iam_policy_document.sts.*.json,\n data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.deny.*.json,\n [var.additional_policy_json]\n )\n }\n---\nmodules/iam-read-only-policy/variables.tf\n@@ -27,6 +27,12 @@ variable \"allowed_services\" {\n type = list(string)\n }\n \n+variable \"denied_actions\" {\n+ description = \"List of actions to deny by default\"\n+ type = list(string)\n+ default = [\"s3:GetObject\"]\n+}\n+\n variable \"additional_policy_json\" {\n description = \"JSON policy document if you want to add custom actions\"\n type = string\n---\n\n\n---\n\nChoice C:\nexamples/iam-read-only-policy/main.tf\n@@ -32,6 +32,7 @@ module \"read_only_iam_policy\" {\n description = \"My read only example policy\"\n \n allowed_services = local.allowed_services\n+ denied_actions = [\"s3:GetObject\", \"dynamodb:GetRecords\"]\n \n tags = {\n PolicyDescription = \"My read only example policy\"\n---\nmodules/iam-read-only-policy/README.md\n@@ -29,6 +29,7 @@ No modules.\n | [aws_iam_policy_document.allowed_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.console_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.deny](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.logs_query](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.sts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n@@ -42,6 +43,7 @@ No modules.\n | <a name=\"input_allow_web_console_services\"></a> [allow\\_web\\_console\\_services](#input\\_allow\\_web\\_console\\_services) | Allows List/Get/Describe/View actions for services used when browsing AWS console (e.g. resource-groups, tag, health services) | `bool` | `true` | no |\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_denied_actions\"></a> [denied\\_actions](#input\\_denied\\_actions) | List of actions to deny by default | `list(string)` | <pre>[<br> \"s3:GetObject\"<br>]</pre> | 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 IAM | `string` | `\"/\"` | no |\n---\nmodules/iam-read-only-policy/main.tf\n@@ -79,12 +79,24 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"deny\" {\n+ count = length(var.denied_actions) > 0 ? 1 : 0\n+\n+ statement {\n+ effect = \"Deny\"\n+ sid = \"Deny\"\n+ actions = var.denied_actions\n+ resources = [\"*\"]\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n data.aws_iam_policy_document.console_services.*.json,\n data.aws_iam_policy_document.sts.*.json,\n data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.deny.*.json,\n [var.additional_policy_json]\n )\n }\n---\nmodules/iam-read-only-policy/variables.tf\n@@ -27,6 +27,12 @@ variable \"allowed_services\" {\n type = list(string)\n }\n \n+variable \"denied_actions\" {\n+ description = \"List of actions to deny by default\"\n+ type = list(string)\n+ default = [\"s3:GetObject\"]\n+}\n+\n variable \"additional_policy_json\" {\n description = \"JSON policy document if you want to add custom actions\"\n type = string\n---\n\n\n---\n\nChoice D:\nexamples/iam-read-only-policy/main.tf\n@@ -32,6 +32,7 @@ module \"read_only_iam_policy\" {\n description = \"My read only example policy\"\n \n allowed_services = local.allowed_services\n+ denied_actions = [\"s3:GetObject\", \"dynamodb:GetRecords\"]\n \n tags = {\n PolicyDescription = \"My read only example policy\"\n---\nmodules/iam-read-only-policy/README.md\n@@ -29,6 +29,7 @@ No modules.\n | [aws_iam_policy_document.allowed_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.console_services](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.deny](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.logs_query](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.sts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n@@ -42,6 +43,7 @@ No modules.\n | <a name=\"input_allow_web_console_services\"></a> [allow\\_web\\_console\\_services](#input\\_allow\\_web\\_console\\_services) | Allows List/Get/Describe/View actions for services used when browsing AWS console (e.g. resource-groups, tag, health services) | `bool` | `true` | no |\n | <a name=\"input_allowed_services\"></a> [allowed\\_services](#input\\_allowed\\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |\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_denied_actions\"></a> [denied\\_actions](#input\\_denied\\_actions) | List of actions to deny by default | `list(string)` | <pre>[<br> \"s3:GetObject\"<br>]</pre> | 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-read-only-policy/main.tf\n@@ -79,12 +79,24 @@ data \"aws_iam_policy_document\" \"logs_query\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"deny\" {\n+ count = length(var.denied_actions) > 0 ? 1 : 0\n+\n+ statement {\n+ effect = \"Deny\"\n+ sid = \"Deny\"\n+ actions = var.denied_actions\n+ resources = [\"*\"]\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = concat(\n [data.aws_iam_policy_document.allowed_services.json],\n data.aws_iam_policy_document.console_services.*.json,\n data.aws_iam_policy_document.sts.*.json,\n data.aws_iam_policy_document.logs_query.*.json,\n+ data.aws_iam_policy_document.deny.*.json,\n [var.additional_policy_json]\n )\n }\n---\nmodules/iam-read-only-policy/variables.tf\n@@ -27,6 +27,12 @@ variable \"allowed_services\" {\n type = list(string)\n }\n \n+variable \"denied_actions\" {\n+ description = \"List of actions to deny by default\"\n+ type = list(string)\n+ default = [\"s3:GetObject\"]\n+}\n+\n variable \"additional_policy_json\" {\n description = \"JSON policy document if you want to add custom actions\"\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:\nFixes #181 \n\n---\n\nChoice A:\nexamples/iam-eks-role/README.md\n@@ -21,20 +21,29 @@ Run `terraform destroy` when you don't need these resources.\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_random\"></a> [random](#requirement\\_random) | >= 2 |\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n+| [aws_subnet_ids.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source |\n+| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |\n \n ## Inputs\n \"aws_subnet_ids\" -7,11 +7,7 @@ module \"iam_eks_role\" {\n role_name = \"my-app\"\n \n cluster_service_accounts = {\n- \"cluster1\" = [\"default:my-app\"]\n- \"cluster2\" = [\n- \"default:my-app\",\n- \"canary:my-app\",\n- ]\n+ (random_pet.this.id) = [\"default:my-app\", \"canary:my-app\"]\n }\n \n provider_url_sa_pairs = {\n@@ -30,3 +26,33 @@ module \"iam_eks_role\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n ]\n }\n+\n+##################\n+# Extra resources\n+##################\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"eks\" {\n+ source = \"terraform-aws-modules/eks/aws\"\n+ version = \"~> 18.0\"\n+\n+ cluster_name = random_pet.this.id\n+ cluster_version = \"1.21\"\n+\n+ vpc_id = data.aws_vpc.default.id\n+ subnet_ids = data.aws_subnet_ids.all.ids\n+}\n+\n+##################################################################\n+# Data sources to get VPC, subnet, security group and AMI details\n+##################################################################\n+data \"aws_vpc\" \"default\" {\n+ default = true\n+}\n+\n+data \"aws_subnet_ids\" \"all\" {\n+ vpc_id = data.aws_vpc.default.id\n+}\n---\nexamples/iam-eks-role/versions.tf\n@@ -2,6 +2,7 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 2.23\"\n+ random = \">= 2\"\n }\n }\n---\n\n\n---\n\nChoice B:\nexamples/iam-eks-role/README.md\n@@ -21,20 ## @@ Run `terraform destroy` when you don't need these resources.\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_random\"></a> [random](#requirement\\_random) | >= 2 |\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n+| [aws_subnet_ids.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source |\n+| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |\n \n ## Inputs\n \n---\nexamples/iam-eks-role/main.tf\n@@ -7,11 +7,7 @@ module \"iam_eks_role\" {\n role_name = \"my-app\"\n \n cluster_service_accounts = {\n- \"cluster1\" = [\"default:my-app\"]\n- \"cluster2\" = [\n- \"default:my-app\",\n- \"canary:my-app\",\n- ]\n+ (random_pet.this.id) = [\"default:my-app\", \"canary:my-app\"]\n }\n \n provider_url_sa_pairs = {\n@@ -30,3 +26,33 @@ module \"iam_eks_role\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n ]\n }\n+\n+##################\n+# Extra resources\n+##################\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"eks\" {\n+ source = \"terraform-aws-modules/eks/aws\"\n+ version = \"~> 18.0\"\n+\n+ cluster_name = random_pet.this.id\n+ cluster_version = \"1.21\"\n+\n+ vpc_id = data.aws_vpc.default.id\n+ subnet_ids = data.aws_subnet_ids.all.ids\n+}\n+\n+##################################################################\n+# Data sources to get VPC, subnet, security group and AMI details\n+##################################################################\n+data \"aws_vpc\" \"default\" {\n+ default = true\n+}\n+\n+data \"aws_subnet_ids\" \"all\" {\n+ vpc_id = data.aws_vpc.default.id\n+}\n---\nexamples/iam-eks-role/versions.tf\n@@ -2,6 +2,7 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 2.23\"\n+ random = \">= 2\"\n }\n }\n---\n\n\n---\n\nChoice C:\nexamples/iam-eks-role/README.md\n@@ -21,20 +21,29 @@ Run `terraform destroy` when you don't need these resources.\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_random\"></a> [random](#requirement\\_random) | >= 2 |\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n+| [aws_subnet_ids.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source |\n+| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |\n \n ## Inputs\n \n---\nexamples/iam-eks-role/main.tf\n@@ -7,11 +7,7 @@ module \"iam_eks_role\" {\n role_name = \"my-app\"\n \n cluster_service_accounts = {\n- \"cluster1\" = [\"default:my-app\"]\n- \"cluster2\" = [\n- \"default:my-app\",\n- \"canary:my-app\",\n- ]\n+ (random_pet.this.id) = [\"default:my-app\", \"canary:my-app\"]\n }\n \n provider_url_sa_pairs = {\n@@ -30,3 +26,33 @@ module \"iam_eks_role\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n ]\n }\n+\n+##################\n+# Extra resources\n+##################\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"eks\" {\n+ source = \"terraform-aws-modules/eks/aws\"\n+ version = \"~> 18.0\"\n+\n+ cluster_name = random_pet.this.id\n+ cluster_version = \"1.21\"\n+\n+ vpc_id = data.aws_vpc.default.id\n+ subnet_ids = data.aws_subnet_ids.all.ids\n+}\n+\n+##################################################################\n+# Data sources to get VPC, subnet, security group and AMI details\n+##################################################################\n+data \"aws_vpc\" \"default\" {\n+ default = true\n+}\n+\n+data \"aws_subnet_ids\" \"all\" {\n+ vpc_id = data.aws_vpc.default.id\n+}\n---\nexamples/iam-eks-role/versions.tf\n@@ -2,6 +2,7 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 2.23\"\n+ random = \">= 2\"\n }\n }\n---\n\n\n---\n\nChoice D:\nexamples/iam-eks-role/README.md\n@@ -21,20 +21,29 @@ Run `terraform destroy` when you don't need these resources.\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_random\"></a> [random](#requirement\\_random) | >= 2 |\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n+| <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n+| <a name=\"module_eks\"></a> [eks](#module\\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |\n | <a name=\"module_iam_eks_role\"></a> [iam\\_eks\\_role](#module\\_iam\\_eks\\_role) | ../../modules/iam-eks-role | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n+| [aws_subnet_ids.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source |\n+| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |\n \n ## Inputs\n \n---\nexamples/iam-eks-role/main.tf\n@@ -7,11 +7,7 @@ module \"iam_eks_role\" {\n role_name = \"my-app\"\n \n cluster_service_accounts = {\n- \"default:my-app\",\n- \"cluster1\" = [\"default:my-app\"]\n- \"cluster2\" = [\n- \"default:my-app\",\n- \"canary:my-app\",\n- ]\n+ (random_pet.this.id) = [\"default:my-app\", \"canary:my-app\"]\n }\n \n provider_url_sa_pairs = {\n@@ -30,3 +26,33 @@ module \"iam_eks_role\" {\n \"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy\"\n ]\n }\n+\n+##################\n+# Extra resources\n+##################\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"eks\" {\n+ source = \"terraform-aws-modules/eks/aws\"\n+ version = \"~> 18.0\"\n+\n+ cluster_name = random_pet.this.id\n+ cluster_version = \"1.21\"\n+\n+ vpc_id = data.aws_vpc.default.id\n+ subnet_ids = data.aws_subnet_ids.all.ids\n+}\n+\n+##################################################################\n+# Data sources to get VPC, subnet, security group and AMI details\n+##################################################################\n+data \"aws_vpc\" \"default\" {\n+ default = true\n+}\n+\n+data \"aws_subnet_ids\" \"all\" {\n+ vpc_id = data.aws_vpc.default.id\n+}\n---\nexamples/iam-eks-role/versions.tf\n@@ -2,6 +2,7 @@ terraform {\n required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 2.23\"\n+ aws = \">= 2.23\"\n+ random = \">= 2\"\n }\n }\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n\r\nJust fix a couple small errors in the doc\r\n\r\n## Motivation and Context\r\n\r\n💅\r\n\r\n\n\n---\n\nChoice A:\nmodules/iam-eks-role/README.md\n@@ -23,6 +23,7 @@ module \"iam_eks_role\" {\n \"<namespace>:<another ServiceAccount name>\"\n ]\n }\n+}\n ```\n \n For example, to create an IAM role named `my-app` that can be assumed from the `ServiceAccount` named `my-app-staging` in the namespace `default` and `canary` in EKS cluster named `cluster-main-1`; and also the `ServiceAccount` name `my-app-staging` in the namespace `default` in EKS cluster named `cluster-backup-1`, the configuration would be:\n@@ -36,11 +37,12 @@ module \"iam_eks_role\" {\n \"cluster-main-1\" = [\n \"default:my-app-staging\",\n [\n \"canary:my-app-staging\"\n- ]\n+ ],\n \"cluster-backup-1\" = [\n \"default:my-app-staging\",\n ]\n }\n+}\n ```\n \n Note: the EKS clusters must in the current AWS region and account as they use the default AWS provider.\n---\n\n\n---\n\nChoice B:\nmodules/iam-eks-role/README.md\n@@ -23,6 +23,7 @@ module \"iam_eks_role\" {\n \"<namespace>:<another ServiceAccount name>\"\n `my-app-staging` ]\n }\n+}\n ```\n \n For example, to create an IAM role named `my-app` that can be assumed from the `ServiceAccount` named `my-app-staging` in the namespace `default` and `canary` in EKS cluster named `cluster-main-1`; and also the `ServiceAccount` name `my-app-staging` in the namespace `default` in EKS cluster named `cluster-backup-1`, the configuration would be:\n@@ -36,11 +37,12 @@ module \"iam_eks_role\" {\n \"cluster-main-1\" = [\n \"default:my-app-staging\",\n \"canary:my-app-staging\"\n- ]\n+ ],\n \"cluster-backup-1\" = [\n \"default:my-app-staging\",\n ]\n }\n+}\n ```\n \n Note: the EKS clusters must in the current AWS region and account as they use the default AWS provider.\n---\n\n\n---\n\nChoice C:\nmodules/iam-eks-role/README.md\n@@ -23,6 +23,7 @@ module \"iam_eks_role\" {\n \"<namespace>:<another ServiceAccount name>\"\n ]\n }\n+}\n ```\n \n For example, to create an IAM role named `my-app` that can be assumed from the `ServiceAccount` named `my-app-staging` in the namespace `default` and `canary` in EKS cluster named `cluster-main-1`; and also the `ServiceAccount` name `my-app-staging` in the namespace `default` in EKS cluster named `cluster-backup-1`, the configuration would be:\n@@ -36,11 +37,12 @@ module \"iam_eks_role\" {\n \"cluster-main-1\" = [\n \"default:my-app-staging\",\n \"canary:my-app-staging\"\n- ]\n+ ],\n \"cluster-backup-1\" = [\n \"default:my-app-staging\",\n ]\n }\n+}\n ```\n \n Note: the EKS clusters must in the current AWS region and account as they use default AWS provider.\n---\n\n\n---\n\nChoice D:\nmodules/iam-eks-role/README.md\n@@ -23,6 +23,7 @@ module \"iam_eks_role\" {\n \"<namespace>:<another ServiceAccount name>\"\n ]\n }\n+}\n ```\n \n For example, to create an IAM role named `my-app` that can be assumed from the `ServiceAccount` named `my-app-staging` in the namespace `default` and `canary` in EKS cluster named `cluster-main-1`; and also the `ServiceAccount` name `my-app-staging` in the namespace `default` in EKS cluster named `cluster-backup-1`, the configuration would be:\n@@ -36,11 +37,12 @@ module \"iam_eks_role\" {\n \"cluster-main-1\" = [\n \"default:my-app-staging\",\n \"canary:my-app-staging\"\n- ]\n+ ],\n \"cluster-backup-1\" = [\n \"default:my-app-staging\",\n ]\n }\n+}\n ```\n \n Note: the EKS clusters must in the current AWS region and account as they use the default AWS provider.\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\nThis change allows to add and additional trusted role and/or service that is allowed to assume the assumable role with OIDC.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nThis module is often used in combination with IRSA. It is sometimes useful to be able to define not only a `sts:AssumeRoleWithWebIdentity`, but also a `sts:AssumeRole`. I have a IAM role per application which is assumed by the Service Account used by my pods (IRSA), but I also need another role to be allowed to use `sts:AssumeRole`, i.e. the role used by External Secrets (https://github.com/external-secrets/kubernetes-external-secrets#aws-ssm-parameter-store).\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have 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@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -60,6 +60,26 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) + +99,15 != 0 ? [true] : []\n+\n+ content {\n+ effect = \"Allow\"\n+\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -76,7 +76,6 @@ variable \"number_of_role_policy_arns\" {\n default = null\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@@ -100,3 +99,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -60,6 +60,26 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) + length(var.trusted_role_services) != 0 ? [true] : []\n+\n+ content {\n+ effect = \"Allow\"\n+\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -76,7 +76,6 @@ variable \"number_of_role_policy_arns\" {\n default = null\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@@ -100,3 +99,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -60,6 +60,26 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) + length(var.trusted_role_services) != 0 ? [true] : []\n+\n+ content {\n+ effect = \"Allow\"\n+\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -76,7 +76,6 @@ variable \"number_of_role_policy_arns\" {\n default = null\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@@ -100,3 +99,15 @@ variable \"force_detach_policies\" {\n type = = bool\n default = false\n }\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role-with-oidc/README.md\n@@ -55,6 +55,8 @@ No modules.\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n | <a name=\"input_role_policy_arns\"></a> [role\\_policy\\_arns](#input\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n+| <a name=\"input_trusted_role_arns\"></a> [trusted\\_role\\_arns](#input\\_trusted\\_role\\_arns) | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |\n+| <a name=\"input_trusted_role_services\"></a> [trusted\\_role\\_services](#input\\_trusted\\_role\\_services) | AWS Services that can assume these roles | `list(string)` | `[]` | no |\n \n ## Outputs\n \n---\nmodules/iam-assumable-role-with-oidc/main.tf\n@@ -60,6 +60,26 @@ data \"aws_iam_policy_document\" \"assume_role_with_oidc\" {\n }\n }\n }\n+\n+ dynamic \"statement\" {\n+ for_each = length(var.trusted_role_arns) + length(var.trusted_role_services) != 0 ? [true] : []\n+\n+ content {\n+ effect = \"Allow\"\n+\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ }\n+ }\n }\n \n resource \"aws_iam_role\" \"this\" {\n---\nmodules/iam-assumable-role-with-oidc/variables.tf\n@@ -76,7 +76,6 @@ variable \"number_of_role_policy_arns\" {\n default = null\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@@ -100,3 +99,15 @@ variable \"force_detach_policies\" {\n type = bool\n default = false\n }\n+\n+variable \"trusted_role_arns\" {\n+ description = \"ARNs of AWS entities who can assume these roles\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"trusted_role_services\" {\n+ description = \"AWS Services that can assume these roles\"\n+ type = list(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\nThis change adds an option to set a custom trust policy.\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\nI need to create an assumable role that can be assumed from all member accounts of the organization except for sandbox accounts.\r\nThis can be achieved via conditions and a deny policy for the sandbox.\r\nAs there is no possibility to cover all options of the JSON policy, the best would be for such rare situations to allow a custom trust policy.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have 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:\nexamples/iam-assumable-role/README.md\n@@ -26,20 +26,25 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_custom\"></a> [iam\\_assumable\\_role\\_custom](#module\\_iam\\_assumable\\_role\\_custom) | ../../modules/iam-assumable-role | n/a |\n+| <a name=\"module_iam_assumable_role_custom_trust_policy\"></a> [iam\\_assumable\\_role\\_custom\\_trust\\_policy](#module\\_iam\\_assumable\\_role\\_custom\\_trust\\_policy) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_sts\"></a> [iam\\_assumable\\_role\\_sts](#module\\_iam\\_assumable\\_role\\_sts) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy_document.custom_trust_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n---\nexamples/iam-assumable-role/main.tf\n@@ -91,6 +91,54 @@ module \"iam_assumable_role_sts\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+#########################################\n+# IAM assumable role with custom trust policy\n+#########################################\n+module \"iam_assumable_role_custom_trust_policy\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ create_role = true\n+\n+ role_name = \"iam_assumable_role_custom_trust_policy\"\n+\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+}\n+\n+data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [\"some-ext-id\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:PrincipalOrgID\"\n+ values = [\"o-someorgid\"]\n+ }\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"*\"]\n+ }\n+ }\n+\n+ statement {\n+ effect = \"Deny\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:aws:iam::111111111111:root\"]\n+ }\n+ }\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -46,6 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,8 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+\n statement {\n effect = \"Allow\"\n \n@@ -30,6 +32,8 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+\n statement {\n effect = \"Allow\"\n \n@@ -79,7 +83,12 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = var.role_requires_mfa ? data.aws_iam_policy_document.assume_role_with_mfa.json : data.aws_iam_policy_document.assume_role.json\n+ assume_role_policy = coalesce(\n+ var.custom_role_trust_policy,\n+ try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n+ data.aws_iam_policy_document.assume_role[0].json\n+ )\n+ )\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_trust_policy\" {\n+ description = \"A custorm role trust policy\"\n+ type = string\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---\n\n\n---\n\nChoice B:\nexamples/iam-assumable-role/README.md\n@@ -26,20 +26,25 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_custom\"></a> [iam\\_assumable\\_role\\_custom](#module\\_iam\\_assumable\\_role\\_custom) | ../../modules/iam-assumable-role | n/a |\n+| <a name=\"module_iam_assumable_role_custom_trust_policy\"></a> [iam\\_assumable\\_role\\_custom\\_trust\\_policy](#module\\_iam\\_assumable\\_role\\_custom\\_trust\\_policy) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_sts\"></a> [iam\\_assumable\\_role\\_sts](#module\\_iam\\_assumable\\_role\\_sts) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy_document.custom_trust_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n---\nexamples/iam-assumable-role/main.tf\n@@ -91,6 +91,54 @@ module \"iam_assumable_role_sts\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+#########################################\n+# IAM assumable role with custom trust policy\n+#########################################\n+module \"iam_assumable_role_custom_trust_policy\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ create_role = true\n+\n+ role_name = \"iam_assumable_role_custom_trust_policy\"\n+\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+}\n+\n+data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [\"some-ext-id\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:PrincipalOrgID\"\n+ values = [\"o-someorgid\"]\n+ }\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"*\"]\n+ }\n+ }\n+\n+ statement {\n+ effect = \"Deny\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:aws:iam::111111111111:root\"]\n+ }\n+ }\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -46,6 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,8 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+\n statement {\n effect = \"Allow\"\n \n@@ -30,6 +32,8 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+\n statement {\n effect = \"Allow\"\n \n@@ -79,7 +83,12 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = var.role_requires_mfa ? data.aws_iam_policy_document.assume_role_with_mfa.json : data.aws_iam_policy_document.assume_role.json\n+ assume_role_policy = coalesce(\n+ var.custom_role_trust_policy,\n+ try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n+ data.aws_iam_policy_document.assume_role[0].json\n+ )\n+ )\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_trust_policy\" {\n+ description = \"A custorm role trust policy\"\n+ type = string\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---\n\n\n---\n\nChoice C:\nexamples/iam-assumable-role/README.md\n@@ -26,20 +26,25 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_custom\"></a> [iam\\_assumable\\_role\\_custom](#module\\_iam\\_assumable\\_role\\_custom) | ../../modules/iam-assumable-role | n/a |\n+| <a name=\"module_iam_assumable_role_custom_trust_policy\"></a> [iam\\_assumable\\_role\\_custom\\_trust\\_policy](#module\\_iam\\_assumable\\_role\\_custom\\_trust\\_policy) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_sts\"></a> [iam\\_assumable\\_role\\_sts](#module\\_iam\\_assumable\\_role\\_sts) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy_document.custom_trust_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n---\nexamples/iam-assumable-role/main.tf\n@@ -91,6 +91,54 @@ module \"iam_assumable_role_sts\" {\n # number_of_custom_role_policy_arns = 3\n }\n \n+#########################################\n+# IAM assumable role with custom trust policy\n+#########################################\n+module \"iam_assumable_role_custom_trust_policy\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ create_role = true\n+\n+ modules.\n role_name = \"iam_assumable_role_custom_trust_policy\"\n+\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+}\n+\n+data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [\"some-ext-id\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:PrincipalOrgID\"\n+ values = [\"o-someorgid\"]\n+ }\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"*\"]\n+ }\n+ }\n+\n+ statement {\n+ effect = \"Deny\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:aws:iam::111111111111:root\"]\n+ }\n+ }\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -46,6 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,8 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+\n statement {\n effect = \"Allow\"\n \n@@ -30,6 +32,8 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+\n statement {\n effect = \"Allow\"\n \n@@ -79,7 +83,12 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = var.role_requires_mfa ? data.aws_iam_policy_document.assume_role_with_mfa.json : data.aws_iam_policy_document.assume_role.json\n+ assume_role_policy = coalesce(\n+ var.custom_role_trust_policy,\n+ try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n+ data.aws_iam_policy_document.assume_role[0].json\n+ )\n+ )\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_trust_policy\" {\n+ description = \"A custorm role trust policy\"\n+ type = string\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---\n\n\n---\n\nChoice D:\nexamples/iam-assumable-role/README.md\n@@ -26,20 +26,25 @@ Run `terraform destroy` when you don't need these resources.\n \n ## Providers\n \n-No providers.\n+| Name | Version |\n+|------|---------|\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 2.23 |\n \n ## Modules\n \n | Name | Source | Version |\n |------|--------|---------|\n | <a name=\"module_iam_assumable_role_admin\"></a> [iam\\_assumable\\_role\\_admin](#module\\_iam\\_assumable\\_role\\_admin) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_custom\"></a> [iam\\_assumable\\_role\\_custom](#module\\_iam\\_assumable\\_role\\_custom) | ../../modules/iam-assumable-role | n/a |\n+| <a name=\"module_iam_assumable_role_custom_trust_policy\"></a> [iam\\_assumable\\_role\\_custom\\_trust\\_policy](#module\\_iam\\_assumable\\_role\\_custom\\_trust\\_policy) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_assumable_role_sts\"></a> [iam\\_assumable\\_role\\_sts](#module\\_iam\\_assumable\\_role\\_sts) | ../../modules/iam-assumable-role | n/a |\n | <a name=\"module_iam_policy\"></a> [iam\\_policy](#module\\_iam\\_policy) | ../../modules/iam-policy | n/a |\n \n ## Resources\n \n-No resources.\n+| Name | Type |\n+|------|------|\n+| [aws_iam_policy_document.custom_trust_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n---\nexamples/iam-assumable-role/main.tf\n@@ -91,6 +91,54 @@ module this {\n # number_of_custom_role_policy_arns = 3\n }\n \n+#########################################\n+# IAM assumable role with custom trust policy\n+#########################################\n+module \"iam_assumable_role_custom_trust_policy\" {\n+ source = \"../../modules/iam-assumable-role\"\n+\n+ create_role = true\n+\n+ role_name = \"iam_assumable_role_custom_trust_policy\"\n+\n+ custom_role_trust_policy = data.aws_iam_policy_document.custom_trust_policy.json\n+ custom_role_policy_arns = [\"arn:aws:iam::aws:policy/AmazonCognitoReadOnly\"]\n+}\n+\n+data \"aws_iam_policy_document\" \"custom_trust_policy\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"sts:ExternalId\"\n+ values = [\"some-ext-id\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:PrincipalOrgID\"\n+ values = [\"o-someorgid\"]\n+ }\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"*\"]\n+ }\n+ }\n+\n+ statement {\n+ effect = \"Deny\"\n+ actions = [\"sts:AssumeRole\"]\n+\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [\"arn:aws:iam::111111111111:root\"]\n+ }\n+ }\n+}\n+\n #########################################\n # IAM policy\n #########################################\n---\nmodules/iam-assumable-role/README.md\n@@ -46,6 +46,7 @@ No modules.\n | <a name=\"input_create_instance_profile\"></a> [create\\_instance\\_profile](#input\\_create\\_instance\\_profile) | Whether to create an instance profile | `bool` | `false` | no |\n | <a name=\"input_create_role\"></a> [create\\_role](#input\\_create\\_role) | Whether to create a role | `bool` | `false` | no |\n | <a name=\"input_custom_role_policy_arns\"></a> [custom\\_role\\_policy\\_arns](#input\\_custom\\_role\\_policy\\_arns) | List of ARNs of IAM policies to attach to IAM role | `list(string)` | `[]` | no |\n+| <a name=\"input_custom_role_trust_policy\"></a> [custom\\_role\\_trust\\_policy](#input\\_custom\\_role\\_trust\\_policy) | A custorm role trust policy | `string` | `\"\"` | no |\n | <a name=\"input_force_detach_policies\"></a> [force\\_detach\\_policies](#input\\_force\\_detach\\_policies) | Whether policies should be detached from this role when destroying | `bool` | `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_mfa_age\"></a> [mfa\\_age](#input\\_mfa\\_age) | Max age of valid MFA (in seconds) for roles which require MFA | `number` | `86400` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,8 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 0 : 1\n+\n statement {\n effect = \"Allow\"\n \n@@ -30,6 +32,8 @@ data \"aws_iam_policy_document\" \"assume_role\" {\n }\n \n data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n+ count = var.custom_role_trust_policy == \"\" && var.role_requires_mfa ? 1 : 0\n+\n statement {\n effect = \"Allow\"\n \n@@ -79,7 +83,12 @@ resource \"aws_iam_role\" \"this\" {\n force_detach_policies = var.force_detach_policies\n permissions_boundary = var.role_permissions_boundary_arn\n \n- assume_role_policy = var.role_requires_mfa ? data.aws_iam_policy_document.assume_role_with_mfa.json : data.aws_iam_policy_document.assume_role.json\n+ assume_role_policy = coalesce(\n+ var.custom_role_trust_policy,\n+ try(data.aws_iam_policy_document.assume_role_with_mfa[0].json,\n+ data.aws_iam_policy_document.assume_role[0].json\n+ )\n+ )\n \n tags = var.tags\n }\n---\nmodules/iam-assumable-role/variables.tf\n@@ -76,6 +76,12 @@ variable \"custom_role_policy_arns\" {\n default = []\n }\n \n+variable \"custom_role_trust_policy\" {\n+ description = \"A custorm role trust policy\"\n+ type = string\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---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested IAM change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixes #152 \r\n\r\n## Description\r\nThis is a small patch change discussed with @antonbabenko to make sure there is no discrepancy when using trusted_role_actions with or without MFA\r\n\r\n## Motivation and Context\r\nConsistent module behaviour based on inputs\r\n\r\n## Breaking Changes\r\nnone\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\n\n---\n\nChoice A:\nmodules/iam-assumable-role/main.tf\n@@ -33,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n statement {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type = \"AWS\"\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/main.tf\n@@ -33,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n statement {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n = \"AWS\"\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/main.tf\n@@ -33,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n statement {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type \"AWS\"\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/main.tf\n@@ -33,7 +33,7 @@ data \"aws_iam_policy_document\" \"assume_role_with_mfa\" {\n statement {\n effect = \"Allow\"\n \n- actions = [\"sts:AssumeRole\"]\n+ actions = var.trusted_role_actions\n \n principals {\n type actions = \"AWS\"\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\nChange allows to control via parameter if sts:TagSession statement is added into role assume document \r\n\r\n## Motivation and Context\r\nThe change is required for a lot of people using GithubActions and relying on this repository structures for controlling IAM. Without this additional workarounds are required to fully use the solution. \r\nFix #152 \r\n\r\n## Breaking Changes\r\nThere are no breaking changes\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\n\n---\n\nChoice A:\nmodules/iam-assumable-role/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n+| <a name=\"input_role_allows_session_tag\"></a> [role\\_allows\\_session\\_tag](#input\\_role\\_allows\\_session\\_tag) | Whether role creates IAM statement to allow sts:TagSession | `bool` | `false` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,24 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_allows_session_tag == true ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ actions = [ \"sts:TagSession\" ]\n+ }\n+ }\n+ \n statement {\n effect = \"Allow\"\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -58,6 +58,12 @@ variable \"role_requires_mfa\" {\n default = true\n }\n \n+variable \"role_allows_session_tag\" {\n+ description = \"Whether role trust allows creation of sts:SessionTags\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"role_permissions_boundary_arn\" {\n description = \"Permissions boundary ARN to use for IAM role\"\n type = string\n---\n\n\n---\n\nChoice B:\nmodules/iam-assumable-role/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n+| <a name=\"input_role_allows_session_tag\"></a> [role\\_allows\\_session\\_tag](#input\\_role\\_allows\\_session\\_tag) | Whether role creates IAM statement to allow sts:TagSession | `bool` | `false` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,24 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_allows_session_tag == true ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ actions = [ \"sts:TagSession\" ]\n+ }\n+ }\n+ \n statement {\n effect = \"Allow\"\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -58,6 +58,12 @@ variable \"role_requires_mfa\" {\n default = true\n }\n \n+variable \"role_allows_session_tag\" {\n+ description = \"Whether role trust allows creation of sts:SessionTags\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"role_permissions_boundary_arn\" {\n description = \"Permissions boundary ARN to use for IAM role\"\n type | string\n---\n\n\n---\n\nChoice C:\nmodules/iam-assumable-role/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` name=\"input_role_path\"></a> no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n+| <a name=\"input_role_allows_session_tag\"></a> [role\\_allows\\_session\\_tag](#input\\_role\\_allows\\_session\\_tag) | Whether role creates IAM statement to allow sts:TagSession | `bool` | `false` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,24 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_allows_session_tag == true ? [1] : []\n+ content {\n+ effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ actions = [ \"sts:TagSession\" ]\n+ }\n+ }\n+ \n statement {\n effect = \"Allow\"\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -58,6 +58,12 @@ variable \"role_requires_mfa\" {\n default = true\n }\n \n+variable \"role_allows_session_tag\" {\n+ description = \"Whether role trust allows creation of sts:SessionTags\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"role_permissions_boundary_arn\" {\n description = \"Permissions boundary ARN to use for IAM role\"\n type = string\n---\n\n\n---\n\nChoice D:\nmodules/iam-assumable-role/README.md\n@@ -56,6 +56,7 @@ No modules.\n | <a name=\"input_role_name\"></a> [role\\_name](#input\\_role\\_name) | IAM role name | `string` | `\"\"` | no |\n | <a name=\"input_role_path\"></a> [role\\_path](#input\\_role\\_path) | Path of IAM role | `string` | `\"/\"` | no |\n | <a name=\"input_role_permissions_boundary_arn\"></a> [role\\_permissions\\_boundary\\_arn](#input\\_role\\_permissions\\_boundary\\_arn) | Permissions boundary ARN to use for IAM role | `string` | `\"\"` | no |\n+| <a name=\"input_role_allows_session_tag\"></a> [role\\_allows\\_session\\_tag](#input\\_role\\_allows\\_session\\_tag) | Whether role creates IAM statement to allow sts:TagSession | `bool` | `false` | no |\n | <a name=\"input_role_requires_mfa\"></a> [role\\_requires\\_mfa](#input\\_role\\_requires\\_mfa) | Whether role requires MFA | `bool` | `true` | no |\n | <a name=\"input_role_sts_externalid\"></a> [role\\_sts\\_externalid](#input\\_role\\_sts\\_externalid) | STS ExternalId condition values to use with a role (when MFA is not required) | `any` | `[]` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to add to IAM role resources | `map(string)` | `{}` | no |\n---\nmodules/iam-assumable-role/main.tf\n@@ -3,6 +3,24 @@ locals {\n }\n \n data \"aws_iam_policy_document\" \"assume_role\" {\n+\n+ dynamic \"statement\" {\n+ for_each = var.role_allows_session_tag == true ? [1] : []\n+ content {\n+ effect = for principals {\n+ type = \"AWS\"\n+ identifiers = var.trusted_role_arns\n+ }\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = var.trusted_role_services\n+ }\n+ actions = [ \"sts:TagSession\" ]\n+ }\n+ }\n+ \n statement {\n effect = \"Allow\"\n \n---\nmodules/iam-assumable-role/variables.tf\n@@ -58,6 +58,12 @@ variable \"role_requires_mfa\" {\n default = true\n }\n \n+variable \"role_allows_session_tag\" {\n+ description = \"Whether role trust allows creation of sts:SessionTags\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"role_permissions_boundary_arn\" {\n description = \"Permissions boundary ARN to use for IAM role\"\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\nAdd `group_arn` to the outputs of the `iam-group-with-policies` module.\r\n\r\n## Motivation and Context\r\nI was missing this feature for a personal project, where I am using the `iam-assumable-roles` module and want to refer to a group by its ARN.\r\n\r\n## Breaking Changes\r\nNo breaking changes, just adding a new output.\r\n\r\n## How Has This Been Tested?\r\nI have tested this change on my aforementioned project. The output is there and I can refer to it in other resources.\r\n\n\n---\n\nChoice A:\nexamples/iam-group-with-policies/README.md\n@@ -51,6 +51,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n | <a name=\"output_iam_account_id\"></a> [iam\\_account\\_id](#output\\_iam\\_account\\_id) | IAM AWS account id |\n---\nexamples/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"iam_account_id\" {\n value = module.iam_group_superadmins.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = module.iam_group_superadmins.group_arn\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = module.iam_group_superadmins.group_users\n---\nmodules/iam-group-with-policies/README.md\n@@ -54,6 +54,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_aws_account_id\"></a> [aws\\_account\\_id](#output\\_aws\\_account\\_id) | IAM AWS account id |\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM arn\"\n+ in IAM group |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"aws_account_id\" {\n value = local.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = element(concat(aws_iam_group.this.*.arn, [\"\"]), 0)\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = flatten(aws_iam_group_membership.this.*.users)\n---\n\n\n---\n\nChoice B:\nexamples/iam-group-with-policies/README.md\n@@ -51,6 +51,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n | <a name=\"output_iam_account_id\"></a> [iam\\_account\\_id](#output\\_iam\\_account\\_id) | IAM AWS account id |\n---\nexamples/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"iam_account_id\" {\n value = module.iam_group_superadmins.aws_account_id\n }\n \n+output {\n+ description = \"IAM group arn\"\n+ value = module.iam_group_superadmins.group_arn\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = module.iam_group_superadmins.group_users\n---\nmodules/iam-group-with-policies/README.md\n@@ -54,6 +54,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_aws_account_id\"></a> [aws\\_account\\_id](#output\\_aws\\_account\\_id) | IAM AWS account id |\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"aws_account_id\" {\n value = local.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = element(concat(aws_iam_group.this.*.arn, [\"\"]), 0)\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = flatten(aws_iam_group_membership.this.*.users)\n---\n\n\n---\n\nChoice C:\nexamples/iam-group-with-policies/README.md\n@@ -51,6 +51,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n | <a name=\"output_iam_account_id\"></a> [iam\\_account\\_id](#output\\_iam\\_account\\_id) | IAM AWS account id |\n---\nexamples/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"iam_account_id\" {\n value = module.iam_group_superadmins.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = module.iam_group_superadmins.group_arn\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = module.iam_group_superadmins.group_users\n---\nmodules/iam-group-with-policies/README.md\n@@ -54,6 +54,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_aws_account_id\"></a> [aws\\_account\\_id](#output\\_aws\\_account\\_id) | IAM AWS account id |\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"aws_account_id\" {\n value = local.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = element(concat(aws_iam_group.this.*.arn, [\"\"]), 0)\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = flatten(aws_iam_group_membership.this.*.users)\n---\n\n\n---\n\nChoice D:\nexamples/iam-group-with-policies/README.md\n@@ -51,6 +51,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n | <a name=\"output_iam_account_id\"></a> [iam\\_account\\_id](#output\\_iam\\_account\\_id) | IAM AWS account id |\n---\nexamples/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"iam_account_id\" {\n value = module.iam_group_superadmins.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = module.iam_group_superadmins.group_arn\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = module.iam_group_superadmins.group_users\n---\nmodules/iam-group-with-policies/README.md\n@@ -54,6 List @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_aws_account_id\"></a> [aws\\_account\\_id](#output\\_aws\\_account\\_id) | IAM AWS account id |\n+| <a name=\"output_group_arn\"></a> [group\\_arn](#output\\_group\\_arn) | IAM group arn |\n | <a name=\"output_group_name\"></a> [group\\_name](#output\\_group\\_name) | IAM group name |\n | <a name=\"output_group_users\"></a> [group\\_users](#output\\_group\\_users) | List of IAM users in IAM group |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n---\nmodules/iam-group-with-policies/outputs.tf\n@@ -3,6 +3,11 @@ output \"aws_account_id\" {\n value = local.aws_account_id\n }\n \n+output \"group_arn\" {\n+ description = \"IAM group arn\"\n+ value = element(concat(aws_iam_group.this.*.arn, [\"\"]), 0)\n+}\n+\n output \"group_users\" {\n description = \"List of IAM users in IAM group\"\n value = flatten(aws_iam_group_membership.this.*.users)\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\nAdded the IAM Instance Profiles ID to the `iam-assumanle-role` exported output.\r\n\r\n## Motivation and Context\r\nI was unable to add the IAM instance profiles `ID` attribute when trying to add `iam_instance_profile` to an EC2 Terraform Resource using the `iam-assumanle-role` module.\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_Testing_\r\nI add the ID attribute to the outputs and locally tested the module's example template with Terraform version 1.x and provider\r\nversion v.3.58.0\r\nTerraform apply output showing the IAM Instance Profile ID below:\r\n````\r\nOutputs:\r\n\r\niam_instance_profile_id = \"admin\"\r\niam_role_arn = \"arn:aws:iam::185203724531:role/admin\"\r\niam_role_name = \"admin\"\r\niam_role_path = \"/\"\r\niam_role_unique_id = \"AROASWHYASDZ4CRLPZFCH\"\r\nrole_requires_mfa = true\r\n```\r\n\n\n---\n\nChoice A:\nexamples/iam-assumable-role/README.md\n@@ -49,6 +49,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n---\nexamples/iam-assumable-role/main.tf\n@@ -17,7 +17,8 @@ module \"iam_assumable_role_admin\" {\n \"codedeploy.amazonaws.com\"\n ]\n \n- create_role = true\n+ create_role = true\n+ create_instance_profile = true\n \n role_name = \"admin\"\n role_requires_mfa = true\n---\nexamples/iam-assumable-role/outputs.tf\n@@ -22,3 +22,8 @@ output \"role_requires_mfa\" {\n description = \"Whether admin IAM role requires MFA\"\n value = module.iam_assumable_role_admin.role_requires_mfa\n }\n+\n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = module.iam_assumable_role_admin.iam_instance_profile_id\n+}\n---\nmodules/iam-assumable-role/README.md\n@@ -68,6 +68,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_instance_profile_arn\"></a> [iam\\_instance\\_profile\\_arn](#output\\_iam\\_instance\\_profile\\_arn) | ARN of IAM instance profile |\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_instance_profile_name\"></a> [iam\\_instance\\_profile\\_name](#output\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n | <a name=\"output_iam_instance_profile_path\"></a> [iam\\_instance\\_profile\\_path](#output\\_iam\\_instance\\_profile\\_path) | Path of IAM instance profile |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -33,6 +33,11 @@ output \"iam_instance_profile_name\" {\n value = element(concat(aws_iam_instance_profile.this.*.name, [\"\"]), 0)\n }\n \n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = element(concat(aws_iam_instance_profile.this.*.id, [\"\"]), 0)\n+}\n+\n output \"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\n---\n\nChoice B:\nexamples/iam-assumable-role/README.md\n@@ -49,6 +49,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n---\nexamples/iam-assumable-role/main.tf\n@@ -17,7 +17,8 @@ module \"iam_assumable_role_admin\" {\n \"codedeploy.amazonaws.com\"\n ]\n \n- create_role = true\n+ create_role = true\n+ create_instance_profile = true\n \n role_name = \"admin\"\n role_requires_mfa = true\n---\nexamples/iam-assumable-role/outputs.tf\n@@ -22,3 +22,8 @@ output \"role_requires_mfa\" {\n description = \"Whether admin IAM role requires MFA\"\n value = module.iam_assumable_role_admin.role_requires_mfa\n }\n+\n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = module.iam_assumable_role_admin.iam_instance_profile_id\n+}\n---\nmodules/iam-assumable-role/README.md\n@@ -68,6 +68,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_instance_profile_arn\"></a> [iam\\_instance\\_profile\\_arn](#output\\_iam\\_instance\\_profile\\_arn) | ARN of IAM instance profile element(concat(aws_iam_instance_profile.this.*.path, <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_instance_profile_name\"></a> [iam\\_instance\\_profile\\_name](#output\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n | <a name=\"output_iam_instance_profile_path\"></a> [iam\\_instance\\_profile\\_path](#output\\_iam\\_instance\\_profile\\_path) | Path of IAM instance profile |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -33,6 +33,11 @@ output \"iam_instance_profile_name\" {\n value = element(concat(aws_iam_instance_profile.this.*.name, [\"\"]), 0)\n }\n \n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = element(concat(aws_iam_instance_profile.this.*.id, [\"\"]), 0)\n+}\n+\n output \"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\n---\n\nChoice C:\nexamples/iam-assumable-role/README.md\n@@ -49,6 +49,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n---\nexamples/iam-assumable-role/main.tf\n@@ -17,7 +17,8 @@ module \"iam_assumable_role_admin\" {\n \"codedeploy.amazonaws.com\"\n ]\n \n- create_role = true\n+ create_role = true\n+ create_instance_profile = true\n \n role_name = \"admin\"\n role_requires_mfa = true\n---\nexamples/iam-assumable-role/outputs.tf\n@@ -22,3 +22,8 @@ output \"role_requires_mfa\" {\n description = \"Whether admin IAM role requires MFA\"\n value = module.iam_assumable_role_admin.role_requires_mfa\n }\n+\n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = module.iam_assumable_role_admin.iam_instance_profile_id\n+}\n---\nmodules/iam-assumable-role/README.md\n@@ -68,6 +68,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_instance_profile_arn\"></a> [iam\\_instance\\_profile\\_arn](#output\\_iam\\_instance\\_profile\\_arn) | ARN of IAM instance profile |\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_instance_profile_name\"></a> [iam\\_instance\\_profile\\_name](#output\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n | <a name=\"output_iam_instance_profile_path\"></a> [iam\\_instance\\_profile\\_path](#output\\_iam\\_instance\\_profile\\_path) | Path of IAM instance profile |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -33,6 +33,11 @@ output \"iam_instance_profile_name\" {\n value = element(concat(aws_iam_instance_profile.this.*.name, [\"\"]), 0)\n }\n \n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = element(concat(aws_iam_instance_profile.this.*.id, [\"\"]), 0)\n+}\n+\n output \"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\n---\n\nChoice D:\nexamples/iam-assumable-role/README.md\n@@ -49,6 +49,7 @@ No inputs.\n \n | Name | Description |\n |------|-------------|\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n | <a name=\"output_iam_role_name\"></a> [iam\\_role\\_name](#output\\_iam\\_role\\_name) | Name of IAM role |\n | <a name=\"output_iam_role_path\"></a> [iam\\_role\\_path](#output\\_iam\\_role\\_path) | Path of IAM role |\n---\nexamples/iam-assumable-role/main.tf\n@@ -17,7 +17,8 @@ module \"iam_assumable_role_admin\" {\n \"codedeploy.amazonaws.com\"\n ]\n \n- create_role = true\n+ create_role = true\n+ create_instance_profile = true\n \n role_name = \"admin\"\n role_requires_mfa = true\n---\nexamples/iam-assumable-role/outputs.tf\n@@ -22,3 +22,8 @@ output \"role_requires_mfa\" {\n description = \"Whether admin IAM role requires MFA\"\n value = module.iam_assumable_role_admin.role_requires_mfa\n }\n+\n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = module.iam_assumable_role_admin.iam_instance_profile_id\n+}\n---\nmodules/iam-assumable-role/README.md\n@@ -68,6 +68,7 @@ No modules.\n | Name | Description |\n |------|-------------|\n | <a name=\"output_iam_instance_profile_arn\"></a> [iam\\_instance\\_profile\\_arn](#output\\_iam\\_instance\\_profile\\_arn) | ARN of IAM instance profile |\n+| <a name=\"output_iam_instance_profile_id\"></a> [iam\\_instance\\_profile\\_id](#output\\_iam\\_instance\\_profile\\_id) | IAM Instance profile's ID. |\n | <a name=\"output_iam_instance_profile_name\"></a> [iam\\_instance\\_profile\\_name](#output\\_iam\\_instance\\_profile\\_name) | Name of IAM instance profile |\n | <a name=\"output_iam_instance_profile_path\"></a> [iam\\_instance\\_profile\\_path](#output\\_iam\\_instance\\_profile\\_path) | Path of IAM instance profile |\n | <a name=\"output_iam_role_arn\"></a> [iam\\_role\\_arn](#output\\_iam\\_role\\_arn) | ARN of IAM role |\n---\nmodules/iam-assumable-role/outputs.tf\n@@ -33,6 +33,11 @@ output \"iam_instance_profile_name\" {\n value = element(concat(aws_iam_instance_profile.this.*.name, [\"\"]), 0)\n }\n \n+output \"iam_instance_profile_id\" {\n+ description = \"IAM Instance profile's ID.\"\n+ value = element(concat(aws_iam_instance_profile.this.*.id, [\"\"]), 0)\n+}\n+\n output \"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\n---\n" } ]
C