Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lambda-layers): add AWS SDK JS layer #5077

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-events-targets/lib/aws-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import events = require('@aws-cdk/aws-events');
import iam = require('@aws-cdk/aws-iam');
import lambda = require('@aws-cdk/aws-lambda');
import { Layer } from '@aws-cdk/lambda-layers';
import path = require('path');
import metadata = require('./sdk-api-metadata.json');
import { addLambdaPermission } from './util';
Expand Down Expand Up @@ -87,6 +88,7 @@ export class AwsApi implements events.IRuleTarget {
handler: 'index.handler',
uuid: 'b4cf1abd-4e4f-4bc6-9944-1af7ccd9ec37',
lambdaPurpose: 'AWS',
layers: [Layer.AWS_SDK_JS.getLayerVersion(rule as events.Rule)]
});

if (this.props.policyStatement) {
Expand Down
8 changes: 5 additions & 3 deletions packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"@aws-cdk/aws-sns-subscriptions": "1.16.1",
"@aws-cdk/aws-sqs": "1.16.1",
"@aws-cdk/aws-stepfunctions": "1.16.1",
"@aws-cdk/core": "1.16.1"
"@aws-cdk/core": "1.16.1",
"@aws-cdk/lambda-layers": "1.16.1"
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
Expand All @@ -118,7 +119,8 @@
"@aws-cdk/aws-sns-subscriptions": "1.16.1",
"@aws-cdk/aws-sqs": "1.16.1",
"@aws-cdk/aws-stepfunctions": "1.16.1",
"@aws-cdk/core": "1.16.1"
"@aws-cdk/core": "1.16.1",
"@aws-cdk/lambda-layers": "1.16.1"
},
"engines": {
"node": ">= 10.3.0"
Expand All @@ -135,4 +137,4 @@
"props-default-doc:@aws-cdk/aws-events-targets.EcsTaskProps.containerOverrides"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,53 @@
]
}
},
"layerawssdkjsB2ED5E7B": {
"Type": "AWS::Lambda::LayerVersion",
"Properties": {
"Content": {
"S3Bucket": {
"Ref": "AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3Bucket9111837A"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3VersionKey5C696394"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3VersionKey5C696394"
}
]
}
]
}
]
]
}
},
"CompatibleRuntimes": [
"nodejs10.x"
],
"Description": "AWS SDK JS"
}
},
"AWSb4cf1abd4e4f4bc699441af7ccd9ec37ServiceRole9FFE9C50": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -139,7 +186,12 @@
"Arn"
]
},
"Runtime": "nodejs10.x"
"Runtime": "nodejs10.x",
"Layers": [
{
"Ref": "layerawssdkjsB2ED5E7B"
}
]
},
"DependsOn": [
"AWSb4cf1abd4e4f4bc699441af7ccd9ec37ServiceRoleDefaultPolicy4D43A7C1",
Expand Down Expand Up @@ -219,6 +271,18 @@
}
},
"Parameters": {
"AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3Bucket9111837A": {
"Type": "String",
"Description": "S3 bucket for asset \"1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7\""
},
"AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3VersionKey5C696394": {
"Type": "String",
"Description": "S3 key for asset version \"1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7\""
},
"AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7ArtifactHash24D48A0B": {
"Type": "String",
"Description": "Artifact hash for asset \"1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7\""
},
"AssetParameters7f96a9f879348c0e50ac55d67a74edede0cc96cf0615355938c45801708cd063S3Bucket05714AA7": {
"Type": "String",
"Description": "S3 bucket for asset \"7f96a9f879348c0e50ac55d67a74edede0cc96cf0615355938c45801708cd063\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CustomResource, CustomResourceProvider } from '@aws-cdk/aws-cloudformat
import iam = require('@aws-cdk/aws-iam');
import lambda = require('@aws-cdk/aws-lambda');
import cdk = require('@aws-cdk/core');
import { Layer } from '@aws-cdk/lambda-layers';
import fs = require('fs');
import path = require('path');

Expand Down Expand Up @@ -180,6 +181,7 @@ export class AwsCustomResource extends cdk.Construct implements iam.IGrantable {
lambdaPurpose: 'AWS',
timeout: props.timeout || cdk.Duration.seconds(30),
role: props.role,
layers: [Layer.AWS_SDK_JS.getLayerVersion(this)]
});
this.grantPrincipal = provider.grantPrincipal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,53 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"layerawssdkjsB2ED5E7B": {
"Type": "AWS::Lambda::LayerVersion",
"Properties": {
"Content": {
"S3Bucket": {
"Ref": "AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3Bucket9111837A"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3VersionKey5C696394"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3VersionKey5C696394"
}
]
}
]
}
]
]
}
},
"CompatibleRuntimes": [
"nodejs10.x"
],
"Description": "AWS SDK JS"
}
},
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -153,6 +200,11 @@
]
},
"Runtime": "nodejs10.x",
"Layers": [
{
"Ref": "layerawssdkjsB2ED5E7B"
}
],
"Timeout": 30
},
"DependsOn": [
Expand Down Expand Up @@ -230,6 +282,18 @@
}
},
"Parameters": {
"AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3Bucket9111837A": {
"Type": "String",
"Description": "S3 bucket for asset \"1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7\""
},
"AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7S3VersionKey5C696394": {
"Type": "String",
"Description": "S3 key for asset version \"1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7\""
},
"AssetParameters1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7ArtifactHash24D48A0B": {
"Type": "String",
"Description": "Artifact hash for asset \"1225cfb84ab98458f900aca0912b08536c3fc65797fbc5fa9bea7f85e756a1c7\""
},
"AssetParametersba1b614bb55ac13ae885f2efd32be195ffd984700d9dafcccd3102bdba2f9915S3Bucket7871AF0F": {
"Type": "String",
"Description": "S3 bucket for asset \"ba1b614bb55ac13ae885f2efd32be195ffd984700d9dafcccd3102bdba2f9915\""
Expand Down Expand Up @@ -269,4 +333,4 @@
}
}
}
}
}
17 changes: 17 additions & 0 deletions packages/@aws-cdk/lambda-layers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.js
*.js.map
*.d.ts
node_modules
dist
tsconfig.json
tslint.json
.jsii

.LAST_BUILD
.LAST_PACKAGE
*.snk
.nyc_output
coverage
.nycrc

layers
18 changes: 18 additions & 0 deletions packages/@aws-cdk/lambda-layers/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Don't include original .ts files when doing `npm pack`
*.ts
!*.d.ts
coverage
.nyc_output
*.tgz

dist
.LAST_PACKAGE
.LAST_BUILD
!*.js

# Include .jsii
!.jsii

*.snk

*.tsbuildinfo
Loading