Skip to content

Commit

Permalink
chore(lambda-event-sources): fix broken integ tests (aws#19694)
Browse files Browse the repository at this point in the history
----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
corymhall authored Apr 2, 2022
1 parent 5fadacc commit a298297
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
]
},
"Handler": "index.handler",
"Runtime": "nodejs10.x"
"Runtime": "nodejs14.x"
},
"DependsOn": [
"FServiceRoleDefaultPolicy17A19BFA",
Expand All @@ -99,8 +99,8 @@
"StreamArn"
]
},
"TumblingWindowInSeconds": 60,
"StartingPosition": "TRIM_HORIZON"
"StartingPosition": "TRIM_HORIZON",
"TumblingWindowInSeconds": 60
}
},
"TD925BC7E": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
]
},
"Handler": "index.handler",
"Runtime": "nodejs10.x"
"Runtime": "nodejs14.x"
},
"DependsOn": [
"FServiceRoleDefaultPolicy17A19BFA",
Expand Down
194 changes: 188 additions & 6 deletions packages/@aws-cdk/aws-lambda-event-sources/test/integ.s3.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,95 @@
]
},
"Handler": "index.handler",
"Runtime": "nodejs10.x"
"Runtime": "nodejs14.x"
},
"DependsOn": [
"FServiceRole3AC82EE1"
]
},
"B08E7C7AF": {
"Type": "AWS::S3::Bucket",
"Properties": {
"Tags": [
{
"Key": "aws-cdk:auto-delete-objects",
"Value": "true"
}
]
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"BPolicy3F02723E": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": {
"Ref": "B08E7C7AF"
},
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:DeleteObject*",
"s3:GetBucket*",
"s3:List*"
],
"Effect": "Allow",
"Principal": {
"AWS": {
"Fn::GetAtt": [
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
"Arn"
]
}
},
"Resource": [
{
"Fn::GetAtt": [
"B08E7C7AF",
"Arn"
]
},
{
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"B08E7C7AF",
"Arn"
]
},
"/*"
]
]
}
]
}
],
"Version": "2012-10-17"
}
}
},
"BAutoDeleteObjectsCustomResource6224D839": {
"Type": "Custom::S3AutoDeleteObjects",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F",
"Arn"
]
},
"BucketName": {
"Ref": "B08E7C7AF"
}
},
"DependsOn": [
"BPolicy3F02723E"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"BNotificationsEB8DA980": {
"Type": "Custom::S3BucketNotifications",
"Properties": {
Expand Down Expand Up @@ -93,11 +176,6 @@
"BAllowBucketNotificationsTolambdaeventsources3F741608059EF9F709"
]
},
"B08E7C7AF": {
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"BAllowBucketNotificationsTolambdaeventsources3F741608059EF9F709": {
"Type": "AWS::Lambda::Permission",
"Properties": {
Expand All @@ -120,6 +198,96 @@
}
}
},
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
]
},
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
]
}
},
"CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE"
}
]
}
]
}
]
]
}
},
"Timeout": 900,
"MemorySize": 128,
"Handler": "__entrypoint__.handler",
"Role": {
"Fn::GetAtt": [
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
"Arn"
]
},
"Runtime": "nodejs12.x",
"Description": {
"Fn::Join": [
"",
[
"Lambda function for auto-deleting objects in ",
{
"Ref": "B08E7C7AF"
},
" S3 bucket."
]
]
}
},
"DependsOn": [
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092"
]
},
"BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -194,5 +362,19 @@
"BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC"
]
}
},
"Parameters": {
"AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232": {
"Type": "String",
"Description": "S3 bucket for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\""
},
"AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE": {
"Type": "String",
"Description": "S3 key for asset version \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\""
},
"AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824ArtifactHash76F8FCF2": {
"Type": "String",
"Description": "Artifact hash for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class S3EventSourceTest extends cdk.Stack {
const fn = new TestFunction(this, 'F');
const bucket = new s3.Bucket(this, 'B', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
});

fn.addEventSource(new S3EventSource(bucket, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
]
},
"Handler": "index.handler",
"Runtime": "nodejs10.x"
"Runtime": "nodejs14.x"
},
"DependsOn": [
"FServiceRole3AC82EE1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
]
},
"Handler": "index.handler",
"Runtime": "nodejs10.x"
"Runtime": "nodejs14.x"
},
"DependsOn": [
"FServiceRoleDefaultPolicy17A19BFA",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class TestFunction extends lambda.Function {
super(scope, id, {
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${handler.toString()}`),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});
}
}
Expand Down

0 comments on commit a298297

Please sign in to comment.