Skip to content

Commit

Permalink
Merge branch 'master' into outlier-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Apr 5, 2021
2 parents 5e0e90e + c5a2add commit d3f618f
Show file tree
Hide file tree
Showing 28 changed files with 353 additions and 141 deletions.
2 changes: 1 addition & 1 deletion design/aws-ecs/aws-ecs-scheduled-ecs-task-construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface ScheduledEc2TaskProps {
The `ScheduledEc2Task` construct will use the following existing constructs:

* Ec2TaskDefinition - To create a Task Definition for the container to start
* Ec2EventRuleTarget - The target of the aws event
* Ec2EventRuleTarget - The target of the AWS event
* EventRule - To describe the event trigger (in this case, a scheduled run)

An example use case to create a task that is scheduled to run every minute:
Expand Down
12 changes: 1 addition & 11 deletions packages/@aws-cdk/aws-backup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@

![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)

> All classes with the `Cfn` prefix in this module ([CFN Resources]) are always stable and safe to use.
>
> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib
![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)

---

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
"resource-attribute:@aws-cdk/aws-backup.BackupSelection.backupSelectionId"
]
},
"stability": "experimental",
"maturity": "experimental",
"stability": "stable",
"maturity": "stable",
"awscdkio": {
"announce": false
},
Expand Down
3 changes: 0 additions & 3 deletions packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ export class CacheHeaderBehavior {
if (headers.length === 0) {
throw new Error('At least one header to allow must be provided');
}
if (headers.length > 10) {
throw new Error(`Maximum allowed headers in Cache Policy is 10; got ${headers.length}.`);
}
return new CacheHeaderBehavior('whitelist', headers);
}

Expand Down
11 changes: 0 additions & 11 deletions packages/@aws-cdk/aws-cloudfront/test/cache-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,6 @@ describe('CachePolicy', () => {
expect(() => new CachePolicy(stack, 'CachePolicy6', { cachePolicyName: 'My_Policy' })).not.toThrow();
});

test('throws if more than 10 CacheHeaderBehavior headers are being passed', () => {
const errorMessage = /Maximum allowed headers in Cache Policy is 10; got (.*?)/;
expect(() => new CachePolicy(stack, 'CachePolicy1', {
headerBehavior: CacheHeaderBehavior.allowList('Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do', 'eiusmod'),
})).toThrow(errorMessage);

expect(() => new CachePolicy(stack, 'CachePolicy2', {
headerBehavior: CacheHeaderBehavior.allowList('Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do'),
})).not.toThrow();
});

test('does not throw if cachePolicyName is a token', () => {
expect(() => new CachePolicy(stack, 'CachePolicy', {
cachePolicyName: Aws.STACK_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class EcrSourceAction extends Action {

this.props.repository.onCloudTrailImagePushed(Names.nodeUniqueId(stage.pipeline.node) + 'SourceEventRule', {
target: new targets.CodePipeline(stage.pipeline),
imageTag: this.props.imageTag,
imageTag: this.props.imageTag ?? 'latest',
});

// the Action Role also needs to write to the Pipeline's bucket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@
},
"MyEcrRepo767466D0": {
"Type": "AWS::ECR::Repository",
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"MyEcrRepoawscdkcodepipelineecrsourceMyPipeline63CF3194SourceEventRule911FDB6D": {
"Type": "AWS::Events::Rule",
Expand All @@ -367,6 +367,9 @@
{
"Ref": "MyEcrRepo767466D0"
}
],
"imageTag": [
"latest"
]
},
"eventName": [
Expand Down Expand Up @@ -412,4 +415,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const pipeline = new codepipeline.Pipeline(stack, 'MyPipeline', {
artifactBucket: bucket,
});

const repository = new ecr.Repository(stack, 'MyEcrRepo');
const repository = new ecr.Repository(stack, 'MyEcrRepo', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const sourceStage = pipeline.addStage({ stageName: 'Source' });
sourceStage.addAction(new cpactions.EcrSourceAction({
actionName: 'ECR_Source',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/container-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class ContainerDefinition extends CoreConstruct {
* stopped. If the essential parameter of a container is marked as false, then its
* failure does not affect the rest of the containers in a task.
*
* If this parameter isomitted, a container is assumed to be essential.
* If this parameter is omitted, a container is assumed to be essential.
*/
public readonly essential: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export class SplunkLogDriver extends LogDriver {
'splunk-verify-connection': this.props.verifyConnection,
'splunk-gzip': this.props.gzip,
'splunk-gzip-level': this.props.gzipLevel,
'splunk-tag': this.props.tag,
...renderCommonLogDriverOptions(this.props),
}),
};
Expand Down
31 changes: 0 additions & 31 deletions packages/@aws-cdk/aws-ecs/test/splunk-log-driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,4 @@ nodeunitShim({

test.done();
},

'create a splunk log driver using splunk-tag property when tag is defined'(test: Test) {
// WHEN
td.addContainer('Container', {
image,
logging: ecs.LogDrivers.splunk({
token: cdk.SecretValue.secretsManager('my-splunk-token'),
url: 'my-splunk-url',
tag: 'abc',
}),
memoryLimitMiB: 128,
});

// THEN
expect(stack).to(haveResourceLike('AWS::ECS::TaskDefinition', {
ContainerDefinitions: [
{
LogConfiguration: {
LogDriver: 'splunk',
Options: {
'splunk-token': '{{resolve:secretsmanager:my-splunk-token:SecretString:::}}',
'splunk-url': 'my-splunk-url',
'splunk-tag': 'abc',
},
},
},
],
}));

test.done();
},
});
11 changes: 8 additions & 3 deletions packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { ABSENT } from '@aws-cdk/assert';
import { Vpc } from '@aws-cdk/aws-ec2';
import { Runtime } from '@aws-cdk/aws-lambda';
import { CodeConfig, Runtime } from '@aws-cdk/aws-lambda';
import { Stack } from '@aws-cdk/core';
import { NodejsFunction } from '../lib';
import { Bundling } from '../lib/bundling';
Expand All @@ -13,8 +13,13 @@ jest.mock('../lib/bundling', () => {
return {
Bundling: {
bundle: jest.fn().mockReturnValue({
bind: () => {
return { inlineCode: 'code' };
bind: (): CodeConfig => {
return {
s3Location: {
bucketName: 'my-bucket',
objectKey: 'my-key',
},
};
},
bindToResource: () => { return; },
}),
Expand Down
9 changes: 7 additions & 2 deletions packages/@aws-cdk/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as kms from '@aws-cdk/aws-kms';
import * as logs from '@aws-cdk/aws-logs';
import * as s3 from '@aws-cdk/aws-s3';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import { Annotations, Duration, RemovalPolicy, Resource, Token } from '@aws-cdk/core';
import { Annotations, Duration, FeatureFlags, RemovalPolicy, Resource, Token } from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { Construct } from 'constructs';
import { IClusterEngine } from './cluster-engine';
import { DatabaseClusterAttributes, IDatabaseCluster } from './cluster-ref';
Expand Down Expand Up @@ -340,11 +341,15 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
const clusterParameterGroupConfig = clusterParameterGroup?.bindToCluster({});
this.engine = props.engine;

const clusterIdentifier = FeatureFlags.of(this).isEnabled(cxapi.RDS_LOWERCASE_DB_IDENTIFIER)
? props.clusterIdentifier?.toLowerCase()
: props.clusterIdentifier;

this.newCfnProps = {
// Basic
engine: props.engine.engineType,
engineVersion: props.engine.engineVersion?.fullVersion,
dbClusterIdentifier: props.clusterIdentifier,
dbClusterIdentifier: clusterIdentifier,
dbSubnetGroupName: this.subnetGroup.subnetGroupName,
vpcSecurityGroupIds: this.securityGroups.map(sg => sg.securityGroupId),
port: props.port ?? clusterEngineBindConfig.port,
Expand Down
18 changes: 16 additions & 2 deletions packages/@aws-cdk/aws-rds/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ import * as kms from '@aws-cdk/aws-kms';
import * as logs from '@aws-cdk/aws-logs';
import * as s3 from '@aws-cdk/aws-s3';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import { Duration, IResource, Lazy, RemovalPolicy, Resource, Stack, Token } from '@aws-cdk/core';
import {
Duration,
FeatureFlags,
IResource,
Lazy,
RemovalPolicy,
Resource,
Stack,
Token,
} from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { Construct } from 'constructs';
import { DatabaseSecret } from './database-secret';
import { Endpoint } from './endpoint';
Expand Down Expand Up @@ -687,13 +697,17 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData
});
}

const instanceIdentifier = FeatureFlags.of(this).isEnabled(cxapi.RDS_LOWERCASE_DB_IDENTIFIER)
? props.instanceIdentifier?.toLowerCase()
: props.instanceIdentifier;

this.newCfnProps = {
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
availabilityZone: props.multiAz ? undefined : props.availabilityZone,
backupRetentionPeriod: props.backupRetention?.toDays(),
copyTagsToSnapshot: props.copyTagsToSnapshot ?? true,
dbInstanceClass: Lazy.string({ produce: () => `db.${this.instanceType}` }),
dbInstanceIdentifier: props.instanceIdentifier,
dbInstanceIdentifier: instanceIdentifier,
dbSubnetGroupName: subnetGroup.subnetGroupName,
deleteAutomatedBackups: props.deleteAutomatedBackups,
deletionProtection: defaultDeletionProtection(props.deletionProtection, props.removalPolicy),
Expand Down
9 changes: 7 additions & 2 deletions packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as ec2 from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import { Resource, Duration, Token, Annotations, RemovalPolicy, IResource, Stack, Lazy } from '@aws-cdk/core';
import { Resource, Duration, Token, Annotations, RemovalPolicy, IResource, Stack, Lazy, FeatureFlags } from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { Construct } from 'constructs';
import { IClusterEngine } from './cluster-engine';
import { Endpoint } from './endpoint';
Expand Down Expand Up @@ -438,10 +439,14 @@ export class ServerlessCluster extends ServerlessClusterBase {
}),
];

const clusterIdentifier = FeatureFlags.of(this).isEnabled(cxapi.RDS_LOWERCASE_DB_IDENTIFIER)
? props.clusterIdentifier?.toLowerCase()
: props.clusterIdentifier;

const cluster = new CfnDBCluster(this, 'Resource', {
backupRetentionPeriod: props.backupRetention?.toDays(),
databaseName: props.defaultDatabaseName,
dbClusterIdentifier: props.clusterIdentifier,
dbClusterIdentifier: clusterIdentifier,
dbClusterParameterGroupName: clusterParameterGroupConfig?.parameterGroupName,
dbSubnetGroupName: this.subnetGroup.subnetGroupName,
deletionProtection: defaultDeletionProtection(props.deletionProtection, props.removalPolicy),
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-rds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"@aws-cdk/aws-s3": "0.0.0",
"@aws-cdk/aws-secretsmanager": "0.0.0",
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"constructs": "^3.3.69"
},
"homepage": "https://github.com/aws/aws-cdk",
Expand All @@ -104,6 +105,7 @@
"@aws-cdk/aws-secretsmanager": "0.0.0",
"@aws-cdk/core": "0.0.0",
"@aws-cdk/aws-s3": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"constructs": "^3.3.69"
},
"engines": {
Expand Down
42 changes: 42 additions & 0 deletions packages/@aws-cdk/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,48 @@ describe('cluster', () => {


});

test('changes the case of the cluster identifier if the lowercaseDbIdentifier feature flag is enabled', () => {
// GIVEN
const app = new cdk.App({
context: { [cxapi.RDS_LOWERCASE_DB_IDENTIFIER]: true },
});
const stack = testStack(app);
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
const clusterIdentifier = 'TestClusterIdentifier';
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA,
instanceProps: { vpc },
clusterIdentifier,
});

// THEN
expect(stack).toHaveResourceLike('AWS::RDS::DBCluster', {
DBClusterIdentifier: clusterIdentifier.toLowerCase(),
});
});

test('does not changes the case of the cluster identifier if the lowercaseDbIdentifier feature flag is disabled', () => {
// GIVEN
const app = new cdk.App();
const stack = testStack(app);
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
const clusterIdentifier = 'TestClusterIdentifier';
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA,
instanceProps: { vpc },
clusterIdentifier,
});

// THEN
expect(stack).toHaveResourceLike('AWS::RDS::DBCluster', {
DBClusterIdentifier: clusterIdentifier,
});
});
});

test.each([
Expand Down
Loading

0 comments on commit d3f618f

Please sign in to comment.