feat: Add feature to configure “role-session-name” in config
Closed this issue · 5 comments
Feature Overview
I want to be able to set any role-session-name
in aws-actions/configure-aws-credentials.
Why is the feature needed?
Currently, tfaction has a fixed value of samplerolesession
when execute AssumeRole operation, which is undesirable.
Line 93 in 1f76ed1
This value is mainly recorded in CloudTrail as the User name.
Ideally, different names should be set for different IAM Roles. This makes it easier to track which session performed which operation.
Example Code
tfaction-root.yaml
target_groups:
- working_directory: fastly
target: fastly
aws_region: ap-northeast-1
terraform_plan_config:
aws_assume_role_arn: arn:aws:iam::123412341234:role/github-actions-terraform-plan-role
aws_role_session_name: fastly-plan
...
expand as follow:
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
if: steps.target-config.outputs.aws_assume_role_arn != ''
with:
role-to-assume: ${{ steps.target-config.outputs.aws_assume_role_arn }}
role-session-name: fastly-plan
aws-region: ${{ steps.target-config.outputs.aws_region }}
Note
No response
Thank you for your suggestion and pull request.
Looks good, but I think we can improve the default role session name.
e.g. tfaction-{plan or apply}-{target}
The maximum length of IAM Role session name is 64, so if target
is too long, we need to remove {target}
from the session name.
tfaction-{plan or apply}
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html
I'm sorry but I noticed this after merging your pull request.
I created a pull request for this.
Thank you for you follow up! It seemed like a good idea!
📝
The maximum length of the session name is 64.
And it must satisfy regular expression pattern [\w+=,.@-]*
.
The default value of session name is
tfaction-{plan or apply}-{normalized target}-{GitHub Actions Run ID}
tfaction-{plan or apply}-{normalized target}
tfaction-{plan or apply}-{GitHub Actions Run ID}
tfaction-{plan or apply}
/
in the default targets are converted to _
.
And if target is too long, it is removed from the default session name.
tfaction v1.11.0 is out 🎉
https://github.com/suzuki-shunsuke/tfaction/releases/tag/v1.11.0