Skip to content

Commit

Permalink
Merge pull request #931 from awslabs/bump/2.35.0
Browse files Browse the repository at this point in the history
chore(release): 2.35.0
  • Loading branch information
biffgaut authored Mar 23, 2023
2 parents bc4b391 + 29b3cd9 commit b4bbe63
Show file tree
Hide file tree
Showing 44 changed files with 506 additions and 415 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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.

## [2.35.0](https://github.com/awslabs/aws-solutions-constructs/compare/v2.34.0...v2.35.0) (2023-03-23)

Built on CDK v2.68.0

### Bug Fixes

* **aws-cloudfront-s3** Set s3LoggingBucket property ([#930](https://github.com/awslabs/aws-solutions-constructs/pull/930))

## [2.34.0](https://github.com/awslabs/aws-solutions-constructs/compare/v2.33.0...v2.34.0) (2023-03-18)

Built on CDK v2.68.0
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": "2.34.0"
"version": "2.35.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class CloudFrontToS3 extends Construct {
logS3AccessLogs: props.logS3AccessLogs
});
this.s3Bucket = buildS3BucketResponse.bucket;
this.s3LoggingBucket = buildS3BucketResponse.loggingBucket;
bucket = this.s3Bucket;
} else {
bucket = props.existingBucketObj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ function deploy(stack: cdk.Stack, props?: CloudFrontToS3Props) {
});
}

test('construct defaults set properties correctly', () => {
const stack = new cdk.Stack();
const construct = new CloudFrontToS3(stack, 'test-cloudfront-s3', {});

expect(construct.cloudFrontWebDistribution).toBeDefined();
expect(construct.cloudFrontFunction).toBeDefined();
expect(construct.cloudFrontLoggingBucket).toBeDefined();
expect(construct.s3Bucket).toBeDefined();
expect(construct.s3LoggingBucket).toBeDefined();
expect(construct.s3BucketInterface).toBeDefined();
});

test('check s3Bucket default encryption', () => {
const stack = new cdk.Stack();
deploy(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"devDependencies": {
"@types/deep-diff": "^1.0.0",
"@types/npmlog": "^4.1.2",
"@aws-cdk/assert": "0.0.0",
"@types/prettier": "2.6.0",
"@types/jest": "^27.4.0",
"@types/node": "^10.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
import * as defaults from '../index';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import '@aws-cdk/assert/jest';
import { Template } from 'aws-cdk-lib/assertions';

test('Test ObtainAlb with existing ALB', () => {
const stack = new Stack();
Expand All @@ -33,7 +33,10 @@ test('Test ObtainAlb with existing ALB', () => {
});

defaults.ObtainAlb(stack, 'test', vpc, true, existingLoadBalancer);
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::LoadBalancer', {

const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::LoadBalancer', {
Name: "unique-name",
});
});
Expand All @@ -52,7 +55,10 @@ test('Test ObtainAlb for new ALB with provided props', () => {
vpc,
internetFacing: true
});
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::LoadBalancer', {

const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::LoadBalancer', {
Name: "new-loadbalancer",
Scheme: "internet-facing",
});
Expand All @@ -68,7 +74,10 @@ test('Test ObtainAlb for new ALB with default props', () => {
});

defaults.ObtainAlb(stack, 'test', vpc, false);
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::LoadBalancer', {

const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::LoadBalancer', {
Scheme: "internal",
});
});
Expand All @@ -87,7 +96,10 @@ test('Test with custom logging bucket props', () => {
const testName = 'test-name';

defaults.ObtainAlb(stack, 'test', vpc, false, undefined, undefined, true, { bucketName: testName });
expect(stack).toHaveResourceLike('AWS::S3::Bucket', {

const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::S3::Bucket', {
BucketName: testName
});
});
Expand All @@ -100,7 +112,10 @@ test('Test with no logging', () => {
});

defaults.ObtainAlb(stack, 'test', vpc, false, undefined, undefined, false);
expect(stack).not.toHaveResourceLike('AWS::S3::Bucket', {});

const template = Template.fromStack(stack);

template.resourceCountIs('AWS::S3::Bucket', 0);
});

test('Test add single lambda target group with no customization', () => {
Expand All @@ -120,7 +135,9 @@ test('Test add single lambda target group with no customization', () => {
testFunction,
);

expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::Listener', {
const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', {
DefaultActions: [
{
TargetGroupArn: {
Expand All @@ -130,7 +147,7 @@ test('Test add single lambda target group with no customization', () => {
}
],
});
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::TargetGroup', {
template.hasResourceProperties('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetType: "lambda",
});

Expand All @@ -156,7 +173,9 @@ test('Test add single lambda target group with target group props', () => {
{ targetGroupName },
);

expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::TargetGroup', {
const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetType: "lambda",
Name: targetGroupName,
});
Expand Down Expand Up @@ -197,8 +216,10 @@ test('Test add rule props for second lambda target group', () => {
{ targetGroupName },
);

expect(stack).toCountResources('AWS::ElasticLoadBalancingV2::TargetGroup', 2);
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::ListenerRule', {
const template = Template.fromStack(stack);

template.resourceCountIs('AWS::ElasticLoadBalancingV2::TargetGroup', 2);
template.hasResourceProperties('AWS::ElasticLoadBalancingV2::ListenerRule', {
Conditions: [
{
Field: "path-pattern",
Expand Down Expand Up @@ -235,7 +256,9 @@ test('Test add single fargate target with no customization', () => {
}
);

expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::Listener', {
const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', {
DefaultActions: [
{
TargetGroupArn: {
Expand All @@ -245,7 +268,7 @@ test('Test add single fargate target with no customization', () => {
}
],
});
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::TargetGroup', {
template.hasResourceProperties('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetType: "ip",
});

Expand Down Expand Up @@ -290,8 +313,10 @@ test('Test add two fargate targets with rules', () => {
}
);

expect(stack).toCountResources('AWS::ElasticLoadBalancingV2::TargetGroup', 2);
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::ListenerRule', {
const template = Template.fromStack(stack);

template.resourceCountIs('AWS::ElasticLoadBalancingV2::TargetGroup', 2);
template.hasResourceProperties('AWS::ElasticLoadBalancingV2::ListenerRule', {
Conditions: [
{
Field: "path-pattern",
Expand All @@ -318,12 +343,14 @@ test('Test adding a listener with defaults', () => {
// Need to add a target because a listener is not allowed to exist without a target or action
defaults.AddLambdaTarget(stack, 'dummy-target', listener, CreateTestFunction(stack, 'dummy-function'));

const template = Template.fromStack(stack);

// This should create 2 listeners, HTTPS plus redirect of HTTP
expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::Listener', {
template.hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', {
Protocol: 'HTTPS',
});

expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::Listener', {
template.hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', {
Protocol: 'HTTP',
});
});
Expand Down Expand Up @@ -369,24 +396,12 @@ test('Test adding a HTTP listener', () => {
// Need to add a target because a listener is not allowed to exist without a target or action
defaults.AddLambdaTarget(stack, 'dummy-target', listener, CreateTestFunction(stack, 'dummy-function'));

expect(stack).toHaveResourceLike('AWS::ElasticLoadBalancingV2::Listener', {
const template = Template.fromStack(stack);

template.hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', {
Protocol: 'HTTP',
});
expect(stack).toCountResources('AWS::ElasticLoadBalancingV2::Listener', 1);
});

test('Test sending custom logging bucket props', () => {
const stack = new Stack();

// Set up test framework independent of our code for unit testing
const testVpc = defaults.getTestVpc(stack);
const testAlb = CreateTestLoadBalancer(stack, testVpc);

const listener = defaults.AddListener(stack, 'test', testAlb, { protocol: 'HTTP' });

// Need to add a target because a listener is not allowed to exist without a target or action
defaults.AddLambdaTarget(stack, 'dummy-target', listener, CreateTestFunction(stack, 'dummy-function'));

template.resourceCountIs('AWS::ElasticLoadBalancingV2::Listener', 1);
});

test('Test GetActiveListener with 0 listeners', () => {
Expand Down
Loading

0 comments on commit b4bbe63

Please sign in to comment.