Skip to content

Commit

Permalink
Update to version v1.80.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hnishar committed Jan 11, 2021
1 parent 8130c54 commit ce4966e
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @hnishar will be requested for review when someone opens a pull request.
* @hnishar
* @hnishar @purplebari
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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.80.0 (2021-01-11)

### Changed
- Upgraded all patterns to CDK v1.80.0
- Fixed the `allowReadOperation` override bug for `aws-apigateway-dynamodb` pattern ([#115](https://github.com/awslabs/aws-solutions-constructs/issues/115))
- Updated `vpc-defaults.ts` and `vpc-helper.ts` in `core` to allow different default VPCs

## 1.79.0 (2020-12-31)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion source/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"./patterns/@aws-solutions-constructs/*"
],
"rejectCycles": "true",
"version": "1.79.0"
"version": "1.80.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class ApiGatewayToDynamoDB extends Construct {
});
}
// Read
if (!props.allowReadOperation || props.allowReadOperation === true) {
if (props.allowReadOperation === undefined || props.allowReadOperation === true) {
const getRequestTemplate = "{\r\n\"TableName\": \"" + this.dynamoTable.tableName + "\",\r\n \"KeyConditionExpression\": \"" + partitionKeyName + " = :v1\",\r\n \"ExpressionAttributeValues\": {\r\n \":v1\": {\r\n \"S\": \"$input.params('" + partitionKeyName + "')\"\r\n }\r\n }\r\n}";
this.addActionToPolicy("dynamodb:Query");
defaults.addProxyMethodToApiResource({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,25 @@ test("Test deployment with existing DynamoDB table", () => {
PathPart: `{${oddPartitionKeyName}}`,
});
});

test("check setting allowReadOperation=false for dynamodb", () => {
const stack1 = new Stack();

new ApiGatewayToDynamoDB(stack1, "test-api-gateway-dynamodb1", {
allowReadOperation: true,
allowDeleteOperation: true
});

// Expect two APIG Methods (GET, DELETE) for allowReadOperation and allowDeleteOperation
expect(stack1).toCountResources("AWS::ApiGateway::Method", 2);

const stack2 = new Stack();

new ApiGatewayToDynamoDB(stack2, "test-api-gateway-dynamodb2", {
allowReadOperation: false,
allowDeleteOperation: true
});

// Expect only one APIG Method (DELETE) for allowDeleteOperation
expect(stack2).toCountResources("AWS::ApiGateway::Method", 1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,12 @@ export class LambdaToSqs extends Construct {
}

this.vpc = defaults.buildVpc(scope, {
defaultVpcProps: defaults.DefaultIsolatedVpcProps(),
existingVpc: props.existingVpc,
userVpcProps: props.vpcProps,
constructVpcProps: {
enableDnsHostnames: true,
enableDnsSupport: true,
natGateways: 0,
subnetConfiguration: [
{
cidrMask: 18,
name: "isolated",
subnetType: ec2.SubnetType.ISOLATED,
},
],
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { overrideProps } from "./utils";
import { buildVpc } from './vpc-helper';
import * as iam from '@aws-cdk/aws-iam';
import { Aws } from "@aws-cdk/core";
import { DefaultPublicPrivateVpcProps } from "./vpc-defaults";

export interface BuildSagemakerNotebookProps {
/**
Expand Down Expand Up @@ -129,7 +130,9 @@ export function buildSagemakerNotebook(scope: cdk.Construct, props: BuildSagemak

if (props.deployInsideVpc === undefined || props.deployInsideVpc) {
if (props.sagemakerNotebookProps?.subnetId === undefined && props.sagemakerNotebookProps?.securityGroupIds === undefined) {
vpcInstance = buildVpc(scope);
vpcInstance = buildVpc(scope, {
defaultVpcProps: DefaultPublicPrivateVpcProps()
});
securityGroup = new ec2.SecurityGroup(scope, "SecurityGroup", {
vpc: vpcInstance,
allowAllOutbound: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,26 @@

import * as ec2 from "@aws-cdk/aws-ec2";

export function DefaultVpcProps(): ec2.VpcProps {
/**
* Default VPC with public and private subnets
*/
export function DefaultPublicPrivateVpcProps(): ec2.VpcProps {
return {
} as ec2.VpcProps;
}

/**
* Default VPC with isolated subnets
*/
export function DefaultIsolatedVpcProps(): ec2.VpcProps {
return {
natGateways: 0,
subnetConfiguration: [
{
cidrMask: 18,
name: "isolated",
subnetType: ec2.SubnetType.ISOLATED,
}
]
} as ec2.VpcProps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
import * as ec2 from "@aws-cdk/aws-ec2";
import { Construct } from "@aws-cdk/core";
import { overrideProps } from "./utils";
import { DefaultVpcProps } from './vpc-defaults';

export interface BuildVpcProps {
/**
* Existing instance of a VPC, if this is set then the all Props are ignored
*/
readonly existingVpc?: ec2.IVpc;
/**
* One of the default VPC configurations available in vpc-defaults
*/
readonly defaultVpcProps: ec2.VpcProps;
/**
* User provided props to override the default props for the VPC.
*/
Expand All @@ -32,12 +35,12 @@ export interface BuildVpcProps {
readonly constructVpcProps?: ec2.VpcProps;
}

export function buildVpc(scope: Construct, props?: BuildVpcProps): ec2.IVpc {
export function buildVpc(scope: Construct, props: BuildVpcProps): ec2.IVpc {
if (props?.existingVpc) {
return props?.existingVpc;
}

let cumulativeProps: ec2.VpcProps = DefaultVpcProps();
let cumulativeProps: ec2.VpcProps = props?.defaultVpcProps;

if (props?.userVpcProps) {
cumulativeProps = overrideProps(cumulativeProps, props?.userVpcProps);
Expand Down
Loading

0 comments on commit ce4966e

Please sign in to comment.