-
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(appconfig): add grantReadConfig method to Environment Construct #30180
Conversation
*/ | ||
grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant; | ||
|
||
/** TODO |
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.
I guess this TODO can be removed?
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.
@daschaa
Oops...sorry, I removed it.
@@ -78,6 +78,24 @@ new appconfig.Environment(this, 'MyEnvironment', { | |||
Environment monitors also support L1 `CfnEnvironment.MonitorsProperty` constructs through the `fromCfnMonitorsProperty` method. | |||
However, this is not the recommended approach for CloudWatch alarms because a role will not be auto-generated if not provided. | |||
|
|||
See [About the AWS AppConfig data plane service](https://docs.aws.amazon.com/appconfig/latest/userguide/about-data-plane.html) more information. |
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.
*for more information
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.
@daschaa
Thank you for your review.
I added for
.
|
||
### Permissions | ||
|
||
You can grant read configuration permission on an Environment to any Principal as follows: |
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 sounds a bit raw to me. Maybe: You can grant permissions to read a configuration to an Environment with the grantReadConfig
method as follows:
What do you think?
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.
@daschaa
I think your suggestion is better.
I edited it.
|
||
/** | ||
* Grants read configuration permissions for this environment | ||
* to an IAM principal (Role/Group/User). |
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.
Is the Grantable
interface === IAM principal? Or is it even broader?
Are other docstrings for grant methods also describing this in this way?
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.
@daschaa
From my understanding, the Grantable interface === IAM principal.
I have revised the explanation referring to the documentation of the grant method of the DynamoDB Table v2 Construct.
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.
@mazyu36 Awesome! Thank you very much for the explanation!
* Adds an IAM policy statement associated with this environment to an IAM principal's policy. | ||
* | ||
* @param grantee the principal (no-op if undefined) | ||
* @param actions the set of actions to allow (i.e., 'appconfig:GetLatestConfiguration', 'appconfig:StartConfigurationSession', etc.) |
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.
I think the comma after i.e. can be removed, right? 🤔
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.
@daschaa
I'm adding a comma (,) to align with the descriptions for DynamoDB.
* @param actions the set of actions to allow (i.e., 'dynamodb:PutItem', 'dynamodb:GetItem', etc.) |
@mazyu36 Thank you very much for the pull requests and sorry for the back and forth with the docstrings. |
return iam.Grant.addToPrincipal({ | ||
grantee, | ||
actions, | ||
resourceArns: [`${this.environmentArn}/*`], |
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.
I'm not too familiar with appconfig usage. Any document supporting that this is the correct arns and least privilege?
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.
Thank you for your comment.
Upon reviewing it again, I found that the scope of the resourcesArn
for grantReadConfig
was too broad, so I made a modification (added /configuration/
).
In AppConfig, a Configuration Profile represents a parameter (e.g., a Feature Flag), and an Environment represents a logical group of deployed Configuration Profiles. (docs)
The ARN of a Configuration belonging to an Environment takes the following format. (docs)
arn:${Partition}:appconfig:${Region}:${Account}:application/${ApplicationId}/environment/${EnvironmentId}/configuration/${ConfigurationProfileId}
For this issue, I wanted to grant read permission for the parameters (Configurations) belonging to a logical group (Environment), so I needed to use a wildcard for /configuration/
and beyond, as I realized.
Previously, the wildcard was applied from /${EnvironmentId}/
onward, which was too broad in scope.
Regarding the grant
method, I changed it to limit the resources to the Environment only.
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.
LGTM in general, just one question regarding permission.
@@ -3,13 +3,13 @@ | |||
|
|||
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. | |||
|
|||
For a high level overview of what AWS AppConfig is and how it works, please take a look here: |
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.
Nice, thanks for removing the whitespaces.
Co-authored-by: GZ <hz351086153@gmail.com>
@GavinZZ |
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.
LGTM, thanks for contributing!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…ws#30180) ### Issue # (if applicable) Closes aws#28585 ### Reason for this change To simplify policy configuration for AppConfig Environments. ### Description of changes add grantReadConfig method to Environment Construct ### Description of how you validated changes Add unit test and integ tests ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ws#30180) ### Issue # (if applicable) Closes aws#28585 ### Reason for this change To simplify policy configuration for AppConfig Environments. ### Description of changes add grantReadConfig method to Environment Construct ### Description of how you validated changes Add unit test and integ tests ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one. |
Issue # (if applicable)
Closes #28585
Reason for this change
To simplify policy configuration for AppConfig Environments.
Description of changes
add grantReadConfig method to Environment Construct
Description of how you validated changes
Add unit test and integ tests
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license