Skip to content

Commit

Permalink
fix: permission changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed May 28, 2024
1 parent 4e9322a commit 1e2ae69
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 46 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{
"Ref": "MyEnvironment465E4DEA"
},
"/*"
"/configuration/*"
]
]
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/aws-cdk-lib/aws-appconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ See [About the AWS AppConfig data plane service](https://docs.aws.amazon.com/app

### Permissions

You can grant permissions to read a configuration to an Environment with the grantReadConfig method as follows:
You can grant read permission on the environment's configurations with the grantReadConfig method as follows:

```ts
import * as iam from 'aws-cdk-lib/aws-iam';

Expand All @@ -92,7 +93,7 @@ const env = new appconfig.Environment(this, 'MyEnvironment', {
});

const user = new iam.User(this, 'MyUser');
env.grantReadConfig(user); // Grant read permission on the environment to the user
env.grantReadConfig(user);
```


Expand Down
19 changes: 11 additions & 8 deletions packages/aws-cdk-lib/aws-appconfig/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,20 @@ abstract class EnvironmentBase extends Resource implements IEnvironment, IExtens
return iam.Grant.addToPrincipal({
grantee,
actions,
resourceArns: [`${this.environmentArn}/*`],
resourceArns: [this.environmentArn],
});
}

public grantReadConfig(grantee: iam.IGrantable) {
return this.grant(grantee,
'appconfig:GetLatestConfiguration',
'appconfig:StartConfigurationSession',
);
public grantReadConfig(identity: iam.IGrantable): iam.Grant {
return iam.Grant.addToPrincipal({
grantee: identity,
actions: [
'appconfig:GetLatestConfiguration',
'appconfig:StartConfigurationSession',
],
resourceArns: [`${this.environmentArn}/configuration/*`],
});
}

}

/**
Expand Down Expand Up @@ -569,7 +572,7 @@ export interface IEnvironment extends IResource {
grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant;

/**
* Permits an IAM principal to perform read operations on this environment's configuration.
* Permits an IAM principal to perform read operations on this environment's configurations.
*
* Actions: GetLatestConfiguration, StartConfigurationSession.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ describe('environment', () => {
{ Ref: 'MyAppConfigB4B63E75' },
'/environment/',
{ Ref: 'MyEnvironment465E4DEA' },
'/*',
'/configuration/*',
]],
},
},
Expand Down

0 comments on commit 1e2ae69

Please sign in to comment.