Skip to content

Commit

Permalink
fix(aws-ecr): fix addToResourcePolicy (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
akiym authored and rix0rrr committed Sep 19, 2018
1 parent d182818 commit eadbda5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecr/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Repository extends RepositoryRef {
const resource = new cloudformation.RepositoryResource(this, 'Resource', {
repositoryName: props.repositoryName,
// It says "Text", but they actually mean "Object".
repositoryPolicyText: this.policyDocument,
repositoryPolicyText: new cdk.Token(() => this.policyDocument),
lifecyclePolicy: new cdk.Token(() => this.renderLifecyclePolicy()),
});

Expand Down
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-ecr/test/test.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,30 @@ export = {
'Fn::ImportValue': 'RepoRepositoryArn7F2901C9'
});

test.done();
},

'resource policy'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const repo = new ecr.Repository(stack, 'Repo');

// WHEN
repo.addToResourcePolicy(new cdk.PolicyStatement().addAction('*'));

// THEN
expect(stack).to(haveResource('AWS::ECR::Repository', {
RepositoryPolicyText: {
Statement: [
{
Action: "*",
Effect: "Allow"
}
],
Version: "2012-10-17"
},
}));

test.done();
}
};

0 comments on commit eadbda5

Please sign in to comment.