Skip to content

Commit

Permalink
Merge pull request #4 from awslabs/master
Browse files Browse the repository at this point in the history
Update from upstream
  • Loading branch information
ScOut3R authored Jun 13, 2019
2 parents 3a84384 + b80ef04 commit f680247
Show file tree
Hide file tree
Showing 142 changed files with 3,628 additions and 1,081 deletions.
2 changes: 2 additions & 0 deletions .gitallowed
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The only AWS account number allowed to be used in tests (used by git-secrets)
account = '123456789012';
# account used for cross-environment tests in addition to the one above
account: '234567890123'
# Account patterns used in the README
account: '000000000000'
account: '111111111111'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
constructor(scope: cdk.Construct, id: string, props: PipelineDeployStackActionProps) {
super(scope, id);

if (!cdk.environmentEquals(props.stack.env, cdk.Stack.of(this).env)) {
if (props.stack.environment !== cdk.Stack.of(this).environment) {
// FIXME: Add the necessary to extend to stacks in a different account
throw new Error(`Cross-environment deployment is not supported`);
}
Expand All @@ -125,8 +125,8 @@ export class PipelineDeployStackAction extends cdk.Construct {
actionName: 'ChangeSet',
changeSetName,
runOrder: createChangeSetRunOrder,
stackName: props.stack.name,
templatePath: props.input.atPath(`${props.stack.name}.template.yaml`),
stackName: props.stack.stackName,
templatePath: props.input.atPath(`${props.stack.stackName}.template.yaml`),
adminPermissions: props.adminPermissions,
deploymentRole: props.role,
capabilities,
Expand All @@ -136,7 +136,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
actionName: 'Execute',
changeSetName,
runOrder: executeChangeSetRunOrder,
stackName: props.stack.name,
stackName: props.stack.stackName,
}));

this.deploymentRole = changeSetAction.deploymentRole;
Expand All @@ -160,7 +160,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
const assets = this.stack.node.metadata.filter(md => md.type === cxapi.ASSET_METADATA);
if (assets.length > 0) {
// FIXME: Implement the necessary actions to publish assets
result.push(`Cannot deploy the stack ${this.stack.name} because it references ${assets.length} asset(s)`);
result.push(`Cannot deploy the stack ${this.stack.stackName} because it references ${assets.length} asset(s)`);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/lib/synth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SynthUtils {
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
const root = stack.node.root;
const assembly = ConstructNode.synth(root.node, options);
return assembly.getStack(stack.name);
return assembly.getStack(stack.stackName);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/test/test.assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function synthesizedStack(fn: (stack: cdk.Stack) => void): cx.CloudFormationStac
fn(stack);

const assembly = app.synth();
return assembly.getStack(stack.name);
return assembly.getStack(stack.stackName);
}

interface TestResourceProps extends cdk.CfnResourceProps {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets-docker/lib/adopted-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AdoptedRepository extends ecr.RepositoryBase {
super(scope, id);

const fn = new lambda.SingletonFunction(this, 'Function', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
lambdaPurpose: 'AdoptEcrRepository',
handler: 'handler.handler',
code: lambda.Code.asset(path.join(__dirname, 'adopt-repository')),
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assets/test/test.asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export = {
path: dirPath
});

const synth = app.synth().getStack(stack.name);
const synth = app.synth().getStack(stack.stackName);
const meta = synth.manifest.metadata || {};
test.ok(meta['/my-stack/MyAsset']);
test.ok(meta['/my-stack/MyAsset'][0]);
Expand Down Expand Up @@ -344,7 +344,7 @@ export = {

// WHEN
const session = app.synth();
const artifact = session.getStack(stack.name);
const artifact = session.getStack(stack.stackName);
const metadata = artifact.manifest.metadata || {};
const md = Object.values(metadata)[0]![0]!.data;
test.deepEqual(md.path, 'asset.6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2');
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class LatestDeploymentResource extends CfnDeployment {
constructor(scope: Construct, id: string, props: CfnDeploymentProps) {
super(scope, id, props);

this.originalLogicalId = Stack.of(this).logicalIds.getLogicalId(this);
this.originalLogicalId = Stack.of(this).getLogicalId(this);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/test/integ.restapi.books.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ class BookStack extends cdk.Stack {
super(scope, id);

const booksHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BooksHandler', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${echoHandlerCode}`)
}));

const bookHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BookHandler', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${echoHandlerCode}`)
}));

const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${helloCode}`)
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/integ.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Test extends cdk.Stack {
});

const handler = new lambda.Function(this, 'MyHandler', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
code: lambda.Code.inline(`exports.handler = ${handlerCode}`),
handler: 'index.handler',
});
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/test/test.lambda-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
});

// WHEN
Expand Down Expand Up @@ -78,7 +78,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
});
const alias = new lambda.Alias(stack, 'alias', {
aliasName: 'my-alias',
Expand Down Expand Up @@ -145,7 +145,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
});

// WHEN
Expand Down Expand Up @@ -184,7 +184,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
});

test.throws(() => new apigw.LambdaRestApi(stack, 'lambda-rest-api', {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/test/test.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export = {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
code: lambda.Code.inline('foo'),
handler: 'index.handler'
});
Expand Down Expand Up @@ -106,7 +106,7 @@ export = {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
code: lambda.Code.inline('foo'),
handler: 'index.handler'
});
Expand All @@ -132,7 +132,7 @@ export = {
const api = new apigateway.RestApi(stack, 'test-api');

const handler = new lambda.Function(stack, 'MyFunc', {
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
handler: 'index.handler',
code: lambda.Code.inline(``)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('given an AutoScalingGroup', () => {
// GIVEN
const fn = new lambda.Function(stack, 'Fn', {
code: lambda.Code.inline('foo'),
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
handler: 'index.index',
});

Expand Down
24 changes: 23 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
import iam = require('@aws-cdk/aws-iam');
import sns = require('@aws-cdk/aws-sns');

import { AutoScalingRollingUpdate, Construct, Fn, IResource, Lazy, Resource, Tag } from '@aws-cdk/cdk';
import { AutoScalingRollingUpdate, Construct, Fn, IResource, Lazy, Resource, Stack, Tag } from '@aws-cdk/cdk';
import { CfnAutoScalingGroup, CfnAutoScalingGroupProps, CfnLaunchConfiguration } from './autoscaling.generated';
import { BasicLifecycleHookProps, LifecycleHook } from './lifecycle-hook';
import { BasicScheduledActionProps, ScheduledAction } from './scheduled-action';
Expand Down Expand Up @@ -196,6 +196,7 @@ export interface AutoScalingGroupProps extends CommonAutoScalingGroupProps {
abstract class AutoScalingGroupBase extends Resource implements IAutoScalingGroup {

public abstract autoScalingGroupName: string;
public abstract autoScalingGroupArn: string;
protected albTargetGroup?: elbv2.ApplicationTargetGroup;

/**
Expand Down Expand Up @@ -318,6 +319,11 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
public static fromAutoScalingGroupName(scope: Construct, id: string, autoScalingGroupName: string): IAutoScalingGroup {
class Import extends AutoScalingGroupBase {
public autoScalingGroupName = autoScalingGroupName;
public autoScalingGroupArn = Stack.of(this).formatArn({
service: 'autoscaling',
resource: 'autoScalingGroup:*:autoScalingGroupName',
resourceName: this.autoScalingGroupName
});
}

return new Import(scope, id);
Expand All @@ -343,6 +349,11 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
*/
public readonly autoScalingGroupName: string;

/**
* Arn of the AutoScalingGroup
*/
public readonly autoScalingGroupArn: string;

private readonly userDataLines = new Array<string>();
private readonly autoScalingGroup: CfnAutoScalingGroup;
private readonly securityGroup: ec2.ISecurityGroup;
Expand Down Expand Up @@ -432,6 +443,11 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
this.autoScalingGroup = new CfnAutoScalingGroup(this, 'ASG', asgProps);
this.osType = machineImage.os.type;
this.autoScalingGroupName = this.autoScalingGroup.autoScalingGroupName;
this.autoScalingGroupArn = Stack.of(this).formatArn({
service: 'autoscaling',
resource: 'autoScalingGroup:*:autoScalingGroupName',
resourceName: this.autoScalingGroupName
});

this.applyUpdatePolicies(props);
}
Expand Down Expand Up @@ -707,6 +723,12 @@ export interface IAutoScalingGroup extends IResource {
*/
readonly autoScalingGroupName: string;

/**
* The arn of the AutoScalingGroup
* @attribute
*/
readonly autoScalingGroupArn: string;

/**
* Send a message to either an SQS queue or SNS topic when instances launch or terminate
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DnsValidatedCertificate extends cdk.Resource implements ICertificat
const requestorFunction = new lambda.Function(this, 'CertificateRequestorFunction', {
code: lambda.Code.asset(path.resolve(__dirname, '..', 'lambda-packages', 'dns_validated_certificate_handler', 'lib')),
handler: 'index.certificateRequestHandler',
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.Nodejs810,
timeout: 15 * 60 // 15 minutes
});
requestorFunction.addToRolePolicy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class AwsCustomResource extends cdk.Construct {

const provider = new lambda.SingletonFunction(this, 'Provider', {
code: lambda.Code.asset(path.join(__dirname, 'aws-custom-resource-provider')),
runtime: lambda.Runtime.NodeJS10x,
runtime: lambda.Runtime.Nodejs10x,
handler: 'index.handler',
uuid: '679f53fa-c002-430c-b0da-5b7982bd2287',
lambdaPurpose: 'AWS'
Expand Down
52 changes: 52 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import lambda = require('@aws-cdk/aws-lambda');
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import { CfnDistribution } from './cloudfront.generated';
Expand Down Expand Up @@ -344,6 +345,48 @@ export interface Behavior {
*/
readonly maxTtlSeconds?: number;

/**
* Declares associated lambda@edge functions for this distribution behaviour.
*
* @default No lambda function associated
*/
readonly lambdaFunctionAssociations?: LambdaFunctionAssociation[];

}

export interface LambdaFunctionAssociation {

/**
* The lambda event type defines at which event the lambda
* is called during the request lifecycle
*/
readonly eventType: LambdaEdgeEventType;

/**
* A version of the lambda to associate
*/
readonly lambdaFunction: lambda.IVersion;
}

export enum LambdaEdgeEventType {
/**
* The origin-request specifies the request to the
* origin location (e.g. S3)
*/
OriginRequest = "origin-request",
/**
* The origin-response specifies the response from the
* origin location (e.g. S3)
*/
OriginResponse = "origin-response",
/**
* The viewer-request specifies the incoming request
*/
ViewerRequest = "viewer-request",
/**
* The viewer-response specifies the outgoing reponse
*/
ViewerResponse = "viewer-response",
}

export interface ErrorConfiguration {
Expand Down Expand Up @@ -691,6 +734,15 @@ export class CloudFrontWebDistribution extends cdk.Construct implements IDistrib
if (!input.isDefaultBehavior) {
toReturn = Object.assign(toReturn, { pathPattern: input.pathPattern });
}
if (input.lambdaFunctionAssociations) {
toReturn = Object.assign(toReturn, {
lambdaFunctionAssociations: input.lambdaFunctionAssociations
.map(fna => ({
eventType: fna.eventType,
lambdaFunctionArn: fna.lambdaFunction && fna.lambdaFunction.versionArn,
}))
});
}
return toReturn;
}
}
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@aws-cdk/aws-certificatemanager": "^0.34.0",
"@aws-cdk/aws-iam": "^0.34.0",
"@aws-cdk/aws-kms": "^0.34.0",
"@aws-cdk/aws-lambda": "^0.34.0",
"@aws-cdk/aws-s3": "^0.34.0",
"@aws-cdk/cdk": "^0.34.0"
},
Expand All @@ -82,11 +83,12 @@
"@aws-cdk/aws-certificatemanager": "^0.34.0",
"@aws-cdk/aws-iam": "^0.34.0",
"@aws-cdk/aws-kms": "^0.34.0",
"@aws-cdk/aws-lambda": "^0.34.0",
"@aws-cdk/aws-s3": "^0.34.0",
"@aws-cdk/cdk": "^0.34.0"
},
"engines": {
"node": ">= 8.10.0"
},
"stability": "experimental"
}
}
Loading

0 comments on commit f680247

Please sign in to comment.