Skip to content

Commit

Permalink
Merge branch 'master' into eks/bug-irsaid
Browse files Browse the repository at this point in the history
  • Loading branch information
vlesierse authored May 26, 2020
2 parents d37687f + 44e4d66 commit c37770a
Show file tree
Hide file tree
Showing 46 changed files with 1,672 additions and 222 deletions.
59 changes: 1 addition & 58 deletions allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1 @@
incompatible-argument:@aws-cdk/aws-ecs.Ec2TaskDefinition.<initializer>
incompatible-argument:@aws-cdk/aws-ecs.Ec2TaskDefinition.addVolume
incompatible-argument:@aws-cdk/aws-ecs.FargateTaskDefinition.<initializer>
incompatible-argument:@aws-cdk/aws-ecs.FargateTaskDefinition.addVolume
incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.<initializer>
incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.addVolume
change-return-type:@aws-cdk/core.Fn.getAtt
new-argument:@aws-cdk/aws-iam.ManagedPolicy.<initializer>
new-argument:@aws-cdk/aws-iam.ManagedPolicy.<initializer>
removed:@aws-cdk/aws-apigateway.AwsIntegration.props
removed:@aws-cdk/aws-apigateway.HttpIntegration.props
removed:@aws-cdk/aws-apigateway.Integration.props
removed:@aws-cdk/aws-apigateway.LambdaIntegration.props
removed:@aws-cdk/aws-apigateway.MockIntegration.props
removed:@aws-cdk/aws-ecs-patterns.ScheduledEc2TaskDefinitionOptions.schedule
removed:@aws-cdk/aws-ecs-patterns.ScheduledEc2TaskDefinitionOptions.cluster
removed:@aws-cdk/aws-ecs-patterns.ScheduledEc2TaskDefinitionOptions.desiredTaskCount
removed:@aws-cdk/aws-ecs-patterns.ScheduledEc2TaskDefinitionOptions.vpc
removed:@aws-cdk/aws-ecs-patterns.ScheduledFargateTaskDefinitionOptions.schedule
removed:@aws-cdk/aws-ecs-patterns.ScheduledFargateTaskDefinitionOptions.cluster
removed:@aws-cdk/aws-ecs-patterns.ScheduledFargateTaskDefinitionOptions.desiredTaskCount
removed:@aws-cdk/aws-ecs-patterns.ScheduledFargateTaskDefinitionOptions.vpc
incompatible-argument:@aws-cdk/aws-lambda.Function.<initializer>
incompatible-argument:@aws-cdk/aws-lambda.SingletonFunction.<initializer>
incompatible-argument:@aws-cdk/aws-lambda.Function.addEnvironment
changed-type:@aws-cdk/aws-dynamodb.Table.tableStreamArn
incompatible-argument:@aws-cdk/aws-apigateway.LambdaRestApi.addModel
incompatible-argument:@aws-cdk/aws-apigateway.Model.<initializer>
incompatible-argument:@aws-cdk/aws-apigateway.RestApi.addModel
incompatible-argument:@aws-cdk/aws-apigateway.ProxyResource.addProxy
incompatible-argument:@aws-cdk/aws-apigateway.Resource.addProxy
incompatible-argument:@aws-cdk/aws-apigateway.ResourceBase.addProxy
incompatible-argument:@aws-cdk/aws-apigateway.IResource.addProxy
incompatible-argument:@aws-cdk/aws-apigateway.RequestAuthorizer.<initializer>
incompatible-argument:@aws-cdk/aws-servicediscovery.Service.fromServiceAttributes
removed:@aws-cdk/core.ConstructNode.addReference
removed:@aws-cdk/core.ConstructNode.references
removed:@aws-cdk/core.OutgoingReference
change-return-type:@aws-cdk/aws-lambda-destinations.EventBridgeDestination.bind
change-return-type:@aws-cdk/aws-lambda-destinations.LambdaDestination.bind
change-return-type:@aws-cdk/aws-lambda-destinations.SnsDestination.bind
change-return-type:@aws-cdk/aws-lambda-destinations.SqsDestination.bind
removed:@aws-cdk/cdk-assets-schema.DockerImageDestination.imageUri
incompatible-argument:@aws-cdk/aws-iam.FederatedPrincipal.<initializer>
incompatible-argument:@aws-cdk/aws-iam.PolicyStatement.addCondition
incompatible-argument:@aws-cdk/aws-iam.PolicyStatement.addConditions
incompatible-argument:@aws-cdk/aws-iam.PolicyStatement.addFederatedPrincipal
incompatible-argument:@aws-cdk/aws-iam.PrincipalPolicyFragment.<initializer>
changed-type:@aws-cdk/aws-iam.FederatedPrincipal.conditions
changed-type:@aws-cdk/aws-iam.PrincipalPolicyFragment.conditions
changed-type:@aws-cdk/aws-iam.PrincipalWithConditions.conditions
removed:@aws-cdk/cdk-assets-schema.Placeholders
# Following two are because we're turning: properties: {string=>any} into a union of typed interfaces
# Needs to be removed after next release.
incompatible-argument:@aws-cdk/cloud-assembly-schema.Manifest.save
change-return-type:@aws-cdk/cloud-assembly-schema.Manifest.load
removed:@aws-cdk/core.DefaultStackSynthesizer.DEFAULT_DEPLOY_ACTION_ROLE_ARN
removed:@aws-cdk/core.DefaultStackSynthesizerProps.deployActionRoleArn

8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-backup/lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ export class BackupResource {
/**
* A DynamoDB table
*/
public static fromDynamoDbTable(table: dynamodb.Table) {
public static fromDynamoDbTable(table: dynamodb.ITable) {
return BackupResource.fromArn(table.tableArn);
}

/**
* An EC2 instance
*/
public static fromEc2Instance(instance: ec2.Instance) {
public static fromEc2Instance(instance: ec2.IInstance) {
return BackupResource.fromArn(Stack.of(instance).formatArn({
service: 'ec2',
resource: 'instance',
Expand All @@ -82,7 +82,7 @@ export class BackupResource {
/**
* An EFS file system
*/
public static fromEfsFileSystem(fileSystem: efs.FileSystem) {
public static fromEfsFileSystem(fileSystem: efs.IFileSystem) {
return BackupResource.fromArn(Stack.of(fileSystem).formatArn({
service: 'elasticfilesystem',
resource: 'file-system',
Expand All @@ -93,7 +93,7 @@ export class BackupResource {
/**
* A RDS database instance
*/
public static fromRdsDatabaseInstance(instance: rds.DatabaseInstance) {
public static fromRdsDatabaseInstance(instance: rds.IDatabaseInstance) {
return BackupResource.fromArn(instance.instanceArn);
}

Expand Down
41 changes: 41 additions & 0 deletions packages/@aws-cdk/aws-backup/test/selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,44 @@ test('fromEc2Instance', () => {
},
});
});

test('fromDynamoDbTable', () => {
// GIVEN
const newTable = new dynamodb.Table(stack, 'New', {
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},
});
const existingTable = dynamodb.Table.fromTableArn(stack, 'Existing', 'arn:aws:dynamodb:eu-west-1:123456789012:table/existing');

// WHEN
plan.addSelection('Selection', {
resources: [
BackupResource.fromDynamoDbTable(newTable),
BackupResource.fromDynamoDbTable(existingTable),
],
});

// THEN
expect(stack).toHaveResource('AWS::Backup::BackupSelection', {
BackupSelection: {
IamRoleArn: {
'Fn::GetAtt': [
'PlanSelectionRole6D10F4B7',
'Arn',
],
},
Resources: [
{
'Fn::GetAtt': [
'New8A81B073',
'Arn',
],
},
'arn:aws:dynamodb:eu-west-1:123456789012:table/existing',
],
SelectionName: 'Selection',
},
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export interface CrossRegionSupportStackProps {
* @example '012345678901'
*/
readonly account: string;

readonly synthesizer: cdk.IStackSynthesizer | undefined;
}

/**
Expand All @@ -90,6 +92,7 @@ export class CrossRegionSupportStack extends cdk.Stack {
region: props.region,
account: props.account,
},
synthesizer: props.synthesizer,
});

const crossRegionSupportConstruct = new CrossRegionSupportConstruct(this, 'Default');
Expand Down
23 changes: 22 additions & 1 deletion packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import * as events from '@aws-cdk/aws-events';
import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
import * as s3 from '@aws-cdk/aws-s3';
import { App, Construct, Lazy, PhysicalName, RemovalPolicy, Resource, Stack, Token } from '@aws-cdk/core';
import {
App, BootstraplessSynthesizer, Construct, DefaultStackSynthesizer,
IStackSynthesizer, Lazy, PhysicalName, RemovalPolicy, Resource, Stack, Token,
} from '@aws-cdk/core';
import { ActionCategory, IAction, IPipeline, IStage } from './action';
import { CfnPipeline } from './codepipeline.generated';
import { CrossRegionSupportConstruct, CrossRegionSupportStack } from './cross-region-support-stack';
Expand Down Expand Up @@ -483,6 +486,7 @@ export class Pipeline extends PipelineBase {
pipelineStackName: pipelineStack.stackName,
region: actionRegion,
account: pipelineAccount,
synthesizer: this.getCrossRegionSupportSynthesizer(),
});
}

Expand All @@ -492,6 +496,23 @@ export class Pipeline extends PipelineBase {
};
}

private getCrossRegionSupportSynthesizer(): IStackSynthesizer | undefined {
if (this.stack.synthesizer instanceof DefaultStackSynthesizer) {
// if we have the new synthesizer,
// we need a bootstrapless copy of it,
// because we don't want to require bootstrapping the environment
// of the pipeline account in this replication region
return new BootstraplessSynthesizer({
deployRoleArn: this.stack.synthesizer.deployRoleArn,
cloudFormationExecutionRoleArn: this.stack.synthesizer.cloudFormationExecutionRoleArn,
});
} else {
// any other synthesizer: just return undefined
// (ie., use the default based on the context settings)
return undefined;
}
}

private generateNameForDefaultBucketKeyAlias(): string {
const prefix = 'alias/codepipeline-';
const maxAliasLength = 256;
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-codepipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand Down
43 changes: 42 additions & 1 deletion packages/@aws-cdk/aws-codepipeline/test/test.pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
import * as s3 from '@aws-cdk/aws-s3';
import * as cdk from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { Test } from 'nodeunit';
import * as codepipeline from '../lib';
import { FakeBuildAction } from './fake-build-action';
Expand Down Expand Up @@ -46,7 +47,7 @@ export = {
},

'that is cross-region': {
'validates that source actions are in the same account as the pipeline'(test: Test) {
'validates that source actions are in the same region as the pipeline'(test: Test) {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'PipelineStack', { env: { region: 'us-west-1', account: '123456789012' }});
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
Expand Down Expand Up @@ -296,6 +297,46 @@ export = {

test.done();
},

'generates the support stack containing the replication Bucket without the need to bootstrap in that environment'(test: Test) {
const app = new cdk.App({
treeMetadata: false, // we can't set the context otherwise, because App will have a child
});
app.node.setContext(cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT, true);

const pipelineStack = new cdk.Stack(app, 'PipelineStack', {
env: { region: 'us-west-2', account: '123456789012' },
});
const sourceOutput = new codepipeline.Artifact();
new codepipeline.Pipeline(pipelineStack, 'Pipeline', {
stages: [
{
stageName: 'Source',
actions: [new FakeSourceAction({
actionName: 'Source',
output: sourceOutput,
})],
},
{
stageName: 'Build',
actions: [new FakeBuildAction({
actionName: 'Build',
input: sourceOutput,
region: 'eu-south-1',
})],
},
],
});

const assembly = app.synth();
const supportStackArtifact = assembly.getStackByName('PipelineStack-support-eu-south-1');
test.equal(supportStackArtifact.assumeRoleArn,
'arn:${AWS::Partition}:iam::123456789012:role/cdk-hnb659fds-deploy-role-123456789012-us-west-2');
test.equal(supportStackArtifact.cloudFormationExecutionRoleArn,
'arn:${AWS::Partition}:iam::123456789012:role/cdk-hnb659fds-cfn-exec-role-123456789012-us-west-2');

test.done();
},
},

'that is cross-account': {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cognito/lib/user-pool-attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface RequiredAttributes {
readonly birthdate?: boolean;

/**
* Whether theb user's e-mail address, represented as an RFC 5322 [RFC5322] addr-spec, is a required attribute.
* Whether the user's e-mail address, represented as an RFC 5322 [RFC5322] addr-spec, is a required attribute.
* @default false
*/
readonly email?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,9 +1114,9 @@ export class Table extends TableBase {
* @param nonKeyAttributes a list of non-key attribute names
*/
private validateNonKeyAttributes(nonKeyAttributes: string[]) {
if (this.nonKeyAttributes.size + nonKeyAttributes.length > 20) {
if (this.nonKeyAttributes.size + nonKeyAttributes.length > 100) {
// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-secondary-indexes
throw new RangeError('a maximum number of nonKeyAttributes across all of secondary indexes is 20');
throw new RangeError('a maximum number of nonKeyAttributes across all of secondary indexes is 100');
}

// store all non-key attributes
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ test('error when adding a global secondary index with projection type INCLUDE, b
const table = new Table(stack, CONSTRUCT_NAME, { partitionKey: TABLE_PARTITION_KEY, sortKey: TABLE_SORT_KEY });
const gsiNonKeyAttributeGenerator = NON_KEY_ATTRIBUTE_GENERATOR(GSI_NON_KEY);
const gsiNonKeyAttributes: string[] = [];
for (let i = 0; i < 21; i++) {
for (let i = 0; i < 101; i++) {
gsiNonKeyAttributes.push(gsiNonKeyAttributeGenerator.next().value);
}

Expand All @@ -1124,7 +1124,7 @@ test('error when adding a global secondary index with projection type INCLUDE, b
sortKey: GSI_SORT_KEY,
projectionType: ProjectionType.INCLUDE,
nonKeyAttributes: gsiNonKeyAttributes,
})).toThrow(/a maximum number of nonKeyAttributes across all of secondary indexes is 20/);
})).toThrow(/a maximum number of nonKeyAttributes across all of secondary indexes is 100/);
});

test('error when adding a global secondary index with read or write capacity on a PAY_PER_REQUEST table', () => {
Expand Down
40 changes: 40 additions & 0 deletions packages/@aws-cdk/aws-events-targets/build-tools/gen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node

/**
* Writes lib/sdk-api-metadata.generated.ts from the metadata gathered from the
* aws-sdk package.
*/

const fs = require('fs');
const path = require('path');

const packageInfo = require('aws-sdk/package.json');
const sdkMetadata = require('aws-sdk/apis/metadata.json');

fs.writeFileSync(
path.resolve(__dirname, '..', 'lib', 'sdk-api-metadata.generated.ts'),
[
'export interface AwsSdkMetadata {',
' readonly [service: string]: {',
' readonly name: string;',
' readonly cors?: boolean;',
' readonly dualstackAvailable?: boolean;',
' readonly prefix?: string;',
' readonly versions?: readonly string[];',
' readonly xmlNoDefaultLists?: boolean;',
' readonly [key: string]: unknown;',
' };',
'}',
'',
// The generated code is probably not going to be super clean as far as linters are concerned...
'/* eslint-disable */',
'/* tslint:disable */',
'',
// Just mention where the data comes from, as a basic courtesy...
'/**',
` * Extracted from ${packageInfo.name} version ${packageInfo.version} (${packageInfo.license}).`,
' */',
// And finally, we export the data:
`export const metadata: AwsSdkMetadata = ${JSON.stringify(sdkMetadata, null, 2)};`,
].join('\n'),
);
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/aws-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as events from '@aws-cdk/aws-events';
import * as iam from '@aws-cdk/aws-iam';
import * as lambda from '@aws-cdk/aws-lambda';
import * as path from 'path';
import * as metadata from './sdk-api-metadata.json';
import { metadata } from './sdk-api-metadata.generated';
import { addLambdaPermission } from './util';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"cdk-build": {
"pre": [
"cp -f $(node -p 'require.resolve(\"aws-sdk/apis/metadata.json\")') lib/sdk-api-metadata.json && rm -f lib/sdk-api-metadata.d.ts"
"node ./build-tools/gen.js"
],
"jest": true
},
Expand Down
Loading

0 comments on commit c37770a

Please sign in to comment.