Skip to content

Commit

Permalink
Fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed May 3, 2024
1 parent 98406ba commit e457942
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 34 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 @@ -103,11 +103,30 @@
"Arn"
]
},
"Id": "OnEventTargetLambda"
"Id": "Target0"
}
]
}
},
"RepoOnEventOnEventTargetLambdaAllowEventRuleawsecrintegstackLambdaFunctionB6045AA7FBA3AA33": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"LambdaFunctionBF21E41F",
"Arn"
]
},
"Principal": "events.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": [
"RepoOnEventOnEventTargetLambda2934FA99",
"Arn"
]
}
}
},
"LambdaFunctionServiceRoleC555A460": {
"Type": "AWS::IAM::Role",
"Properties": {
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.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as ecr from 'aws-cdk-lib/aws-ecr';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-ecr-integ-stack');
Expand Down Expand Up @@ -30,15 +31,14 @@ new cdk.CfnOutput(stack, 'RepositoryURI', {
});

const repoOnEvent = new ecr.Repository(stack, 'RepoOnEvent');
const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', {
const lambdaHandler = new lambda.Function(stack, 'LambdaFunction', {
runtime: lambda.Runtime.PYTHON_3_12,
code: lambda.Code.fromInline('# dummy func'),
handler: 'index.handler',
});

repoOnEvent.onEvent('OnEventTargetLambda', {
target: {
bind: () => ({ arn: lambdaFunction.functionArn, id: 'OnEventTargetLambda' }),
},
target: new LambdaFunction(lambdaHandler),
});

new IntegTest(app, 'cdk-ecr-integ-test-basic', {
Expand Down
6 changes: 2 additions & 4 deletions packages/aws-cdk-lib/aws-ecr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,13 @@ You can publish repository events to a CloudWatch event rule with `onEvent`:
import * as lambda from 'aws-cdk-lib/aws-lambda';

const repo = new ecr.Repository(this, 'Repo');
const lambdaFunction = new lambda.Function(this, 'LambdaFunction', {
const lambdaHandler = new lambda.Function(this, 'LambdaFunction', {
runtime: lambda.Runtime.PYTHON_3_12,
code: lambda.Code.fromInline('# dummy func'),
handler: 'index.handler',
});

repo.onEvent('OnEventTargetLambda', {
target: {
bind: () => ({ arn: lambdaFunction.functionArn, id: 'OnEventTargetLambda' }),
},
target: new LambdaFunction(lambdaHandler),
});
```

0 comments on commit e457942

Please sign in to comment.