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

chore: forward merge 'master' into 'v2-main' #13685

Merged
merged 10 commits into from
Mar 19, 2021
7 changes: 6 additions & 1 deletion .github/workflows/yarn-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ jobs:
run: yarn install

- name: Run "yarn upgrade"
run: yarn upgrade
# jsdom breaks us starting from 16.5.1. Caused by https://github.com/feross/queue-microtask/issues/17
# in combination with https://github.com/jsdom/jsdom/commit/31eb938fdaa5d446e194c9ec4f0d6b46b4354954
# pinning this for now since its only used in tests (by jest-enviroment-jsdom).
# we are not even using this because our environment is 'node' - just the mere fact this module is loaded is what breaks.
# also - jest-enviroment-jsdom doesnt actually require 16.5.1 (https://github.com/facebook/jest/blob/master/packages/jest-environment-jsdom/package.json#L23)
run: yarn upgrade --pattern '!(jsdom)'

- name: Make Pull Request
uses: peter-evans/create-pull-request@v3
Expand Down
5 changes: 5 additions & 0 deletions allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.addVolume
# We made properties optional and it's really fine but our differ doesn't think so.
weakened:@aws-cdk/cloud-assembly-schema.DockerImageSource
weakened:@aws-cdk/cloud-assembly-schema.FileSource

# Changed required deprecated props from required -> optional.
# These are fine, since they shouldn't be widely used.
weakened:@aws-cdk/core.FileAssetLocation
weakened:@aws-cdk/aws-events.RuleTargetConfig
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/jest": "^26.0.21",
"cdk-build-tools": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/assets/test/test.staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export = {
// WHEN
const staging = new Staging(stack, 's1', { sourcePath });

test.deepEqual(staging.sourceHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.deepEqual(staging.assetHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.deepEqual(staging.sourcePath, sourcePath);
test.deepEqual(staging.relativeStagedPath(stack), 'asset.2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.done();
Expand All @@ -29,9 +29,9 @@ export = {
// WHEN
const staging = new Staging(stack, 's1', { sourcePath });

test.deepEqual(staging.sourceHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.deepEqual(staging.assetHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.deepEqual(staging.sourcePath, sourcePath);
test.deepEqual(staging.stagedPath, sourcePath);
test.deepEqual(staging.absoluteStagedPath, sourcePath);
test.done();
},

Expand Down Expand Up @@ -70,9 +70,9 @@ export = {
const withExtra = new Staging(stack, 'withExtra', { sourcePath: directory, extraHash: 'boom' });

// THEN
test.notEqual(withoutExtra.sourceHash, withExtra.sourceHash);
test.deepEqual(withoutExtra.sourceHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.deepEqual(withExtra.sourceHash, 'c95c915a5722bb9019e2c725d11868e5a619b55f36172f76bcbcaa8bb2d10c5f');
test.notEqual(withoutExtra.assetHash, withExtra.assetHash);
test.deepEqual(withoutExtra.assetHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00');
test.deepEqual(withExtra.assetHash, 'c95c915a5722bb9019e2c725d11868e5a619b55f36172f76bcbcaa8bb2d10c5f');
test.done();
},
};
32 changes: 26 additions & 6 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,10 @@ export abstract class RestApiBase extends Resource implements IRestApi {
ignore(deployment);
}

protected configureCloudWatchRole(apiResource: CfnRestApi) {
/**
* @internal
*/
protected _configureCloudWatchRole(apiResource: CfnRestApi) {
const role = new iam.Role(this, 'CloudWatchRole', {
assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonAPIGatewayPushToCloudWatchLogs')],
Expand All @@ -503,7 +506,24 @@ export abstract class RestApiBase extends Resource implements IRestApi {
resource.node.addDependency(apiResource);
}

protected configureDeployment(props: RestApiOptions) {
/**
* @deprecated This method will be made internal. No replacement
*/
protected configureCloudWatchRole(apiResource: CfnRestApi) {
this._configureCloudWatchRole(apiResource);
}

/**
* @deprecated This method will be made internal. No replacement
*/
protected configureDeployment(props: RestApiBaseProps) {
this._configureDeployment(props);
}

/**
* @internal
*/
protected _configureDeployment(props: RestApiBaseProps) {
const deploy = props.deploy ?? true;
if (deploy) {

Expand Down Expand Up @@ -603,14 +623,14 @@ export class SpecRestApi extends RestApiBase {
this.restApiRootResourceId = resource.attrRootResourceId;
this.root = new RootResource(this, {}, this.restApiRootResourceId);

this.configureDeployment(props);
this._configureDeployment(props);
if (props.domainName) {
this.addDomainName('CustomDomain', props.domainName);
}

const cloudWatchRole = props.cloudWatchRole ?? true;
if (cloudWatchRole) {
this.configureCloudWatchRole(resource);
this._configureCloudWatchRole(resource);
}
}
}
Expand Down Expand Up @@ -708,10 +728,10 @@ export class RestApi extends RestApiBase {

const cloudWatchRole = props.cloudWatchRole ?? true;
if (cloudWatchRole) {
this.configureCloudWatchRole(resource);
this._configureCloudWatchRole(resource);
}

this.configureDeployment(props);
this._configureDeployment(props);
if (props.domainName) {
this.addDomainName('CustomDomain', props.domainName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MultiStack extends cdk.Stack {
const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.NODEJS_10_X,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${helloCode}`),
code: lambda.Code.fromInline(`exports.handler = ${helloCode}`),
}));

const api = new apigw.RestApi(this, 'hello-api');
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/vpc-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class VpcLink extends Resource implements IVpcLink {
this.vpc = props.vpc;

const cfnResource = new CfnVpcLink(this, 'Resource', {
name: props.vpcLinkName || Lazy.stringValue({ produce: () => Names.uniqueId(this) }),
subnetIds: Lazy.listValue({ produce: () => this.renderSubnets() }),
securityGroupIds: Lazy.listValue({ produce: () => this.renderSecurityGroups() }),
name: props.vpcLinkName || Lazy.string({ produce: () => Names.uniqueId(this) }),
subnetIds: Lazy.list({ produce: () => this.renderSubnets() }),
securityGroupIds: Lazy.list({ produce: () => this.renderSecurityGroups() }),
});

this.vpcLinkId = cfnResource.ref;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class ScalableTarget extends Resource implements IScalableTarget {
* Add a policy statement to the role's policy
*/
public addToRolePolicy(statement: iam.PolicyStatement) {
this.role.addToPolicy(statement);
this.role.addToPrincipalPolicy(statement);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appmesh/lib/virtual-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export class VirtualNode extends VirtualNodeBase {
virtualNodeName: this.physicalName,
meshName: this.mesh.meshName,
spec: {
backends: cdk.Lazy.anyValue({ produce: () => this.backends }, { omitEmptyArray: true }),
listeners: cdk.Lazy.anyValue({ produce: () => this.listeners.map(listener => listener.listener) }, { omitEmptyArray: true }),
backends: cdk.Lazy.any({ produce: () => this.backends }, { omitEmptyArray: true }),
listeners: cdk.Lazy.any({ produce: () => this.listeners.map(listener => listener.listener) }, { omitEmptyArray: true }),
backendDefaults: props.backendDefaults !== undefined
? {
clientPolicy: props.backendDefaults?.clientPolicy?.bind(this).clientPolicy,
Expand Down
7 changes: 4 additions & 3 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
* Adds a statement to the IAM role assumed by instances of this fleet.
*/
public addToRolePolicy(statement: iam.PolicyStatement) {
this.role.addToPolicy(statement);
this.role.addToPrincipalPolicy(statement);
}

/**
Expand Down Expand Up @@ -1225,7 +1225,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
...this.autoScalingGroup.cfnOptions.creationPolicy,
resourceSignal: {
count: props.resourceSignalCount,
timeout: props.resourceSignalTimeout && props.resourceSignalTimeout.toISOString(),
timeout: props.resourceSignalTimeout && props.resourceSignalTimeout.toIsoString(),
},
};
}
Expand Down Expand Up @@ -1327,6 +1327,7 @@ export enum ScalingEvent {

/**
* Additional settings when a rolling update is selected
* @deprecated use `UpdatePolicy.rollingUpdate()`
*/
export interface RollingUpdateConfiguration {
/**
Expand Down Expand Up @@ -1516,7 +1517,7 @@ function renderRollingUpdateConfig(config: RollingUpdateConfiguration = {}): Cfn
minInstancesInService: config.minInstancesInService,
minSuccessfulInstancesPercent: validatePercentage(config.minSuccessfulInstancesPercent),
waitOnResourceSignals,
pauseTime: pauseTime && pauseTime.toISOString(),
pauseTime: pauseTime && pauseTime.toIsoString(),
suspendProcesses: config.suspendProcesses ?? DEFAULT_SUSPEND_PROCESSES,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nodeunitShim({

class FakeNotificationTarget implements autoscaling.ILifecycleHookTarget {
public bind(_scope: constructs.Construct, lifecycleHook: autoscaling.ILifecycleHook): autoscaling.LifecycleHookTargetConfig {
lifecycleHook.role.addToPolicy(new iam.PolicyStatement({
lifecycleHook.role.addToPrincipalPolicy(new iam.PolicyStatement({
actions: ['action:Work'],
resources: ['*'],
}));
Expand Down
5 changes: 1 addition & 4 deletions packages/@aws-cdk/aws-batch/test/compute-environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ describe('Batch Compute Evironment', () => {
},
desiredvCpus: 1,
ec2KeyPair: 'my-key-pair',
image: new ecs.EcsOptimizedAmi({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
hardwareType: ecs.AmiHardwareType.STANDARD,
}),
image: ecs.EcsOptimizedImage.amazonLinux2(ecs.AmiHardwareType.STANDARD),
instanceRole: new iam.CfnInstanceProfile(stack, 'Instance-Profile', {
roles: [new iam.Role(stack, 'Ecs-Instance-Role', {
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MyNestedStack extends cfn.NestedStack {
if (props.subscriber) {
new lambda.Function(this, 'fn', {
runtime: lambda.Runtime.NODEJS_10_X,
code: lambda.Code.inline('console.error("hi")'),
code: lambda.Code.fromInline('console.error("hi")'),
handler: 'index.handler',
environment: {
TOPIC_ARN: props.siblingTopic?.topicArn ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NestedStack extends cfn.NestedStack {
super(scope, id);

new lambda.Function(this, 'Handler', {
code: lambda.Code.asset(path.join(__dirname, 'asset-directory-fixture')),
code: lambda.Code.fromAsset(path.join(__dirname, 'asset-directory-fixture')),
runtime: lambda.Runtime.NODEJS_10_X,
handler: 'index.handler',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ export = {
const nested = new NestedStack(parent, 'nested-stack');

// WHEN
const location = nested.addDockerImageAsset({
const location = nested.synthesizer.addDockerImageAsset({
directoryName: 'my-image',
dockerBuildArgs: { key: 'value', boom: 'bam' },
dockerBuildTarget: 'buildTarget',
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-cloudfront/lib/web-distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export enum FailoverStatusCode {
* "cloudfront.net" domain. To use this feature you must provide the list of
* additional domains, and the ACM Certificate that CloudFront should use for
* these additional domains.
* @deprecated see {@link CloudFrontWebDistributionProps#viewerCertificate} with {@link ViewerCertificate#acmCertificate}
*/
export interface AliasConfiguration {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ nodeunitShim({
const sourceBucket = new s3.Bucket(stack, 'Bucket');

const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: lambda.Code.inline('foo'),
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
});
Expand Down Expand Up @@ -580,7 +580,7 @@ nodeunitShim({
const sourceBucket = new s3.Bucket(stack, 'Bucket');

const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: lambda.Code.inline('foo'),
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
});
Expand Down Expand Up @@ -618,7 +618,7 @@ nodeunitShim({
const sourceBucket = new s3.Bucket(stack, 'Bucket');

const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: lambda.Code.inline('foo'),
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
environment: {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudtrail/lib/cloudtrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class Trail extends Resource {

logsRole = new iam.Role(this, 'LogsRole', { assumedBy: cloudTrailPrincipal });

logsRole.addToPolicy(new iam.PolicyStatement({
logsRole.addToPrincipalPolicy(new iam.PolicyStatement({
actions: ['logs:PutLogEvents', 'logs:CreateLogStream'],
resources: [this.logGroup.logGroupArn],
}));
Expand Down
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch/lib/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class Metric implements IMetric {
};
}

/** @deprecated use toMetricConfig() */
public toAlarmConfig(): MetricAlarmConfig {
const metricConfig = this.toMetricConfig();
if (metricConfig.metricStat === undefined) {
Expand All @@ -320,6 +321,9 @@ export class Metric implements IMetric {
};
}

/**
* @deprecated use toMetricConfig()
*/
public toGraphConfig(): MetricGraphConfig {
const metricConfig = this.toMetricConfig();
if (metricConfig.metricStat === undefined) {
Expand Down Expand Up @@ -475,10 +479,16 @@ export class MathExpression implements IMetric {
});
}

/**
* @deprecated use toMetricConfig()
*/
public toAlarmConfig(): MetricAlarmConfig {
throw new Error('Using a math expression is not supported here. Pass a \'Metric\' object instead');
}

/**
* @deprecated use toMetricConfig()
*/
public toGraphConfig(): MetricGraphConfig {
throw new Error('Using a math expression is not supported here. Pass a \'Metric\' object instead');
}
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-cloudwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricAlarmConfig.period",
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricGraphConfig.period",
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.period",
"no-unused-type:@aws-cdk/aws-cloudwatch.Statistic",
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricAlarmConfig.dimensions",
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricAlarmConfig.extendedStatistic",
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricAlarmConfig.statistic",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudwatch/test/test.metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export = {
// GIVEN
const stack = new cdk.Stack();
const role = new iam.Role(stack, 'SomeRole', {
assumedBy: new iam.Anyone(),
assumedBy: new iam.AnyPrincipal(),
});

// WHEN
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ abstract class ProjectBase extends Resource implements IProject {
*/
public addToRolePolicy(statement: iam.PolicyStatement) {
if (this.role) {
this.role.addToPolicy(statement);
this.role.addToPrincipalPolicy(statement);
}
}

Expand Down Expand Up @@ -1224,7 +1224,7 @@ export class Project extends ProjectBase {
return;
}

this.role.addToPolicy(new iam.PolicyStatement({
this.role.addToPrincipalPolicy(new iam.PolicyStatement({
resources: [`arn:${Aws.PARTITION}:ec2:${Aws.REGION}:${Aws.ACCOUNT_ID}:network-interface/*`],
actions: ['ec2:CreateNetworkInterfacePermission'],
conditions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
super(scope, id);

const secrets = secretsmanager.Secret.fromSecretArn(this, 'MySecrets',
const secrets = secretsmanager.Secret.fromSecretCompleteArn(this, 'MySecrets',
`arn:aws:secretsmanager:${this.region}:${this.account}:secret:my-secrets-123456`);

new codebuild.Project(this, 'MyProject', {
Expand Down
Loading