Skip to content

Commit

Permalink
Merge branch 'main' into merge-back/2.37.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Aug 10, 2022
2 parents f15dee0 + 3d259d6 commit aeae861
Show file tree
Hide file tree
Showing 105 changed files with 5,769 additions and 815 deletions.
2 changes: 1 addition & 1 deletion MANUAL_INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ its signature against our public signing key. To do so, you need
the following things:

* [GNU Privacy Guard](https://gnupg.org/) needs to be installed.
* Download our public key: https://s3.amazonaws.com/aws-cdk-beta/cdk-team.asc
* Download our public key: https://docs.aws.amazon.com/cdk/v2/guide/pgp-keys.html
* Make sure you have downloaded both `aws-cdk-x.y.z.zip`
and `aws-cdk-x.y.z.zip.sig`.

Expand Down
4 changes: 4 additions & 0 deletions allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.onFai
# removed kubernetes version from EKS
removed:@aws-cdk/aws-eks.KubernetesVersion.V1_22

# change the type of vpcEndpoint from ec2.IInterfaceVpcEndpoint to ec2.InterfaceVpcEndpoint.
# even though it accepted IInterfaceVpcEndpoint, the actual implementation required a
# managed construct ec2.InterfaceVpcEndpoint
incompatible-argument:@aws-cdk/aws-route53-targets.InterfaceVpcEndpointTarget.<initializer>
# changed the type of requiresBootstrapStackVersion to Optional<number> (formerly number)
# to allow the CLI to skip validating the bootstrap stack when the stack is not needed
changed-type:@aws-cdk/cx-api.AssetManifestArtifact.requiresBootstrapStackVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/aws-lambda": "^8.10.101",
"@types/aws-lambda": "^8.10.102",
"@aws-cdk/integ-tests": "0.0.0",
"@types/jest": "^27.5.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/aws-lambda": "^8.10.101",
"@types/aws-lambda": "^8.10.102",
"@types/sinon": "^9.0.11",
"@aws-cdk/cdk-build-tools": "0.0.0",
"aws-sdk": "^2.596.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/aws-lambda": "^8.10.101",
"@types/aws-lambda": "^8.10.102",
"@types/jest": "^27.5.2",
"jest": "^27.5.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export class ResponseHeadersPolicy extends Resource implements IResponseHeadersP
physicalName: props.responseHeadersPolicyName,
});

const responseHeadersPolicyName = props.responseHeadersPolicyName ?? Names.uniqueId(this);
const responseHeadersPolicyName = props.responseHeadersPolicyName ?? Names.uniqueResourceName(this, {
maxLength: 128,
});

const resource = new CfnResponseHeadersPolicy(this, 'Resource', {
responseHeadersPolicyConfig: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,14 @@ describe('ResponseHeadersPolicy', () => {
},
});
});

test('it truncates long auto-generated names', () => {
new ResponseHeadersPolicy(stack, 'AVeryLongIdThatMightSeemRidiculousButSometimesHappensInCdkPipelinesBecauseTheStageNamesConcatenatedWithTheRegionAreQuiteLongMuchLongerThanYouWouldExpect');

Template.fromStack(stack).hasResourceProperties('AWS::CloudFront::ResponseHeadersPolicy', {
ResponseHeadersPolicyConfig: {
Name: 'StackAVeryLongIdThatMightSeemRidiculousButSometimesHappensIntenatedWithTheRegionAreQuiteLongMuchLongerThanYouWouldExpect39083892',
},
});
});
});
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ alarm.addAlarmAction(
);
```

## SSM Incident Manager Action Example

```ts
declare const alarm: cloudwatch.Alarm;
// Create an Incident Manager incident based on a specific response plan
alarm.addAlarmAction(
new actions.SsmIncidentAction('ResponsePlanName')
);
```

See `@aws-cdk/aws-cloudwatch` for more information.
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch-actions/lib/ssm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,20 @@ export class SsmAction implements cloudwatch.IAlarmAction {
}
}

/**
* Use an SSM Incident Response Plan as an Alarm action
*/
export class SsmIncidentAction implements cloudwatch.IAlarmAction {
constructor(private readonly responsePlanName: string) {}

/**
* Returns an alarm action configuration to use an SSM Incident as an alarm action
* based on an Incident Manager Response Plan
*/
bind(_scope: Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig {
return {
alarmActionArn: `arn:${Stack.of(_scope).partition}:ssm-incidents::${Stack.of(_scope).account}:response-plan/${this.responsePlanName}`,
};
}
}

3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@
"devDependencies": {
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-ssmincidents": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as ssmIncidents from '@aws-cdk/aws-ssmincidents';
import { App, Stack, StackProps } from '@aws-cdk/core';
import * as integ from '@aws-cdk/integ-tests';

import * as cloudwatchActions from '../lib';

class SsmIncidentAlarmActionIntegrationTestStack extends Stack {

constructor(scope: App, id: string, props?: StackProps) {
super(scope, id, props);

const responsePlanName = 'test-response-plan';

new ssmIncidents.CfnResponsePlan(this, 'ResponsePlan', {
name: responsePlanName,
incidentTemplate: {
title: 'Incident Title',
impact: 1,
},
});

const metric = new cloudwatch.Metric({
namespace: 'CDK/Test',
metricName: 'Metric',
label: 'Metric [AVG: ${AVG}]',
});

const alarm = new cloudwatch.Alarm(this, 'Alarm1', {
metric,
threshold: 100,
evaluationPeriods: 3,
});

alarm.addAlarmAction(new cloudwatchActions.SsmIncidentAction(responsePlanName));
}
}

const app = new App();

const stack = new SsmIncidentAlarmActionIntegrationTestStack(app, 'SsmIncidentAlarmActionIntegrationTestStack');

new integ.IntegTest(app, 'SsmIncidentManagerAlarmActionTest', {
testCases: [stack],
});

app.synth();
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"Resources": {
"ResponsePlan": {
"Type": "AWS::SSMIncidents::ResponsePlan",
"Properties": {
"IncidentTemplate": {
"Impact": 1,
"Title": "Incident Title"
},
"Name": "test-response-plan"
}
},
"Alarm1F9009D71": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"EvaluationPeriods": 3,
"AlarmActions": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":ssm-incidents::",
{
"Ref": "AWS::AccountId"
},
":response-plan/test-response-plan"
]
]
}
],
"Metrics": [
{
"Id": "m1",
"Label": "Metric [AVG: ${AVG}]",
"MetricStat": {
"Metric": {
"MetricName": "Metric",
"Namespace": "CDK/Test"
},
"Period": 300,
"Stat": "Average"
},
"ReturnData": true
}
],
"Threshold": 100
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"20.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "20.0.0",
"testCases": {
"SsmIncidentManagerAlarmActionTest/DefaultTest": {
"stacks": [
"SsmIncidentAlarmActionIntegrationTestStack"
],
"assertionStack": "SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"version": "20.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"SsmIncidentAlarmActionIntegrationTestStack": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "SsmIncidentAlarmActionIntegrationTestStack.template.json",
"validateOnSynth": false
},
"metadata": {
"/SsmIncidentAlarmActionIntegrationTestStack/ResponsePlan": [
{
"type": "aws:cdk:logicalId",
"data": "ResponsePlan"
}
],
"/SsmIncidentAlarmActionIntegrationTestStack/Alarm1/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "Alarm1F9009D71"
}
]
},
"displayName": "SsmIncidentAlarmActionIntegrationTestStack"
},
"SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0.template.json",
"validateOnSynth": false
},
"displayName": "SsmIncidentManagerAlarmActionTest/DefaultTest/DeployAssert"
}
}
}
Loading

0 comments on commit aeae861

Please sign in to comment.