-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[IAM] Ability to add conditions to AccountPrincipal #5855
Comments
Probably a wrapper principal that adds conditions will be more reusable. |
Thanks Robertd, i'm in teh same situation. ANd this will be very useful. |
Our current modeling of conditions on const role = new iam.Role(this, "role", {
assumedBy: new iam.ServicePrincipal('service-principal.amazonaws.com', {
conditions: {
"string:equals": {
"sts:ExternalId": "<sts-external-id>"
}
}
})
}); I propose we switch the conditional for conditions: {
"sts:ExternalId": {
StringCondition.Equals: "<sts-external-id>"
}
} where |
I see how this is more logical, but it deviates from what people are used to in IAM so I'm not use that'd be a great idea. |
Ok - I originally assumed that there was support for repeated use of the same operator - such as multiple 'StringEquals' - in the conditional. Upon trying this out, it seems I'm mistaken and there can only be one instance of a conditional per policy. I'm ok leaving the structure as is. However, can we still model the conditional more strongly so I don't have to look at the IAM documentation to know the list of conditionals available? |
Closes #5855 Adds a `PrincipalWithConditions` wrapper that allows conditions to be added to any principal. Behaviour is consistent with the way that `PolicyStatement.addCondition` and `.addConditions` currently work - most notably in that adding an operator that is already present will merge their objects, but adding a condition to an operator/key combination that is already set will overwrite the existing value (rather than merge the values into an array). BREAKING CHANGES: every place an IAM Condition was expected it is now typed as `{[key: string]: any}`, instead of plain `any`. You were always supposed to pass a map/dictionary in these locations, but the type system didn't enforce it. It now does. This will not impact correct programs, but may cause compiler errors in programs that were incorrect.
Closes aws#5855 Adds a `PrincipalWithConditions` wrapper that allows conditions to be added to any principal. Behaviour is consistent with the way that `PolicyStatement.addCondition` and `.addConditions` currently work - most notably in that adding an operator that is already present will merge their objects, but adding a condition to an operator/key combination that is already set will overwrite the existing value (rather than merge the values into an array). BREAKING CHANGES: every place an IAM Condition was expected it is now typed as `{[key: string]: any}`, instead of plain `any`. You were always supposed to pass a map/dictionary in these locations, but the type system didn't enforce it. It now does. This will not impact correct programs, but may cause compiler errors in programs that were incorrect.
It'd be great if we can add conditions to
AccountPrincipal
when creatingiam.Role
. Currently,AccountPrincipal
only acceptsaccountId
param. We're creating an iam role for 3rd party SaaS and we need to provide aCondition
property.Other
Current workaround is using
addPropertyOverride
.This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: