Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (PSKD-904) Support credentials when assuming an IAM role #319

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from

Conversation

dhoucgitter
Copy link
Member

Changes

  • Updates to support authenticating to Terraform using temporary AWS credentials generated by assuming an IAM role
  • Expose EKS cluster authentication_mode as a General configuration variable
  • Add access_entry_role_arns as a General configuration variable. Add behavior to create an admin level EKS access entry for each role ARN specified in this list of strings.

@dhoucgitter dhoucgitter added the enhancement New feature or request label Jan 28, 2025
@dhoucgitter dhoucgitter self-assigned this Jan 28, 2025
@dhoucgitter dhoucgitter requested a review from supear January 28, 2025 18:13
Copy link
Contributor

@supear supear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some edits!

@@ -266,6 +266,8 @@ Custom policy:
| autoscaling_enabled | Enable cluster autoscaling | bool | true | |
| ssh_public_key | File name of public ssh key for jump and nfs VM | string | "~/.ssh/id_rsa.pub" | Required with `create_jump_vm=true` or `storage_type=standard` |
| cluster_api_mode | Public or private IP for the cluster api| string|"public"|Valid Values: "public", "private" |
| authentication_mode | The authentication mode for the EKS cluster.| string|"API_AND_CONFIG_MAP"| Valid values are CONFIG_MAP, API or API_AND_CONFIG_MAP |
| access_entry_role_arns | Create an EKS access entry associated with the AmazonEKSClusterAdminPolicy for each existing IAM role ARN specified in this list. | list of strings | | **Note:** The assumed-role used to authenticate to Terraform should not be included this list. The format role ARNs take is: "arn:aws:iam::<Subscription_ID>:role/<rolename>"|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< Above, in the IAM section, we have a first reference to the abbreviation "ARN." It needs to be expanded there, so please make this change:
from cluster_iam_role_arn | ARN of the pre-existing IAM role for the EKS cluster
to: cluster_iam_role_arn | Amazon Resource Name (ARN) of the pre-existing IAM role for the EKS cluster >

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied, the upcoming commit will contain the update for your review

@@ -266,6 +266,8 @@ Custom policy:
| autoscaling_enabled | Enable cluster autoscaling | bool | true | |
| ssh_public_key | File name of public ssh key for jump and nfs VM | string | "~/.ssh/id_rsa.pub" | Required with `create_jump_vm=true` or `storage_type=standard` |
| cluster_api_mode | Public or private IP for the cluster api| string|"public"|Valid Values: "public", "private" |
| authentication_mode | The authentication mode for the EKS cluster.| string|"API_AND_CONFIG_MAP"| Valid values are CONFIG_MAP, API or API_AND_CONFIG_MAP |
| access_entry_role_arns | Create an EKS access entry associated with the AmazonEKSClusterAdminPolicy for each existing IAM role ARN specified in this list. | list of strings | | **Note:** The assumed-role used to authenticate to Terraform should not be included this list. The format role ARNs take is: "arn:aws:iam::<Subscription_ID>:role/<rolename>"|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... for each of the existing IAM role ARNs that are included in this list.
...
Note: Do not include the assumed-role that is used to authenticate to Terraform in this list. The format for role ARNs resembles the following example: "arn:aws:iam::<Subscription_ID>:role/"

Copy link
Member Author

@dhoucgitter dhoucgitter Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each suggestion applied, the upcoming commit will contain the update for your review

@@ -1,8 +1,8 @@
# Authenticating Terraform to Access AWS

In order to create and destroy AWS resources on your behalf, Terraform needs a AWS account that has sufficient permissions to perform all the actions defined in the Terraform manifest. You will need an AWS account IAM user that has at a minimum the permissions listed in [this policy](../../files/policies/devops-iac-eks-policy.json).
In order to create and destroy AWS resources on your behalf, Terraform needs to authenticate with credentials associated with an AWS account IAM user or credentials generated by assuming an IAM role that has sufficient permissions to perform all the actions defined in the Terraform manifest. You will need either an AWS account IAM user or an AWS IAM role that has at a minimum the permissions listed in [this policy](../../files/policies/devops-iac-eks-policy.json).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to create and destroy AWS resources on your behalf, Terraform needs credentials that enable it to authenticate to AWS. Two types of credentials are acceptable:

  • Credentials that are associated with an AWS IAM user account, or
  • Credentials that are generated by assuming an IAM role that has sufficient permissions to perform all the actions that are defined in the Terraform manifest.

You will need either an AWS IAM user account or an AWS IAM role that has at a minimum the permissions listed in this policy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestions applied, the upcoming commit will contain the updates for your review

@@ -28,7 +28,9 @@ TF_VAR_aws_secret_access_key=<your_aws_secret_access_key>
TF_VAR_aws_session_token=<your_aws_session_token>
```

> **NOTE** `AWS_SESSION_TOKEN` is optional and is only required when using you are using temporary AWS credentials. See the [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) on environment variables for more information.
> **NOTE** `AWS_SESSION_TOKEN` is optional and is only required when you are using temporary AWS credentials like those you would generate when assuming an IAM role. See the [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) on environment variables for more information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary AWS credentials. For example, you might generate temporary AWS credentials when assuming an IAM role.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied, upcoming commit will contain the updates for your review

> **NOTE** `AWS_SESSION_TOKEN` is optional and is only required when using you are using temporary AWS credentials. See the [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) on environment variables for more information.
> **NOTE** `AWS_SESSION_TOKEN` is optional and is only required when you are using temporary AWS credentials like those you would generate when assuming an IAM role. See the [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) on environment variables for more information.

See [AWS IAM roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) for more information about temporary credentials when using an assumed role. In order for an IAM user to be able to assume a role, a trust relationship for that user needs to be created within the role, see [granting AssumeRole permission for a role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_permissions-to-switch.html) for more information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a trust relationship for that user must be created within the role. For more information, see granting AssumeRole permission for a role.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied, upcoming commit will contain the updates for your review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants