Skip to content

Commit a7c3a6f

Browse files
authored
Enable terraform plan access via dynamic Terraform roles (cloudposse/terraform-aws-components#715)
1 parent 0e3571e commit a7c3a6f

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

src/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,6 @@ Consult [actions-runner-controller](https://github.com/actions-runner-controller
438438
| <a name="input_github_app_installation_id"></a> [github\_app\_installation\_id](#input\_github\_app\_installation\_id) | The "Installation ID" of the GitHub App to use for the runner controller. | `string` | `""` | no |
439439
| <a name="input_helm_manifest_experiment_enabled"></a> [helm\_manifest\_experiment\_enabled](#input\_helm\_manifest\_experiment\_enabled) | Enable storing of the rendered manifest for helm\_release so the full diff of what is changing can been seen in the plan | `bool` | `false` | no |
440440
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
441-
| <a name="input_import_profile_name"></a> [import\_profile\_name](#input\_import\_profile\_name) | AWS Profile name to use when importing a resource | `string` | `null` | no |
442-
| <a name="input_import_role_arn"></a> [import\_role\_arn](#input\_import\_role\_arn) | IAM Role ARN to use when importing a resource | `string` | `null` | no |
443441
| <a name="input_kube_data_auth_enabled"></a> [kube\_data\_auth\_enabled](#input\_kube\_data\_auth\_enabled) | If `true`, use an `aws_eks_cluster_auth` data source to authenticate to the EKS cluster.<br>Disabled by `kubeconfig_file_enabled` or `kube_exec_auth_enabled`. | `bool` | `false` | no |
444442
| <a name="input_kube_exec_auth_aws_profile"></a> [kube\_exec\_auth\_aws\_profile](#input\_kube\_exec\_auth\_aws\_profile) | The AWS config profile for `aws eks get-token` to use | `string` | `""` | no |
445443
| <a name="input_kube_exec_auth_aws_profile_enabled"></a> [kube\_exec\_auth\_aws\_profile\_enabled](#input\_kube\_exec\_auth\_aws\_profile\_enabled) | If `true`, pass `kube_exec_auth_aws_profile` as the `profile` to `aws eks get-token` | `bool` | `false` | no |

src/provider-helm.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ locals {
101101
"--profile", var.kube_exec_auth_aws_profile
102102
] : []
103103

104-
kube_exec_auth_role_arn = coalesce(var.kube_exec_auth_role_arn, var.import_role_arn, module.iam_roles.terraform_role_arn)
104+
kube_exec_auth_role_arn = coalesce(var.kube_exec_auth_role_arn, module.iam_roles.terraform_role_arn)
105105
exec_role = local.kube_exec_auth_enabled && var.kube_exec_auth_role_arn_enabled ? [
106106
"--role-arn", local.kube_exec_auth_role_arn
107107
] : []

src/providers.tf

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
provider "aws" {
22
region = var.region
33

4-
profile = module.iam_roles.profiles_enabled ? coalesce(var.import_profile_name, module.iam_roles.terraform_profile_name) : null
4+
# Profile is deprecated in favor of terraform_role_arn. When profiles are not in use, terraform_profile_name is null.
5+
profile = module.iam_roles.terraform_profile_name
6+
57
dynamic "assume_role" {
6-
for_each = module.iam_roles.profiles_enabled ? [] : ["role"]
8+
# module.iam_roles.terraform_role_arn may be null, in which case do not assume a role.
9+
for_each = compact([module.iam_roles.terraform_role_arn])
710
content {
8-
role_arn = coalesce(var.import_role_arn, module.iam_roles.terraform_role_arn)
11+
role_arn = module.iam_roles.terraform_role_arn
912
}
1013
}
1114
}
@@ -14,15 +17,3 @@ module "iam_roles" {
1417
source = "../../account-map/modules/iam-roles"
1518
context = module.this.context
1619
}
17-
18-
variable "import_profile_name" {
19-
type = string
20-
default = null
21-
description = "AWS Profile name to use when importing a resource"
22-
}
23-
24-
variable "import_role_arn" {
25-
type = string
26-
default = null
27-
description = "IAM Role ARN to use when importing a resource"
28-
}

0 commit comments

Comments
 (0)