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: Add support for OIDC policy conditions #480

Merged

Conversation

fatmcgav
Copy link
Contributor

@fatmcgav fatmcgav commented Apr 19, 2024

Description

This commit adds support to the iam-assumable-role-with-oidc module
for adding policy conditions constraints [1]

Also add an example showing use with aws:RequestTag session tag match [2].

[1] https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#condition
[2] https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html

Motivation and Context

AWS STS session tags allow for additional control when using the AssumeRoleWithWebIdentity authentication call.

Breaking Changes

None

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@bryantbiggs
Copy link
Member

this looks like you are looking for the https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-role-for-service-accounts-eks instead - using that sub-module, is this change still warranted? I'm thinking no

@fatmcgav
Copy link
Contributor Author

Hey @bryantbiggs ...

So I think this change is still valid, as I'm using session tags in combination with an external OIDC provider, in this case env0. Docs are here: https://docs.env0.com/docs/oidc-with-aws#custom-claims-with-aws-session-tags-optional

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label May 23, 2024
@fatmcgav
Copy link
Contributor Author

@bryantbiggs / @antonbabenko Any chance of a review on this one? 👍

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Jun 23, 2024
@yaroslav-nakonechnikov
Copy link

ping

@yaroslav-nakonechnikov
Copy link

as i understand, it also covers #426 in different way

@github-actions github-actions bot removed the stale label Jul 3, 2024
@fatmcgav fatmcgav force-pushed the feat/oidc-trust-policy branch 2 times, most recently from e322820 to 12a82ef Compare July 5, 2024 18:19
@fatmcgav
Copy link
Contributor Author

fatmcgav commented Jul 5, 2024

@bryantbiggs I've updated this PR following the discussion we had on #479 (comment)

@fatmcgav fatmcgav changed the title feat: Add support for STS Session Tags feat: Add support for OIDC policy conditions Jul 5, 2024
@fatmcgav
Copy link
Contributor Author

fatmcgav commented Jul 5, 2024

@bryantbiggs OK, I've tweaked the PR to make it more generic.
I did make one tweak to your suggestions, which was to call the variable polcy_conditions rather than prvovider_conditions, as I think the former is closer to the docs.

PTAL 👍

"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",
]

policy_conditions = [
Copy link
Member

Choose a reason for hiding this comment

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

we can add to existing example instead of creating new

Copy link

github-actions bot commented Aug 8, 2024

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Aug 8, 2024
@fatmcgav
Copy link
Contributor Author

fatmcgav commented Aug 8, 2024

Apologies, just noticed the failed pre-commit check... Have fixed that now so should be good 🤞

This commit adds support to the `iam-assumable-role-with-oidc` module
for adding policy conditions constraints [1]

Also add an example showing use with `aws:RequestTag` session tag match [2].

[1] https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#condition
[2] https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html
@bryantbiggs bryantbiggs merged commit 02a5b7f into terraform-aws-modules:master Aug 8, 2024
34 checks passed
antonbabenko pushed a commit that referenced this pull request Aug 8, 2024
## [5.44.0](v5.43.0...v5.44.0) (2024-08-08)

### Features

* Add support for OIDC policy conditions ([#480](#480)) ([02a5b7f](02a5b7f))
@antonbabenko
Copy link
Member

This PR is included in version 5.44.0 🎉

Copy link

github-actions bot commented Sep 8, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants