Skip to content

Commit

Permalink
Merge branch 'master' into python38
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 3, 2020
2 parents 921547f + 71be72d commit c54cb21
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ part of the build of all AWS modules in the project and enforces the [AWS
Construct Library Design Guidelines](./DESIGN_GUIDELINES.md).

For more information about this tool, see the [awslint
README](./tools/awslint/README.md).
README](./packages/awslint/README.md).

Generally speaking, if you make any changes which violate an awslint rule, build
will fail with appropriate messages. All rules are documented and explained in
Expand All @@ -377,7 +377,7 @@ Here are a few useful commands:
* `scripts/foreach.sh yarn awslint` will start linting the entire repo, progressively. Rerun `scripts/foreach.sh` after fixing to continue.
* `lerna run awslint --no-bail --stream 2> awslint.txt` will run __awslint__ in all modules and collect all results into awslint.txt
* `lerna run awslint -- -i <RULE>` will run awslint throughout the repo and
evaluate only the rule specified [awslint README](./tools/awslint/README.md)
evaluate only the rule specified [awslint README](./packages/awslint/README.md)
for details on include/exclude rule patterns.

### cfn2ts
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 @@ -913,15 +913,15 @@ export class Table extends TableBase {

this.encryptionKey = encryptionKey;

if (props.tableName) { this.node.addMetadata('aws:cdk:hasPhysicalName', props.tableName); }

this.tableArn = this.getResourceArnAttribute(this.table.attrArn, {
service: 'dynamodb',
resource: 'table',
resourceName: this.physicalName,
});
this.tableName = this.getResourceNameAttribute(this.table.ref);

if (props.tableName) { this.node.addMetadata('aws:cdk:hasPhysicalName', this.tableName); }

this.tableStreamArn = streamSpecification ? this.table.attrStreamArn : undefined;

this.scalingRole = this.makeScalingRole();
Expand Down
37 changes: 20 additions & 17 deletions packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ResourcePart, SynthUtils } from '@aws-cdk/assert';
import { ABSENT, ResourcePart, SynthUtils } from '@aws-cdk/assert';
import '@aws-cdk/assert/jest';
import * as appscaling from '@aws-cdk/aws-applicationautoscaling';
import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
import { App, CfnDeletionPolicy, ConstructNode, Duration, RemovalPolicy, Stack, Tag } from '@aws-cdk/core';
import { App, CfnDeletionPolicy, ConstructNode, Duration, PhysicalName, RemovalPolicy, Stack, Tag } from '@aws-cdk/core';
import {
Attribute,
AttributeType,
Expand Down Expand Up @@ -67,8 +67,12 @@ function* LSI_GENERATOR(): Generator<LocalSecondaryIndexProps, never> {
}

describe('default properties', () => {
let stack: Stack;
beforeEach(() => {
stack = new Stack();
});

test('hash key only', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, { partitionKey: TABLE_PARTITION_KEY });

expect(stack).toHaveResource('AWS::DynamoDB::Table', {
Expand All @@ -82,15 +86,13 @@ describe('default properties', () => {
});

test('removalPolicy is DESTROY', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, { partitionKey: TABLE_PARTITION_KEY, removalPolicy: RemovalPolicy.DESTROY });

expect(stack).toHaveResource('AWS::DynamoDB::Table', { DeletionPolicy: CfnDeletionPolicy.DELETE }, ResourcePart.CompleteDefinition);

});

test('hash + range key', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, {
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
Expand All @@ -110,8 +112,6 @@ describe('default properties', () => {
});

test('hash + range key can also be specified in props', () => {
const stack = new Stack();

new Table(stack, CONSTRUCT_NAME, {
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
Expand All @@ -132,7 +132,6 @@ describe('default properties', () => {
});

test('point-in-time recovery is not enabled', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, {
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
Expand All @@ -154,7 +153,6 @@ describe('default properties', () => {
});

test('server-side encryption is not enabled', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, {
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
Expand All @@ -176,7 +174,6 @@ describe('default properties', () => {
});

test('stream is not enabled', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, {
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
Expand All @@ -198,7 +195,6 @@ describe('default properties', () => {
});

test('ttl is not enabled', () => {
const stack = new Stack();
new Table(stack, CONSTRUCT_NAME, {
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
Expand All @@ -220,8 +216,6 @@ describe('default properties', () => {
});

test('can specify new and old images', () => {
const stack = new Stack();

new Table(stack, CONSTRUCT_NAME, {
tableName: TABLE_NAME,
readCapacity: 42,
Expand Down Expand Up @@ -249,8 +243,6 @@ describe('default properties', () => {
});

test('can specify new images only', () => {
const stack = new Stack();

new Table(stack, CONSTRUCT_NAME, {
tableName: TABLE_NAME,
readCapacity: 42,
Expand Down Expand Up @@ -278,8 +270,6 @@ describe('default properties', () => {
});

test('can specify old images only', () => {
const stack = new Stack();

new Table(stack, CONSTRUCT_NAME, {
tableName: TABLE_NAME,
readCapacity: 42,
Expand All @@ -305,6 +295,19 @@ describe('default properties', () => {
},
);
});

test('can use PhysicalName.GENERATE_IF_NEEDED as the Table name', () => {
new Table(stack, CONSTRUCT_NAME, {
tableName: PhysicalName.GENERATE_IF_NEEDED,
partitionKey: TABLE_PARTITION_KEY,
});

// since the resource has not been used in a cross-environment manner,
// so the name should not be filled
expect(stack).toHaveResourceLike('AWS::DynamoDB::Table', {
TableName: ABSENT,
});
});
});

test('when specifying every property', () => {
Expand Down

0 comments on commit c54cb21

Please sign in to comment.