-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for AgentPermissions in CloudFormation (Schema + CreateHandler) #10
Add support for AgentPermissions in CloudFormation (Schema + CreateHandler) #10
Conversation
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
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.
Please make sure it is handling the edge case when PG has been created successfully but putPermission failed.
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
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.
Tiniest of tiniest of notes: We usually never end commit titles with "." :)
@@ -16,6 +20,33 @@ | |||
"maxLength": 255, | |||
"pattern": "^[\\w-]+$" | |||
}, | |||
"Permissions": { | |||
"description": "The permissions attached for this profiling group.", |
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.
"description": "The permissions attached for this profiling group.", | |
"description": "The permissions attached to this profiling group.", |
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.
Thanks, I will update.
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"AgentPermissions" | ||
], | ||
"properties": { | ||
"AgentPermissions": { | ||
"type": "object", | ||
"description": "The permissions for the agent.", | ||
"additionalProperties": false, | ||
"required": [ | ||
"Principals" | ||
], | ||
"properties": { | ||
"Principals": { | ||
"description": "The principals for the agent permissions.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/ArnIam" | ||
} | ||
} | ||
} | ||
} |
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.
This structure seems quite deep:
{
"Type": "AWS::CodeGuruProfiler::ProfilingGroup",
"Properties": {
"ProfilingGroupName": "some-profiling-group",
"Permissions": {
"AgentPermissions": {
"Principals": ["...list of principals... "]
}
}
}
}
What do you think of making it a little more flatter by going with
{
"Type": "AWS::CodeGuruProfiler::ProfilingGroup",
"Properties": {
"ProfilingGroupName": "some-profiling-group",
"Permissions": [
{
"ActionGroup": "agentPermissions",
"Principals": ["...list of principals..."]
}
]
}
}
or
{
"Type": "AWS::CodeGuruProfiler::ProfilingGroup",
"Properties": {
"ProfilingGroupName": "some-profiling-group",
"AgentPermissions": {
"Principals": ["...list of principals... "]
}
}
}
?
Cloudformation is already quite verbose, so the more lightweight we can make it, the better :)
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.
Good point, I will update the code with having AgentPermissions
as first-level property, thanks.
@@ -26,7 +57,8 @@ | |||
}, | |||
"additionalProperties": false, | |||
"required": [ | |||
"ProfilingGroupName" | |||
"ProfilingGroupName", | |||
"Permissions" |
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.
This seems potentially problematic -- what happens to existing customers that have cloudformation written without specifying permissions?
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.
It makes sense, I will update then the code for Permissions
to not be required, thanks.
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>bom</artifactId> | ||
<version>2.13.16</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> |
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.
Would be nice to see this change in a separate commit and with an explanation of what it does, so that it would be clear and we could refer to it in the future.
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.
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.
Looking good! I've left a bunch of comments regarding code style and small improvements, and I think we're almost good to go.
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Show resolved
Hide resolved
proxy = mock(AmazonWebServicesClientProxy.class); | ||
logger = mock(Logger.class); | ||
|
||
request = makeValidRequest(); | ||
subject = new CreateHandler(); |
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.
Minor: All of these can be inlined with the filed declaration itself.
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.
Good point, thanks, I will update.
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
...nggroup/src/test/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandlerTest.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
...filinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/CreateHandler.java
Outdated
Show resolved
Hide resolved
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.
Thanks, LGTM 👍
}, | ||
"ArnIam": { | ||
"type": "string", | ||
"pattern": "^arn:aws(-(cn|gov))?:iam::([0-9]{12}):[^.]+$" |
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.
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.
Looking into it in #19
As pointed out by @PatMyron [in this comment](#10 (comment)) our regular expression patterns for validating arns were missing quite a few partitions. I've gone ahead and fixed that, adding tests as well. I also did the following extra changes: * Made the pattern used for ProfilingGroupArns more specific * Tweaked the pattern used for ChannelUri to allow Arns without region
Issue #, if available:
Description of changes:
This includes updates for the schema, to the CreateHandler resource and its related unit test.
Testing was done as suggested in the README.md file. See the screenshots for more details.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.