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

trusted_entities input is only accepting Service Principals #138

Closed
flibustier opened this issue Mar 31, 2021 · 3 comments
Closed

trusted_entities input is only accepting Service Principals #138

flibustier opened this issue Mar 31, 2021 · 3 comments

Comments

@flibustier
Copy link
Contributor

Is your request related to a new offering from AWS?

I don’t think so

Is your request related to a problem? Please describe.

We want our trusted entities from our lambda role to look like the following:

"Principal": {
  "Service": "lambda.amazonaws.com",
  "AWS": "arn:aws:sts::************:assumed-role/OktaRoleFor*****/******@*****.com"
},

Unfortunately, when using the input trusted_entities as following:

trusted_entities = ["arn:aws:sts::************:assumed-role/OktaRoleFor*****/******@*****.com"]

Terraform tries to perform this :

# module.aws_iam_role.lambda[0] will be updated in-place
  ~ resource "aws_iam_role" "lambda" {
      ~ assume_role_policy    = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Principal = {
                          - AWS     = "arn:aws:sts::************:assumed-role/OktaRoleFor*****/******@*****.com" -> null
                          ~ Service = "lambda.amazonaws.com" -> [
                              + "lambda.amazonaws.com",
                              + "arn:aws:sts::************:assumed-role/OktaRoleFor*****/******@*****.com",
                            ]
                        }
                        # (3 unchanged elements hidden)
                    },
                ]
                # (1 unchanged element hidden)
            }
        )

Which will result in a
Error Updating IAM Role (****) Assume Role Policy: MalformedPolicyDocument: Invalid principal in policy: "SERVICE":"arn:aws:sts::************:assumed-role/OktaRoleFor*****/******@*****.com"

Describe the solution you'd like.

It would be nice to use trusted_entities like so:

trusted_entities = {
  "AWS" = "arn:aws:sts::************:assumed-role/OktaRoleFor*****/******@*****.com"
}

Describe alternatives you've considered.

We don’t find an alternative at this moment, we would appreciate any direction :)

Additional context

Thank you all for your great work on this fabulous module !! 🎉

@milosbackonja
Copy link

@flibustier You could create role and policy separately, and specify role ARN in lambda together with create_role = false

@antonbabenko
Copy link
Member

+1 to what @milosbackonja says.

This module does not support the use-case you describe out-of-the-box because it is less common.

@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 Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants