Skip to content

Commit

Permalink
fix(s3): Runtime modernization of notifications-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
watany-dev committed Dec 2, 2022
1 parent b1d8d08 commit 415f08f
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 32 deletions.
Expand Up @@ -98,7 +98,7 @@ export class NotificationsResourceHandler extends Construct {
Code: { ZipFile: handlerSourceWithoutComments },
Handler: 'index.handler',
Role: this.role.roleArn,
Runtime: 'python3.7',
Runtime: 'python3.9',
Timeout: 300,
},
});
Expand Down
@@ -1,15 +1,15 @@
{
"version": "20.0.0",
"version": "22.0.0",
"files": {
"61a3a9ee337bb9ad72389718da2aff2589bcadc056e4a5a942c4ef95ad60c38f": {
"0950e270b55171f331f16b0a63f107106782d89c7816c2ec3ba14a69c11be52d": {
"source": {
"path": "aws-cdk-s3-notifications.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "61a3a9ee337bb9ad72389718da2aff2589bcadc056e4a5a942c4ef95ad60c38f.json",
"objectKey": "0950e270b55171f331f16b0a63f107106782d89c7816c2ec3ba14a69c11be52d.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -89,7 +89,7 @@
"Arn"
]
},
"Runtime": "python3.7",
"Runtime": "python3.9",
"Timeout": 300
},
"DependsOn": [
Expand Down
@@ -1 +1 @@
{"version":"20.0.0"}
{"version":"22.0.0"}
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "22.0.0",
"testCases": {
"integ.bucket.notifications": {
"stacks": [
Expand Down
@@ -1,12 +1,6 @@
{
"version": "20.0.0",
"version": "22.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"aws-cdk-s3-notifications.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/61a3a9ee337bb9ad72389718da2aff2589bcadc056e4a5a942c4ef95ad60c38f.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0950e270b55171f331f16b0a63f107106782d89c7816c2ec3ba14a69c11be52d.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -83,6 +77,12 @@
]
},
"displayName": "aws-cdk-s3-notifications"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Expand Up @@ -4,14 +4,6 @@
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
}
},
"aws-cdk-s3-notifications": {
"id": "aws-cdk-s3-notifications",
"path": "aws-cdk-s3-notifications",
Expand Down Expand Up @@ -40,14 +32,14 @@
"id": "Resource",
"path": "aws-cdk-s3-notifications/MyEventBridgeBucket/Notifications/Resource",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"fqn": "@aws-cdk/core.CfnResource",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.168"
}
}
},
Expand All @@ -64,6 +56,14 @@
"id": "Role",
"path": "aws-cdk-s3-notifications/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role",
"children": {
"ImportRole": {
"id": "ImportRole",
"path": "aws-cdk-s3-notifications/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/ImportRole",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "aws-cdk-s3-notifications/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/Resource",
Expand Down Expand Up @@ -152,26 +152,50 @@
"id": "Resource",
"path": "aws-cdk-s3-notifications/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Resource",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"fqn": "@aws-cdk/core.CfnResource",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.168"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "aws-cdk-s3-notifications/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "aws-cdk-s3-notifications/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.168"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"fqn": "@aws-cdk/core.App",
"version": "0.0.0"
}
}
}
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-s3/test/notification.test.ts
Expand Up @@ -164,4 +164,25 @@ describe('notification', () => {
},
});
});
test('check notifications handler runtime version', () => {
const stack = new cdk.Stack();

const importedRole = iam.Role.fromRoleArn(stack, 'role', 'arn:aws:iam::111111111111:role/DevsNotAllowedToTouch');

const bucket = s3.Bucket.fromBucketAttributes(stack, 'MyBucket', {
bucketName: 'foo-bar',
notificationsHandlerRole: importedRole,
});

bucket.addEventNotification(s3.EventType.OBJECT_CREATED, {
bind: () => ({
arn: 'ARN',
type: s3.BucketNotificationDestinationType.TOPIC,
}),
});

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Runtime: 'python3.9',
});
});
});

0 comments on commit 415f08f

Please sign in to comment.