Skip to content

Commit 7af20ba

Browse files
authored
feat(apigateway): set RestApi CloudWatchRole and Account retention policy (#26836)
Adds a `cloudWatchRoleRemovalPolicy` property to `RestApiBaseProps` that allows to specify a custom retention policy for CloudWatchRole and Account. Defaults to `RemovalPolicy.RETAIN`. Closes #26827. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent dd912da commit 7af20ba

12 files changed

+813
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "33.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"33.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "33.0.0",
3+
"testCases": {
4+
"apigateway-restapi-cloudwatch-removal-policy/DefaultTest": {
5+
"stacks": [
6+
"test-apigateway-restapi-cloudwatch-removal-policy"
7+
],
8+
"assertionStack": "apigateway-restapi-cloudwatch-removal-policy/DefaultTest/DeployAssert",
9+
"assertionStackName": "apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"version": "33.0.0",
3+
"artifacts": {
4+
"test-apigateway-restapi-cloudwatch-removal-policy.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "test-apigateway-restapi-cloudwatch-removal-policy.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"test-apigateway-restapi-cloudwatch-removal-policy": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://unknown-account/unknown-region",
15+
"properties": {
16+
"templateFile": "test-apigateway-restapi-cloudwatch-removal-policy.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ad0976eb05657cb79673c3a947078cdcaaac49665eb861a3a4d2e6eeb5774489.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"test-apigateway-restapi-cloudwatch-removal-policy.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"test-apigateway-restapi-cloudwatch-removal-policy.assets"
34+
],
35+
"metadata": {
36+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "myapi4C7BF186"
40+
}
41+
],
42+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/CloudWatchRole/Resource": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "myapiCloudWatchRole095452E5"
46+
}
47+
],
48+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/Account": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "myapiAccountEC421A0A"
52+
}
53+
],
54+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/Deployment/Resource": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "myapiDeployment92F2CB4972a890db5063ec679071ba7eefc76f2a"
58+
}
59+
],
60+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/DeploymentStage.prod/Resource": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "myapiDeploymentStageprod298F01AF"
64+
}
65+
],
66+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/Endpoint": [
67+
{
68+
"type": "aws:cdk:logicalId",
69+
"data": "myapiEndpoint3628AFE3"
70+
}
71+
],
72+
"/test-apigateway-restapi-cloudwatch-removal-policy/my-api/Default/GET/Resource": [
73+
{
74+
"type": "aws:cdk:logicalId",
75+
"data": "myapiGETF990CE3C"
76+
}
77+
],
78+
"/test-apigateway-restapi-cloudwatch-removal-policy/BootstrapVersion": [
79+
{
80+
"type": "aws:cdk:logicalId",
81+
"data": "BootstrapVersion"
82+
}
83+
],
84+
"/test-apigateway-restapi-cloudwatch-removal-policy/CheckBootstrapVersion": [
85+
{
86+
"type": "aws:cdk:logicalId",
87+
"data": "CheckBootstrapVersion"
88+
}
89+
]
90+
},
91+
"displayName": "test-apigateway-restapi-cloudwatch-removal-policy"
92+
},
93+
"apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A.assets": {
94+
"type": "cdk:asset-manifest",
95+
"properties": {
96+
"file": "apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A.assets.json",
97+
"requiresBootstrapStackVersion": 6,
98+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
99+
}
100+
},
101+
"apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A": {
102+
"type": "aws:cloudformation:stack",
103+
"environment": "aws://unknown-account/unknown-region",
104+
"properties": {
105+
"templateFile": "apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A.template.json",
106+
"validateOnSynth": false,
107+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
108+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
109+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
110+
"requiresBootstrapStackVersion": 6,
111+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
112+
"additionalDependencies": [
113+
"apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A.assets"
114+
],
115+
"lookupRole": {
116+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
117+
"requiresBootstrapStackVersion": 8,
118+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
119+
}
120+
},
121+
"dependencies": [
122+
"apigatewayrestapicloudwatchremovalpolicyDefaultTestDeployAssert35AFDA9A.assets"
123+
],
124+
"metadata": {
125+
"/apigateway-restapi-cloudwatch-removal-policy/DefaultTest/DeployAssert/BootstrapVersion": [
126+
{
127+
"type": "aws:cdk:logicalId",
128+
"data": "BootstrapVersion"
129+
}
130+
],
131+
"/apigateway-restapi-cloudwatch-removal-policy/DefaultTest/DeployAssert/CheckBootstrapVersion": [
132+
{
133+
"type": "aws:cdk:logicalId",
134+
"data": "CheckBootstrapVersion"
135+
}
136+
]
137+
},
138+
"displayName": "apigateway-restapi-cloudwatch-removal-policy/DefaultTest/DeployAssert"
139+
},
140+
"Tree": {
141+
"type": "cdk:tree",
142+
"properties": {
143+
"file": "tree.json"
144+
}
145+
}
146+
}
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "33.0.0",
3+
"files": {
4+
"ad0976eb05657cb79673c3a947078cdcaaac49665eb861a3a4d2e6eeb5774489": {
5+
"source": {
6+
"path": "test-apigateway-restapi-cloudwatch-removal-policy.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "ad0976eb05657cb79673c3a947078cdcaaac49665eb861a3a4d2e6eeb5774489.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)