Skip to content

Commit

Permalink
Merge branch 'master' into refactor/virtualServiceTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Jan 27, 2021
2 parents 575ded5 + 2f6521a commit 93fb617
Show file tree
Hide file tree
Showing 81 changed files with 4,100 additions and 968 deletions.
1 change: 0 additions & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--install.check-files true # install will verify file tree of packages for consistency
ignore-engines true # the 'engines' key for 'aws-cdk-lib' has specifies node14 as min while v1 will remain at node10
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.87.0](https://github.com/aws/aws-cdk/compare/v1.86.0...v1.87.0) (2021-01-27)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **s3-deployment:** User metadata keys of bucket objects will change from `x-amz-meta-x-amz-meta-x-amzn-meta-mykey` to `x-amz-meta-mykey`.
* **core:** users of modern synthesis (`DefaultSynthesizer`,
used by CDK Pipelines) must upgrade their bootstrap stacks. Run `cdk bootstrap`.

### Features

* **aws-codebuild:** add `enableBatchBuilds()` to Project ([#12531](https://github.com/aws/aws-cdk/issues/12531)) ([0568390](https://github.com/aws/aws-cdk/commit/05683907d6ffc9ab12b6744c1b59b0df096789e1))
* **aws-codepipeline-actions:** Add Full Clone support for CodeCommit ([#12558](https://github.com/aws/aws-cdk/issues/12558)) ([d169688](https://github.com/aws/aws-cdk/commit/d169688f35bc78c88c44ff9a7d8fa0dfea71f904)), closes [#12236](https://github.com/aws/aws-cdk/issues/12236)
* **batch:** Compute Resources placement group ([#12203](https://github.com/aws/aws-cdk/issues/12203)) ([fe37174](https://github.com/aws/aws-cdk/commit/fe37174ec29b7d3b60b252df08ceecf1aa057098))
* **eks:** Graduate to stable ([#12640](https://github.com/aws/aws-cdk/issues/12640)) ([b5ba7cd](https://github.com/aws/aws-cdk/commit/b5ba7cdd61714bcfbf2135240790340a77ee1a8b))
* **stepfunctions-tasks:** EcsRunTask now uses taskDefinition family instead of ARN ([#12436](https://github.com/aws/aws-cdk/issues/12436)) ([abde96b](https://github.com/aws/aws-cdk/commit/abde96b046358fc5435545692eba4fd63d503914)), closes [#12080](https://github.com/aws/aws-cdk/issues/12080)
* **stepfunctions-tasks:** support databrew startJobRun task ([#12532](https://github.com/aws/aws-cdk/issues/12532)) ([eacd2f7](https://github.com/aws/aws-cdk/commit/eacd2f7ea67c83d50c839acf29fbe953ae49d987))


### Bug Fixes

* **apigatewayv2:** multiple http integrations are created for each route ([#12528](https://github.com/aws/aws-cdk/issues/12528)) ([855ce59](https://github.com/aws/aws-cdk/commit/855ce59039a577d142d68720e86d81610edffc64)), closes [40aws-cdk/aws-apigatewayv2/lib/http/route.ts#L128](https://github.com/40aws-cdk/aws-apigatewayv2/lib/http/route.ts/issues/L128)
* **core:** modern deployments fail if bootstrap stack is renamed ([#12594](https://github.com/aws/aws-cdk/issues/12594)) ([e5c616f](https://github.com/aws/aws-cdk/commit/e5c616f73eac395492636341f57fb6a716d1ea69)), closes [#11952](https://github.com/aws/aws-cdk/issues/11952) [#11420](https://github.com/aws/aws-cdk/issues/11420) [#9053](https://github.com/aws/aws-cdk/issues/9053)
* **pipelines:** assets broken in Pipelines synthesized from Windows ([#12573](https://github.com/aws/aws-cdk/issues/12573)) ([5c3dce5](https://github.com/aws/aws-cdk/commit/5c3dce56c71083321069a31213aaa5bce40f51d3)), closes [#12540](https://github.com/aws/aws-cdk/issues/12540)
* **pipelines:** can't use CodePipeline variables in Synth environment variables ([#12602](https://github.com/aws/aws-cdk/issues/12602)) ([736b260](https://github.com/aws/aws-cdk/commit/736b260db7f21d89e220591007580f62b22fea3a)), closes [#12061](https://github.com/aws/aws-cdk/issues/12061) [#11178](https://github.com/aws/aws-cdk/issues/11178)
* **pipelines:** unable to publish assets inside VPC ([#12331](https://github.com/aws/aws-cdk/issues/12331)) ([a16f09c](https://github.com/aws/aws-cdk/commit/a16f09c9ea675caf5b1e50a4e1cc288e5afd1237)), closes [#11815](https://github.com/aws/aws-cdk/issues/11815)
* **s3-deployment:** User metadata keys have redundant triple `x-amz` prefix ([#12414](https://github.com/aws/aws-cdk/issues/12414)) ([6716181](https://github.com/aws/aws-cdk/commit/671618152dc585ef0703f6c3501f6ee5a366b4a9)), closes [#8459](https://github.com/aws/aws-cdk/issues/8459)
* **secretsmanager:** fromSecretPartialArn() has incorrect grant policies ([#12665](https://github.com/aws/aws-cdk/issues/12665)) ([560915e](https://github.com/aws/aws-cdk/commit/560915ece87a919f499a64452b919a0b291394ee)), closes [#12411](https://github.com/aws/aws-cdk/issues/12411)

## [1.86.0](https://github.com/aws/aws-cdk/compare/v1.85.0...v1.86.0) (2021-01-21)


Expand Down
7 changes: 4 additions & 3 deletions packages/@aws-cdk/aws-apigateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,10 @@ new apigateway.RestApi(this, 'books', {
deployOptions: {
accessLogDestination: new apigateway.LogGroupLogDestination(logGroup),
accessLogFormat: apigateway.AccessLogFormat.custom(
`${AccessLogFormat.contextRequestId()} ${AccessLogField.contextErrorMessage()} ${AccessLogField.contextErrorMessageString()}`);
})
};
`${AccessLogField.contextRequestId()} ${AccessLogField.contextErrorMessage()} ${AccessLogField.contextErrorMessageString()}`
)
}
});
```

You can use the `methodOptions` property to configure
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-batch/lib/compute-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ export interface ComputeResources {
*/
readonly minvCpus?: number;

/**
* The Amazon EC2 placement group to associate with your compute resources.
*
* @default - No placement group will be used.
*/
readonly placementGroup?: string;

/**
* The EC2 key pair that is used for instances launched in the compute environment.
* If no key is defined, then SSH access is not allowed to provisioned compute resources.
Expand Down Expand Up @@ -365,6 +372,7 @@ export class ComputeEnvironment extends Resource implements IComputeEnvironment
launchTemplate: props.computeResources.launchTemplate,
maxvCpus: props.computeResources.maxvCpus || 256,
minvCpus: props.computeResources.minvCpus || 0,
placementGroup: props.computeResources.placementGroup,
securityGroupIds: this.buildSecurityGroupIds(props.computeResources.vpc, props.computeResources.securityGroups),
spotIamFleetRole: spotFleetRole ? spotFleetRole.roleArn : undefined,
subnets: props.computeResources.vpc.selectSubnets(props.computeResources.vpcSubnets).subnetIds,
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-batch/test/compute-environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ describe('Batch Compute Evironment', () => {
],
maxvCpus: 4,
minvCpus: 1,
placementGroup: 'example-cluster-group',
securityGroups: [
new ec2.SecurityGroup(stack, 'test-sg', {
vpc,
Expand Down Expand Up @@ -230,6 +231,7 @@ describe('Batch Compute Evironment', () => {
],
MaxvCpus: props.computeResources.maxvCpus,
MinvCpus: props.computeResources.minvCpus,
PlacementGroup: props.computeResources.placementGroup,
SecurityGroupIds: [
{
'Fn::GetAtt': [
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import { Construct } from '@aws-cdk/core';

/**
* Collection of arbitrary properties
*
* @deprecated this type has been deprecated in favor of using a key-value type directly
*/
export type Properties = {[key: string]: any};

/**
* Configuration options for custom resource providers.
*
* @deprecated used in {@link ICustomResourceProvider} which is now deprecated
*/
export interface CustomResourceProviderConfig {
/**
Expand All @@ -37,6 +41,8 @@ export interface ICustomResourceProvider {

/**
* Represents a provider for an AWS CloudFormation custom resources.
*
* @deprecated use core.CustomResource instead
*/
export class CustomResourceProvider implements ICustomResourceProvider {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-cloudformation/lib/nested-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Construct } from '@aws-cdk/core';
/**
* Initialization props for the `NestedStack` construct.
*
* @experimental
* @deprecated use core.NestedStackProps instead
*/
export interface NestedStackProps {
/**
Expand Down Expand Up @@ -64,7 +64,7 @@ export interface NestedStackProps {
* nested stack will automatically be translated to stack parameters and
* outputs.
*
* @experimental
* @deprecated use core.NestedStack instead
*/
export class NestedStack extends core.NestedStack {
constructor(scope: Construct, id: string, props: NestedStackProps = { }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront-origins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ new cloudfront.Distribution(this, 'myDist', {

The above will treat the bucket differently based on if `IBucket.isWebsite` is set or not. If the bucket is configured as a website, the bucket is
treated as an HTTP origin, and the built-in S3 redirects and error pages can be used. Otherwise, the bucket is handled as a bucket origin and
CloudFront's redirect and error handling will be used. In the latter case, the Origin wil create an origin access identity and grant it access to the
CloudFront's redirect and error handling will be used. In the latter case, the Origin will create an origin access identity and grant it access to the
underlying bucket. This can be used in conjunction with a bucket that is not public to require that your users access your content using CloudFront
URLs and not S3 URLs directly. Alternatively, a custom origin access identity can be passed to the S3 origin in the properties.

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ new cloudfront.Distribution(this, 'myDist', {

The above will treat the bucket differently based on if `IBucket.isWebsite` is set or not. If the bucket is configured as a website, the bucket is
treated as an HTTP origin, and the built-in S3 redirects and error pages can be used. Otherwise, the bucket is handled as a bucket origin and
CloudFront's redirect and error handling will be used. In the latter case, the Origin wil create an origin access identity and grant it access to the
CloudFront's redirect and error handling will be used. In the latter case, the Origin will create an origin access identity and grant it access to the
underlying bucket. This can be used in conjunction with a bucket that is not public to require that your users access your content using CloudFront
URLs and not S3 URLs directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class EdgeFunction extends Resource implements lambda.IVersion {
throw new Error('stacks which use EdgeFunctions must have an explicitly set region');
}

const edgeStackId = stackId ?? `edge-lambda-stack-${region}`;
const edgeStackId = stackId ?? `edge-lambda-stack-${this.stack.node.addr}`;
let edgeStack = stage.node.tryFindChild(edgeStackId) as Stack;
if (!edgeStack) {
edgeStack = new Stack(stage, edgeStackId, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ function defaultEdgeFunctionProps(stackId?: string) {
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_12_X,
stackId: stackId ?? 'edge-lambda-stack-testregion',
stackId: stackId,
};
}

function getFnStack(region: string = 'testregion'): cdk.Stack {
return app.node.findChild(`edge-lambda-stack-${region}`) as cdk.Stack;
function getFnStack(): cdk.Stack {
return app.node.findChild(`edge-lambda-stack-${stack.node.addr}`) as cdk.Stack;
}
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-codebuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,20 @@ new codebuild.Project(stack, 'MyProject', {
Here's a CodeBuild project with a simple example that creates a project mounted on AWS EFS:

[Minimal Example](./test/integ.project-file-system-location.ts)

## Batch builds

To enable batch builds you should call `enableBatchBuilds()` on the project instance.

It returns an object containing the batch service role that was created,
or `undefined` if batch builds could not be enabled, for example if the project was imported.

```ts
import * as codebuild from '@aws-cdk/aws-codebuild';

const project = new codebuild.Project(this, 'MyProject', { ... });

if (project.enableBatchBuilds()) {
console.log('Batch builds were enabled');
}
```
58 changes: 54 additions & 4 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import { CODEPIPELINE_SOURCE_ARTIFACTS_TYPE, NO_SOURCE_TYPE } from './source-typ
// eslint-disable-next-line
import { Construct as CoreConstruct } from '@aws-cdk/core';

/**
* The type returned from {@link IProject#enableBatchBuilds}.
*/
export interface BatchBuildConfig {
/** The IAM batch service Role of this Project. */
readonly role: iam.IRole;
}

export interface IProject extends IResource, iam.IGrantable, ec2.IConnectable {
/**
* The ARN of this Project.
Expand All @@ -44,6 +52,14 @@ export interface IProject extends IResource, iam.IGrantable, ec2.IConnectable {
/** The IAM service Role of this Project. Undefined for imported Projects. */
readonly role?: iam.IRole;

/**
* Enable batch builds.
*
* Returns an object contining the batch service role if batch builds
* could be enabled.
*/
enableBatchBuilds(): BatchBuildConfig | undefined;

addToRolePolicy(policyStatement: iam.PolicyStatement): void;

/**
Expand Down Expand Up @@ -196,6 +212,10 @@ abstract class ProjectBase extends Resource implements IProject {
return this._connections;
}

public enableBatchBuilds(): BatchBuildConfig | undefined {
return undefined;
}

/**
* Add a permission only if there's a policy attached.
* @param statement The permissions statement to add
Expand Down Expand Up @@ -729,6 +749,7 @@ export class Project extends ProjectBase {
private readonly _secondaryArtifacts: CfnProject.ArtifactsProperty[];
private _encryptionKey?: kms.IKey;
private readonly _fileSystemLocations: CfnProject.ProjectFileSystemLocationProperty[];
private _batchServiceRole?: iam.Role;

constructor(scope: Construct, id: string, props: ProjectProps) {
super(scope, id, {
Expand Down Expand Up @@ -813,6 +834,14 @@ export class Project extends ProjectBase {
sourceVersion: sourceConfig.sourceVersion,
vpcConfig: this.configureVpc(props),
logsConfig: this.renderLoggingConfiguration(props.logging),
buildBatchConfig: Lazy.any({
produce: () => {
const config: CfnProject.ProjectBuildBatchConfigProperty | undefined = this._batchServiceRole ? {
serviceRole: this._batchServiceRole.roleArn,
} : undefined;
return config;
},
}),
});

this.addVpcRequiredPermissions(props, resource);
Expand Down Expand Up @@ -853,6 +882,27 @@ export class Project extends ProjectBase {
}
}

public enableBatchBuilds(): BatchBuildConfig | undefined {
if (!this._batchServiceRole) {
this._batchServiceRole = new iam.Role(this, 'BatchServiceRole', {
assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
});
this._batchServiceRole.addToPrincipalPolicy(new iam.PolicyStatement({
resources: [Lazy.string({
produce: () => this.projectArn,
})],
actions: [
'codebuild:StartBuild',
'codebuild:StopBuild',
'codebuild:RetryBuild',
],
}));
}
return {
role: this._batchServiceRole,
};
}

/**
* Adds a secondary source to the Project.
*
Expand Down Expand Up @@ -1139,8 +1189,8 @@ export class Project extends ProjectBase {
return undefined;
}

let s3Config: CfnProject.S3LogsConfigProperty|undefined = undefined;
let cloudwatchConfig: CfnProject.CloudWatchLogsConfigProperty|undefined = undefined;
let s3Config: CfnProject.S3LogsConfigProperty | undefined = undefined;
let cloudwatchConfig: CfnProject.CloudWatchLogsConfigProperty | undefined = undefined;

if (props.s3) {
const s3Logs = props.s3;
Expand Down Expand Up @@ -1350,10 +1400,10 @@ export interface IBuildImage {
}

/** Optional arguments to {@link IBuildImage.binder} - currently empty. */
export interface BuildImageBindOptions {}
export interface BuildImageBindOptions { }

/** The return type from {@link IBuildImage.binder} - currently empty. */
export interface BuildImageConfig {}
export interface BuildImageConfig { }

// @deprecated(not in tsdoc on purpose): add bind() to IBuildImage
// and get rid of IBindableBuildImage
Expand Down
11 changes: 9 additions & 2 deletions packages/@aws-cdk/aws-codebuild/lib/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ interface ThirdPartyGitSourceProps extends GitSourceProps {
/**
* Trigger a batch build from a webhook instead of a standard one.
*
* Enabling this will enable batch builds on the CodeBuild project.
*
* @default false
*/
readonly webhookTriggersBatchBuild?: boolean;
Expand Down Expand Up @@ -518,7 +520,7 @@ abstract class ThirdPartyGitSource extends GitSource {
this.webhookTriggersBatchBuild = props.webhookTriggersBatchBuild;
}

public bind(_scope: CoreConstruct, _project: IProject): SourceConfig {
public bind(_scope: CoreConstruct, project: IProject): SourceConfig {
const anyFilterGroupsProvided = this.webhookFilters.length > 0;
const webhook = this.webhook === undefined ? (anyFilterGroupsProvided ? true : undefined) : this.webhook;

Expand All @@ -530,7 +532,12 @@ abstract class ThirdPartyGitSource extends GitSource {
throw new Error('`webhookTriggersBatchBuild` cannot be used when `webhook` is `false`');
}

const superConfig = super.bind(_scope, _project);
const superConfig = super.bind(_scope, project);

if (this.webhookTriggersBatchBuild) {
project.enableBatchBuilds();
}

return {
sourceProperty: {
...superConfig.sourceProperty,
Expand Down
Loading

0 comments on commit 93fb617

Please sign in to comment.