Skip to content

Commit

Permalink
Merge branch 'master' into fix-proxy-support-for-eks-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 28, 2021
2 parents 5156748 + be6aa2e commit 5760312
Show file tree
Hide file tree
Showing 48 changed files with 389 additions and 391 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"fast-check": "^2.17.0",
"jest": "^26.6.3",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
"@aws-cdk/assertions": "0.0.0"
},
"dependencies": {
"@aws-cdk/aws-autoscaling-common": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { Match, Template } from '@aws-cdk/assertions';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as cdk from '@aws-cdk/core';
import * as appscaling from '../lib';
Expand All @@ -19,7 +19,7 @@ describe('scalable target', () => {
});

// THEN
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalableTarget', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalableTarget', {
ServiceNamespace: 'dynamodb',
ScalableDimension: 'test:TestCount',
ResourceId: 'test:this/test',
Expand All @@ -44,7 +44,7 @@ describe('scalable target', () => {
});

// THEN: no exception
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalableTarget', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalableTarget', {
ServiceNamespace: 'dynamodb',
ScalableDimension: 'test:TestCount',
ResourceId: 'test:this/test',
Expand All @@ -68,7 +68,7 @@ describe('scalable target', () => {
});

// THEN
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalableTarget', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalableTarget', {
ScheduledActions: [
{
ScalableTargetAction: {
Expand Down Expand Up @@ -109,11 +109,11 @@ describe('scalable target', () => {
});

// THEN
expect(stack).not.toHaveResource('AWS::CloudWatch::Alarm', {
Period: 60,
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', {
Period: Match.absentProperty(),
});

expect(stack).toHaveResource('AWS::CloudWatch::Alarm', {
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', {
ComparisonOperator: 'LessThanOrEqualToThreshold',
EvaluationPeriods: 1,
Metrics: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { SynthUtils } from '@aws-cdk/assert-internal';
import { Template } from '@aws-cdk/assertions';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as cdk from '@aws-cdk/core';
import * as fc from 'fast-check';
Expand Down Expand Up @@ -132,7 +131,7 @@ describe('step scaling policy', () => {
});

// THEN
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalingPolicy', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
PolicyType: 'StepScaling',
ScalingTargetId: {
Ref: 'Target3191CF44',
Expand Down Expand Up @@ -169,14 +168,14 @@ describe('step scaling policy', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::ApplicationAutoScaling::ScalingPolicy', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
PolicyType: 'StepScaling',
StepScalingPolicyConfiguration: {
AdjustmentType: 'ChangeInCapacity',
MetricAggregationType: 'Average',
},
});
expect(stack).toHaveResource('AWS::CloudWatch::Alarm', {
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', {
ComparisonOperator: 'GreaterThanOrEqualToThreshold',
EvaluationPeriods: 1,
AlarmActions: [
Expand Down Expand Up @@ -209,14 +208,14 @@ describe('step scaling policy', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::ApplicationAutoScaling::ScalingPolicy', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
PolicyType: 'StepScaling',
StepScalingPolicyConfiguration: {
AdjustmentType: 'ChangeInCapacity',
MetricAggregationType: 'Maximum',
},
});
expect(stack).toHaveResource('AWS::CloudWatch::Alarm', {
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', {
ComparisonOperator: 'GreaterThanOrEqualToThreshold',
EvaluationPeriods: 10,
ExtendedStatistic: 'p99',
Expand All @@ -241,7 +240,7 @@ function setupStepScaling(intervals: appscaling.ScalingInterval[]) {
scalingSteps: intervals,
});

return new ScalingStackTemplate(SynthUtils.synthesize(stack).template);
return new ScalingStackTemplate(Template.fromStack(stack).toJSON());
}

class ScalingStackTemplate {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { Template } from '@aws-cdk/assertions';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as cdk from '@aws-cdk/core';
import * as appscaling from '../lib';
Expand All @@ -17,7 +17,7 @@ describe('target tracking', () => {
});

// THEN
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalingPolicy', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
PolicyType: 'TargetTrackingScaling',
TargetTrackingScalingPolicyConfiguration: {
PredefinedMetricSpecification: { PredefinedMetricType: 'EC2SpotFleetRequestAverageCPUUtilization' },
Expand All @@ -41,7 +41,7 @@ describe('target tracking', () => {
});

// THEN
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalingPolicy', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
PolicyType: 'TargetTrackingScaling',
TargetTrackingScalingPolicyConfiguration: {
PredefinedMetricSpecification: { PredefinedMetricType: 'LambdaProvisionedConcurrencyUtilization' },
Expand All @@ -65,7 +65,7 @@ describe('target tracking', () => {
});

// THEN
expect(stack).toHaveResource('AWS::ApplicationAutoScaling::ScalingPolicy', {
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
PolicyType: 'TargetTrackingScaling',
TargetTrackingScalingPolicyConfiguration: {
CustomizedMetricSpecification: {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
"@aws-cdk/assertions": "0.0.0"
},
"dependencies": {
"@aws-cdk/aws-codestarnotifications": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { ABSENT } from '@aws-cdk/assert-internal';
import { Match, Template } from '@aws-cdk/assertions';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as iam from '@aws-cdk/aws-iam';
import * as logs from '@aws-cdk/aws-logs';
Expand All @@ -21,7 +20,7 @@ describe('SlackChannelConfiguration', () => {
slackChannelConfigurationName: 'Test',
});

expect(stack).toHaveResourceLike('AWS::Chatbot::SlackChannelConfiguration', {
Template.fromStack(stack).hasResourceProperties('AWS::Chatbot::SlackChannelConfiguration', {
ConfigurationName: 'Test',
IamRoleArn: {
'Fn::GetAtt': [
Expand All @@ -33,7 +32,7 @@ describe('SlackChannelConfiguration', () => {
SlackWorkspaceId: 'ABC123',
});

expect(stack).toHaveResourceLike('AWS::IAM::Role', {
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', {
AssumeRolePolicyDocument: {
Statement: [
{
Expand All @@ -57,7 +56,7 @@ describe('SlackChannelConfiguration', () => {
loggingLevel: chatbot.LoggingLevel.ERROR,
});

expect(stack).toHaveResourceLike('AWS::Chatbot::SlackChannelConfiguration', {
Template.fromStack(stack).hasResourceProperties('AWS::Chatbot::SlackChannelConfiguration', {
ConfigurationName: 'Test',
IamRoleArn: {
'Fn::GetAtt': [
Expand All @@ -81,7 +80,7 @@ describe('SlackChannelConfiguration', () => {
notificationTopics: [topic],
});

expect(stack).toHaveResourceLike('AWS::Chatbot::SlackChannelConfiguration', {
Template.fromStack(stack).hasResourceProperties('AWS::Chatbot::SlackChannelConfiguration', {
ConfigurationName: 'Test',
IamRoleArn: {
'Fn::GetAtt': [
Expand Down Expand Up @@ -109,7 +108,7 @@ describe('SlackChannelConfiguration', () => {
role: role,
});

expect(stack).toCountResources('AWS::IAM::Role', 0);
Template.fromStack(stack).resourceCountIs('AWS::IAM::Role', 0);
});

test('created with new role and extra iam policies', () => {
Expand All @@ -127,7 +126,7 @@ describe('SlackChannelConfiguration', () => {
resources: ['arn:aws:s3:::abc/xyz/123.txt'],
}));

expect(stack).toHaveResourceLike('AWS::IAM::Policy', {
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
PolicyDocument: {
Statement: [
{
Expand All @@ -149,7 +148,7 @@ describe('SlackChannelConfiguration', () => {
logRetention: logs.RetentionDays.ONE_MONTH,
});

expect(stack).toHaveResourceLike('Custom::LogRetention', {
Template.fromStack(stack).hasResourceProperties('Custom::LogRetention', {
LogGroupName: '/aws/chatbot/ConfigurationName',
RetentionInDays: 30,
LogGroupRegion: 'us-east-1',
Expand Down Expand Up @@ -179,7 +178,7 @@ describe('SlackChannelConfiguration', () => {
},
metricName: 'MetricName',
}));
expect(stack).toHaveResourceLike('AWS::CloudWatch::Alarm', {
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', {
Namespace: 'AWS/Chatbot',
MetricName: 'MetricName',
Dimensions: [
Expand Down Expand Up @@ -208,10 +207,10 @@ describe('SlackChannelConfiguration', () => {
region: 'us-east-1',
metricName: 'MetricName',
}));
expect(stack).toHaveResourceLike('AWS::CloudWatch::Alarm', {
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', {
Namespace: 'AWS/Chatbot',
MetricName: 'MetricName',
Dimensions: ABSENT,
Dimensions: Match.absentProperty(),
ComparisonOperator: 'GreaterThanThreshold',
EvaluationPeriods: 1,
Threshold: 0,
Expand All @@ -229,8 +228,8 @@ describe('SlackChannelConfiguration', () => {
resources: ['arn:aws:s3:::abc/xyz/123.txt'],
}));

expect(stack).toCountResources('AWS::IAM::Role', 0);
expect(stack).toCountResources('AWS::IAM::Policy', 0);
Template.fromStack(stack).resourceCountIs('AWS::IAM::Role', 0);
Template.fromStack(stack).resourceCountIs('AWS::IAM::Policy', 0);
});

test('should throw error if ARN invalid', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codecommit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"cfn2ts": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
"@aws-cdk/assertions": "0.0.0"
},
"dependencies": {
"@aws-cdk/aws-codestarnotifications": "0.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-codecommit/test/codecommit.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { Template } from '@aws-cdk/assertions';
import { Role, ServicePrincipal } from '@aws-cdk/aws-iam';
import { Stack } from '@aws-cdk/core';
import { Repository, RepositoryProps } from '../lib';
Expand All @@ -16,7 +16,7 @@ describe('codecommit', () => {

new Repository(stack, 'MyRepository', props).notify(snsArn);

expect(stack).toMatchTemplate({
Template.fromStack(stack).templateMatches({
Resources: {
MyRepository4C4BD5FC: {
Type: 'AWS::CodeCommit::Repository',
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('codecommit', () => {
repository.grantPullPush(role);

// THEN
expect(stack).toHaveResource('AWS::IAM::Policy', {
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
PolicyDocument: {
Statement: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { Template } from '@aws-cdk/assertions';
import * as sns from '@aws-cdk/aws-sns';
import * as cdk from '@aws-cdk/core';
import * as codecommit from '../lib';
Expand All @@ -16,7 +16,7 @@ describe('notification rule', () => {

repository.notifiyOnPullRequestMerged('NotifyOnPullRequestMerged', target);

expect(stack).toHaveResource('AWS::CodeStarNotifications::NotificationRule', {
Template.fromStack(stack).hasResourceProperties('AWS::CodeStarNotifications::NotificationRule', {
Name: 'MyCodecommitRepositoryNotifyOnPullRequestCreatedBB14EA32',
DetailType: 'FULL',
EventTypeIds: [
Expand All @@ -38,7 +38,7 @@ describe('notification rule', () => {
],
});

expect(stack).toHaveResource('AWS::CodeStarNotifications::NotificationRule', {
Template.fromStack(stack).hasResourceProperties('AWS::CodeStarNotifications::NotificationRule', {
Name: 'MyCodecommitRepositoryNotifyOnPullRequestMerged34A7EDF1',
DetailType: 'FULL',
EventTypeIds: [
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"cfn2ts": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
"@aws-cdk/assertions": "0.0.0"
},
"dependencies": {
"@aws-cdk/aws-codestarnotifications": "0.0.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/@aws-cdk/aws-codepipeline/test/action.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { Match, Template } from '@aws-cdk/assertions';
import * as iam from '@aws-cdk/aws-iam';
import * as cdk from '@aws-cdk/core';
import * as codepipeline from '../lib';
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('action', () => {
});

expect(() => {
expect(stack).toHaveResourceLike('AWS::CodePipeline::Pipeline', {
Template.fromStack(stack).hasResourceProperties('AWS::CodePipeline::Pipeline', {
});
}).toThrow(/Build\/Fake cannot have more than 3 input artifacts/);

Expand Down Expand Up @@ -166,7 +166,7 @@ describe('action', () => {
});

expect(() => {
expect(stack).toHaveResourceLike('AWS::CodePipeline::Pipeline', {
Template.fromStack(stack).hasResourceProperties('AWS::CodePipeline::Pipeline', {
});
}).toThrow(/Source\/Fake cannot have more than 4 output artifacts/);

Expand Down Expand Up @@ -199,25 +199,25 @@ describe('action', () => {
],
});

expect(stack).toHaveResourceLike('AWS::CodePipeline::Pipeline', {
Template.fromStack(stack).hasResourceProperties('AWS::CodePipeline::Pipeline', {
'Stages': [
{
'Name': 'Source',
'Actions': [
{
Match.objectLike({
'Name': 'CodeCommit',
'OutputArtifacts': [
{
'Name': 'Artifact_Source_CodeCommit',
},
],
},
}),
],
},
{
'Name': 'Build',
'Actions': [
{
Match.objectLike({
'Name': 'CodeBuild',
'InputArtifacts': [
{
Expand All @@ -229,7 +229,7 @@ describe('action', () => {
'Name': 'Artifact_Build_CodeBuild',
},
],
},
}),
],
},
],
Expand Down
Loading

0 comments on commit 5760312

Please sign in to comment.