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

Fetching SSO IAM role ARNs dynamically #14173

Closed
mattdodge opened this issue Jul 14, 2020 · 5 comments · Fixed by #18585
Closed

Fetching SSO IAM role ARNs dynamically #14173

mattdodge opened this issue Jul 14, 2020 · 5 comments · Fixed by #18585
Labels
question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. service/iam Issues and PRs that pertain to the iam service.
Milestone

Comments

@mattdodge
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.12.19
+ provider.aws v2.61.0

Affected Resource(s)

  • aws_iam_role

Expected Behavior

We're using AWS SSO to authenticate into our different AWS accounts. This creates roles in each account that maps to the permission sets in AWS SSO. I'm wondering how I can get these role names in a dynamic fashion in terraform.

For example, I want to allow our developers access to our Kubernetes cluster. I do this by creating a role that has access that a developer can call AssumeRole on, like so.

resource "aws_iam_role" "developer_cluster_access" {
  name                 = "cluster-access-developer"
  assume_role_policy   = data.aws_iam_policy_document.developer_cluster_access.json
}

data "aws_iam_policy_document" "developer_cluster_access" {
  statement {
    actions = ["sts:AssumeRole"]
    principals {
      type = "AWS"
      identifiers = ["my_role_arn_goes_here"]  # <-- I want this to be dynamic
    }
  }
}

Right now I'm having to hard code that role ARN in the assume role policy document - I would like for this to be fetched dynamically.

I could use the aws_iam_role data source but for that I need the role name. The name structure of the role seems to be something like AWSReservedSSO_<permission set>_<unique hash> (Example role name: AWSReservedSSO_AWSPowerUserAccess_aaaaaabbbbbbcccc). Is there a reliable/deterministic way to compute that hash in terraform?

@ghost ghost added the service/iam Issues and PRs that pertain to the iam service. label Jul 14, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 14, 2020
@breathingdust breathingdust added question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 15, 2020
@sidewinder12s
Copy link

Anyone know how easy it might be to update the aws_iam_role data source to search for roles based on part of the name or by tags?

@Marcvd316
Copy link

This issue is nearly identical to the one I opened in August last year : #14470. Maybe they should be merged?

@seddarj
Copy link

seddarj commented Mar 15, 2021

I believe #18048 would fix this issue 😅

@github-actions
Copy link

This functionality has been released in v3.55.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue 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 similar to this, 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 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants