-
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
feat(iam): customer managed policies #3578
Merged
mergify
merged 12 commits into
aws:master
from
IainCole:ic_support_customer_managed_policy
Aug 9, 2019
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d6c364c
Support creation of customer managed policies
IainCole 3b5f803
Make ManagedPolicy changes pass build
IainCole 2b31d3d
Add tests and make policy stuff work with users, groups and roles
IainCole a19a83d
Merge branch 'master' into ic_support_customer_managed_policy
IainCole 4fb8111
fix call to generatePolicyName from ManagedPolicy after merge from ma…
IainCole 26ad422
Fix implementation of ManagedPolicy and add integ test
IainCole 21866c6
Revert test.role.ts to its original form
IainCole 988a878
Remove unnecessary Lazy.stringValue
IainCole d43480e
Allow adding parameters to previously unused constructor
rix0rrr 8f944f7
Fix policy naming
rix0rrr ccd522c
Fix tests
rix0rrr ffe5f81
Merge branch 'master' into ic_support_customer_managed_policy
rix0rrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
change-return-type:@aws-cdk/core.Fn.getAtt | ||
new-argument:@aws-cdk/aws-iam.ManagedPolicy.<initializer> | ||
new-argument:@aws-cdk/aws-iam.ManagedPolicy.<initializer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/@aws-cdk/aws-iam/test/integ.managed-policy.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"Resources": { | ||
"MyUserDC45028B": { | ||
"Type": "AWS::IAM::User", | ||
"Properties": { | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Ref": "TwoManagedPolicy7E701864" | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/SecurityAudit" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"OneManagedPolicy77F9185F": { | ||
"Type": "AWS::IAM::ManagedPolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sqs:SendMessage", | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Description": "My Policy", | ||
"ManagedPolicyName": "Default", | ||
"Path": "/some/path/", | ||
"Users": [ | ||
{ | ||
"Ref": "MyUserDC45028B" | ||
} | ||
] | ||
} | ||
}, | ||
"TwoManagedPolicy7E701864": { | ||
"Type": "AWS::IAM::ManagedPolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "lambda:InvokeFunction", | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Description": "", | ||
"Path": "/" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { App, Stack } from "@aws-cdk/core"; | ||
import { ManagedPolicy, PolicyStatement } from "../lib"; | ||
import { User } from "../lib/user"; | ||
|
||
const app = new App(); | ||
|
||
const stack = new Stack(app, 'aws-cdk-iam-managed-policy'); | ||
|
||
const user = new User(stack, 'MyUser'); | ||
|
||
const policy = new ManagedPolicy(stack, 'OneManagedPolicy', { | ||
managedPolicyName: 'Default', | ||
description: 'My Policy', | ||
path: '/some/path/', | ||
}); | ||
policy.addStatements(new PolicyStatement({ resources: ['*'], actions: ['sqs:SendMessage'] })); | ||
policy.attachToUser(user); | ||
|
||
const policy2 = new ManagedPolicy(stack, 'TwoManagedPolicy'); | ||
policy2.addStatements(new PolicyStatement({ resources: ['*'], actions: ['lambda:InvokeFunction'] })); | ||
user.addManagedPolicy(policy2); | ||
|
||
const policy3 = ManagedPolicy.fromAwsManagedPolicyName('SecurityAudit'); | ||
user.addManagedPolicy(policy3); | ||
|
||
app.synth(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we really need a way to add comments here