Skip to content

Commit

Permalink
Merge branch 'master' into benisrae/construct-instead-of-node
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 10, 2020
2 parents e7283cd + bd45f34 commit ebe60d9
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ yarn-error.log
# Parcel default cache directory
.parcel-cache

# Cloud9
.c9
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-efs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fileSystem.connections.allowDefaultPortFrom(instance);

In order to automatically mount this file system during instance launch,
following code can be used as reference:
```
```ts
const vpc = new ec2.Vpc(this, 'VPC');

const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
Expand Down
14 changes: 6 additions & 8 deletions packages/@aws-cdk/aws-efs/lib/efs-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ export enum LifecyclePolicy {
/**
* After 7 days of not being accessed.
*/
AFTER_7_DAYS,
AFTER_7_DAYS = 'AFTER_7_DAYS',

/**
* After 14 days of not being accessed.
*/
AFTER_14_DAYS,
AFTER_14_DAYS = 'AFTER_14_DAYS',

/**
* After 30 days of not being accessed.
*/
AFTER_30_DAYS,
AFTER_30_DAYS = 'AFTER_30_DAYS',

/**
* After 60 days of not being accessed.
*/
AFTER_60_DAYS,
AFTER_60_DAYS = 'AFTER_60_DAYS',

/**
* After 90 days of not being accessed.
*/
AFTER_90_DAYS
AFTER_90_DAYS = 'AFTER_90_DAYS'
}

/**
Expand Down Expand Up @@ -247,9 +247,7 @@ export class FileSystem extends Resource implements IFileSystem {
const filesystem = new CfnFileSystem(this, 'Resource', {
encrypted: props.encrypted,
kmsKeyId: (props.kmsKey ? props.kmsKey.keyId : undefined),
lifecyclePolicies: (props.lifecyclePolicy ? Array.of({
transitionToIa: LifecyclePolicy[props.lifecyclePolicy],
} as CfnFileSystem.LifecyclePolicyProperty) : undefined),
lifecyclePolicies: (props.lifecyclePolicy ? [{ transitionToIa: props.lifecyclePolicy }] : undefined),
performanceMode: props.performanceMode,
throughputMode: props.throughputMode,
provisionedThroughputInMibps: props.provisionedThroughputPerSecond?.toMebibytes(),
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ test('encrypted file system is created correctly with custom KMS', () => {
}));
});

test('file system is created correctly with life cycle property', () => {
test('file system is created correctly with a life cycle property', () => {
// WHEN
new FileSystem(stack, 'EfsFileSystem', {
vpc,
lifecyclePolicy: LifecyclePolicy.AFTER_14_DAYS,
lifecyclePolicy: LifecyclePolicy.AFTER_7_DAYS,
});
// THEN
expectCDK(stack).to(haveResource('AWS::EFS::FileSystem', {
LifecyclePolicies: [{
TransitionToIA: 'AFTER_14_DAYS',
TransitionToIA: 'AFTER_7_DAYS',
}],
}));
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as path from 'path';
import * as cfn from '@aws-cdk/aws-cloudformation';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as cpactions from '@aws-cdk/aws-codepipeline-actions';
import * as events from '@aws-cdk/aws-events';
import * as iam from '@aws-cdk/aws-iam';
import { Arn, Construct, Fn, Stack } from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import * as path from 'path';
import { appOf, assemblyBuilderOf } from '../private/construct-internals';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export class PublishAssetsAction extends Construct implements codepipeline.IActi

const project = new codebuild.PipelineProject(this, 'Default', {
projectName: this.props.projectName,
environment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_4_0,
privileged: (props.assetType === AssetType.DOCKER_IMAGE) ? true : undefined,
},
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand All @@ -92,8 +96,6 @@ export class PublishAssetsAction extends Construct implements codepipeline.IActi
},
},
}),
// Needed to perform Docker builds
environment: props.assetType === AssetType.DOCKER_IMAGE ? { privileged: true } : undefined,
role: props.role,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class UpdatePipelineAction extends Construct implements codepipeline.IAct

const selfMutationProject = new codebuild.PipelineProject(this, 'SelfMutation', {
projectName: props.projectName,
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_4_0 },
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/pipelines/lib/private/asset-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// FIXME: copied from `ckd-assets`, because this tool needs to read the asset manifest aswell.
import { AssetManifest, DockerImageDestination, DockerImageSource, FileDestination, FileSource, Manifest } from '@aws-cdk/cloud-assembly-schema';
import * as fs from 'fs';
import * as path from 'path';
import { AssetManifest, DockerImageDestination, DockerImageSource, FileDestination, FileSource, Manifest } from '@aws-cdk/cloud-assembly-schema';

/**
* A manifest of assets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Get access to construct internals that we need but got removed from the Stages PR.
*/
import * as path from 'path';
import { App, IConstruct, Stage } from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import * as path from 'path';

export function appOf(construct: IConstruct): App {
const root = construct.node.root;
Expand Down
7 changes: 4 additions & 3 deletions packages/@aws-cdk/pipelines/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ export class CdkStage extends Construct {
if (this._prepared) { return; }
this._prepared = true;

for (const { prepareRunOrder: runOrder, stackArtifact } of this.stacksToDeploy) {
for (const { prepareRunOrder, stackArtifact, executeRunOrder } of this.stacksToDeploy) {
const artifact = this.host.stackOutputArtifact(stackArtifact.id);

this.pipelineStage.addAction(DeployCdkStackAction.fromStackArtifact(this, stackArtifact, {
baseActionName: this.simplifyStackName(stackArtifact.stackName),
cloudAssemblyInput: this.cloudAssemblyArtifact,
output: artifact,
outputFileName: artifact ? 'outputs.json' : undefined,
prepareRunOrder: runOrder,
prepareRunOrder,
executeRunOrder,
}));
}
}
Expand Down Expand Up @@ -387,4 +388,4 @@ interface DeployStackCommand {
prepareRunOrder: number;
executeRunOrder: number;
stackArtifact: cxapi.CloudFormationStackArtifact;
}
}
6 changes: 3 additions & 3 deletions packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as path from 'path';
import * as codebuild from '@aws-cdk/aws-codebuild';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions';
import * as events from '@aws-cdk/aws-events';
import { Construct } from '@aws-cdk/core';
import * as path from 'path';
import { cloudAssemblyBuildSpecDir } from '../private/construct-internals';
import { copyEnvironmentVariables, filterEmpty } from './_util';

Expand Down Expand Up @@ -54,7 +54,7 @@ export interface SimpleSynthOptions {
/**
* Build environment to use for CodeBuild job
*
* @default BuildEnvironment.LinuxBuildImage.STANDARD_1_0
* @default BuildEnvironment.LinuxBuildImage.STANDARD_4_0
*/
readonly environment?: codebuild.BuildEnvironment;

Expand Down Expand Up @@ -210,7 +210,7 @@ export class SimpleSynthAction implements codepipeline.IAction {

const project = new codebuild.PipelineProject(scope, 'CdkBuildProject', {
projectName: this.props.projectName ?? this.props.projectName,
environment: this.props.environment,
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_4_0, ...this.props.environment },
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class ShellScriptAction implements codepipeline.IAction {
}

this._project = new codebuild.PipelineProject(scope, 'Project', {
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_4_0 },
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand Down
15 changes: 15 additions & 0 deletions packages/@aws-cdk/pipelines/test/builds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ test.each([['npm'], ['yarn']])('%s build automatically determines artifact base-

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
artifacts: {
Expand All @@ -55,6 +58,9 @@ test.each([['npm'], ['yarn']])('%s build respects subdirectory', (npmYarn) => {

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand All @@ -80,6 +86,9 @@ test.each([['npm'], ['yarn']])('%s assumes no build step by default', (npmYarn)

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand All @@ -106,6 +115,9 @@ test.each([['npm'], ['yarn']])('%s can have its install command overridden', (np

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -141,6 +153,9 @@ test('Standard (NPM) synth can output additional artifacts', () => {

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
artifacts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1087,7 +1087,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1391,7 +1391,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1564,7 +1564,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1594,7 +1594,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -986,7 +986,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1290,7 +1290,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/pipelines/test/pipeline-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ test('command line properly locates assets in subassembly', () => {

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -107,6 +110,7 @@ test('file image asset publishers do not use privilegedmode, have right AssumeRo
},
Environment: objectLike({
PrivilegedMode: false,
Image: 'aws/codebuild/standard:4.0',
}),
});

Expand Down Expand Up @@ -137,6 +141,7 @@ test('docker image asset publishers use privilegedmode, have right AssumeRole',
})),
},
Environment: objectLike({
Image: 'aws/codebuild/standard:4.0',
PrivilegedMode: true,
}),
});
Expand All @@ -161,6 +166,9 @@ test('can control fix/CLI version used in pipeline selfupdate', () => {

// THEN
expect(stack2).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/pipelines/test/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ test('pipeline has self-mutation stage', () => {
});

expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand All @@ -200,6 +203,9 @@ test('selfmutation stage correctly identifies nested assembly of pipeline stack'

// THEN
expect(stackTemplate(nestedPipelineStack)).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:4.0',
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down
Loading

0 comments on commit ebe60d9

Please sign in to comment.