Skip to content

Commit 6306837

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

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ No resources.
112112
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
113113
| <a name="input_family"></a> [family](#input\_family) | Redis family | `string` | n/a | yes |
114114
| <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 |
115-
| <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 |
116-
| <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 |
117115
| <a name="input_ingress_cidr_blocks"></a> [ingress\_cidr\_blocks](#input\_ingress\_cidr\_blocks) | CIDR blocks for permitted ingress | `list(string)` | n/a | yes |
118116
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
119117
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |

src/providers.tf

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +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
56

67
dynamic "assume_role" {
7-
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])
810
content {
9-
role_arn = coalesce(var.import_role_arn, module.iam_roles.terraform_role_arn)
11+
role_arn = module.iam_roles.terraform_role_arn
1012
}
1113
}
1214
}
@@ -15,15 +17,3 @@ module "iam_roles" {
1517
source = "../account-map/modules/iam-roles"
1618
context = module.this.context
1719
}
18-
19-
variable "import_profile_name" {
20-
type = string
21-
default = null
22-
description = "AWS Profile name to use when importing a resource"
23-
}
24-
25-
variable "import_role_arn" {
26-
type = string
27-
default = null
28-
description = "IAM Role ARN to use when importing a resource"
29-
}

0 commit comments

Comments
 (0)