Skip to content

Commit b408d78

Browse files
committed
Add the default amplify policy to the autogenerated role
1 parent 88decc6 commit b408d78

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Diff for: packages/@aws-cdk/aws-amplify-alpha/lib/app.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export interface AppProps {
155155
* The IAM service role to associate with the application. The App
156156
* implements IGrantable.
157157
*
158-
* @default - a new role is created
158+
* @default - a new role is created with the AdministratorAccess-Amplify managed policy attached
159159
*/
160160
readonly role?: iam.IRole;
161161

@@ -224,6 +224,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
224224

225225
const role = props.role || new iam.Role(this, 'Role', {
226226
assumedBy: new iam.ServicePrincipal('amplify.amazonaws.com'),
227+
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess-Amplify')],
227228
});
228229
this.grantPrincipal = role;
229230

@@ -239,7 +240,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
239240
buildSpec: props.autoBranchCreation.buildSpec && props.autoBranchCreation.buildSpec.toBuildSpec(),
240241
enableAutoBranchCreation: true,
241242
enableAutoBuild: props.autoBranchCreation.autoBuild ?? true,
242-
environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables ) }, { omitEmptyArray: true }), // eslint-disable-line max-len
243+
environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables) }, { omitEmptyArray: true }), // eslint-disable-line max-len
243244
enablePullRequestPreview: props.autoBranchCreation.pullRequestPreview ?? true,
244245
pullRequestEnvironmentName: props.autoBranchCreation.pullRequestEnvironmentName,
245246
stage: props.autoBranchCreation.stage,

Diff for: packages/@aws-cdk/aws-amplify-alpha/test/app.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ test('create an app connected to a GitLab repository', () => {
113113
],
114114
Version: '2012-10-17',
115115
},
116+
ManagedPolicyArns: [
117+
{
118+
'Fn::Join': [
119+
'',
120+
[
121+
'arn:',
122+
{
123+
Ref: 'AWS::Partition',
124+
},
125+
':iam::aws:policy/AdministratorAccess-Amplify',
126+
],
127+
],
128+
},
129+
],
130+
116131
});
117132
});
118133

0 commit comments

Comments
 (0)