diff --git a/docs/resources/alks_iamrole.md b/docs/resources/alks_iamrole.md index 0493d8ec..e25d8969 100644 --- a/docs/resources/alks_iamrole.md +++ b/docs/resources/alks_iamrole.md @@ -5,6 +5,7 @@ Creates an custom ALKS IAM role for usage in an AWS account. ## Example Usage ### ALKS IAM Role Creation + ```hcl resource "alks_iamrole" "test_role" { name = "My_Test_Role" @@ -14,9 +15,26 @@ resource "alks_iamrole" "test_role" { } ``` +### ALKS Dynamic Role Creation + +```hcl +resource "alks_iamrole" "test_dynamic_role" { + name = "my_dynamic_role" + type = "Amazon EKS IRSA" + include_default_policies = false + enable_alks_access = false + template_fields = { + "OIDC_PROVIDER" = "abc1234" + "K8S_NAMESPACE" = "default" + "K8S_SERVICE_ACCOUNT" = "my-service-account" + } +} +``` + ## Argument Reference The following arguments are supported: + * `name` - (Required) The name of the ALKS IAM role which will be reflected in AWS and the ALKS UI. * `type` - (Required) The role type to use. To see a list of available roles, [call this endpoint](https://pages.ghe.coxautoinc.com/ETS-CloudAutomation/ALKS-Documentation/#/aws-role-type-rest-service/getAllAwsRoleTypesUsingGET). * `include_default_policies` - (Required) Whether or not the default manages policies should be attached to the role. @@ -24,12 +42,14 @@ The following arguments are supported: * `arn` - (Computed) Provides the ARN of the role that was created. * `ip_arn` - (Computed) If `role_added_to_ip` was `true` this will provide the ARN of the instance profile role. * `enable_alks_access` - (Optional) If `true`, allows ALKS calls to be made by instance profiles or Lambda functions making use of this role. Note: This enables **machine identity** capability. +* `template_fields` - (Optional) If present, will submit template field data to ALKS. Note: This will generate an error if the role type does not support template fields. ## Import !> **Warning:** This will force-replace the resource. ALKS IAM roles can be imported using the `name`, e.g. -``` -$ terraform import alks_iamrole.test_role My_Test_Role + +```sh +terraform import alks_iamrole.test_role My_Test_Role ``` \ No newline at end of file diff --git a/examples/alks.tf b/examples/alks.tf index 379eb4f8..6ac2f0a2 100644 --- a/examples/alks.tf +++ b/examples/alks.tf @@ -40,6 +40,18 @@ resource "alks_iamrole" "test_role" { enable_alks_access = true } +resource "alks_iamrole" "test_dynamic_role" { + name = "TEST-DELETE-DYNAMIC" + type = "Amazon EKS IRSA" + include_default_policies = false + enable_alks_access = true + template_fields = { + "OIDC_PROVIDER" = "abc1234" + "K8S_NAMESPACE" = "default" + "K8S_SERVICE_ACCOUNT" = "definitely-not-real" + } +} + # CREATE IAM ROLE -- Secondary Provider resource "alks_iamrole" "test_role_nonprod" { provider = alks.nonprod @@ -52,7 +64,7 @@ resource "alks_iamrole" "test_role_nonprod" { # ATTACH POLICY resource "aws_iam_role_policy" "test_policy" { name = "test_policy" - role = "${alks_iamrole.test_role.name}" + role = alks_iamrole.test_role.name policy = <