Skip to content

Commit 65d8e3d

Browse files
authored
fix(iam): service principals use unnecessary exceptions (under feature flag) (#22819)
We have a database of service principal exceptions in different regions. This database is no longer necessary: all services now use the global service principal name for in-region references, and sometimes a standardized regional service principal name for cross-opt-in-region references. This PR changes the following things: ```ts new ServicePrincipal('service.amazonaws.com') // ➡️ always resolves to 'service.amazonaws.com', regardless of region // or service principal new ServicePrincipal('service.amazonaws.com', { region: 'me-south-1' }) // ➡️ resolves to 'service.me-south-1.amazonaws.com' in case of a // cross-region reference, or just 'service.amazonaws.com' otherwise. ``` Because change is scary (and because we are only 99% sure that this change has made it to all ADC regions), we put the new behavior behind a feature flag: ```json { "context": { "@aws-cdk/aws-iam:standardizedServicePrincipals": true } } ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6fe034c commit 65d8e3d

File tree

391 files changed

+4297
-9244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

391 files changed

+4297
-9244
lines changed

packages/@aws-cdk/aws-apigateway/test/integ.stepfunctions-api.js.snapshot/StepFunctionsRestApiDeploymentStack.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"files": {
4-
"15b69b6acb0a3b911686881039fd821b7be7a59737df5c36a7f1e7f0dc306c40": {
4+
"06411bc9644c9af466e4101cc159122b7c5422ecbd496553c2a2ef821687361c": {
55
"source": {
66
"path": "StepFunctionsRestApiDeploymentStack.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "15b69b6acb0a3b911686881039fd821b7be7a59737df5c36a7f1e7f0dc306c40.json",
12+
"objectKey": "06411bc9644c9af466e4101cc159122b7c5422ecbd496553c2a2ef821687361c.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/aws-apigateway/test/integ.stepfunctions-api.js.snapshot/StepFunctionsRestApiDeploymentStack.template.json

+1-103
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@
99
"Action": "sts:AssumeRole",
1010
"Effect": "Allow",
1111
"Principal": {
12-
"Service": {
13-
"Fn::FindInMap": [
14-
"ServiceprincipalMap",
15-
{
16-
"Ref": "AWS::Region"
17-
},
18-
"states"
19-
]
20-
}
12+
"Service": "states.amazonaws.com"
2113
}
2214
}
2315
],
@@ -290,100 +282,6 @@
290282
}
291283
}
292284
},
293-
"Mappings": {
294-
"ServiceprincipalMap": {
295-
"af-south-1": {
296-
"states": "states.af-south-1.amazonaws.com"
297-
},
298-
"ap-east-1": {
299-
"states": "states.ap-east-1.amazonaws.com"
300-
},
301-
"ap-northeast-1": {
302-
"states": "states.ap-northeast-1.amazonaws.com"
303-
},
304-
"ap-northeast-2": {
305-
"states": "states.ap-northeast-2.amazonaws.com"
306-
},
307-
"ap-northeast-3": {
308-
"states": "states.ap-northeast-3.amazonaws.com"
309-
},
310-
"ap-south-1": {
311-
"states": "states.ap-south-1.amazonaws.com"
312-
},
313-
"ap-southeast-1": {
314-
"states": "states.ap-southeast-1.amazonaws.com"
315-
},
316-
"ap-southeast-2": {
317-
"states": "states.ap-southeast-2.amazonaws.com"
318-
},
319-
"ap-southeast-3": {
320-
"states": "states.ap-southeast-3.amazonaws.com"
321-
},
322-
"ca-central-1": {
323-
"states": "states.ca-central-1.amazonaws.com"
324-
},
325-
"cn-north-1": {
326-
"states": "states.cn-north-1.amazonaws.com"
327-
},
328-
"cn-northwest-1": {
329-
"states": "states.cn-northwest-1.amazonaws.com"
330-
},
331-
"eu-central-1": {
332-
"states": "states.eu-central-1.amazonaws.com"
333-
},
334-
"eu-north-1": {
335-
"states": "states.eu-north-1.amazonaws.com"
336-
},
337-
"eu-south-1": {
338-
"states": "states.eu-south-1.amazonaws.com"
339-
},
340-
"eu-south-2": {
341-
"states": "states.eu-south-2.amazonaws.com"
342-
},
343-
"eu-west-1": {
344-
"states": "states.eu-west-1.amazonaws.com"
345-
},
346-
"eu-west-2": {
347-
"states": "states.eu-west-2.amazonaws.com"
348-
},
349-
"eu-west-3": {
350-
"states": "states.eu-west-3.amazonaws.com"
351-
},
352-
"me-south-1": {
353-
"states": "states.me-south-1.amazonaws.com"
354-
},
355-
"sa-east-1": {
356-
"states": "states.sa-east-1.amazonaws.com"
357-
},
358-
"us-east-1": {
359-
"states": "states.us-east-1.amazonaws.com"
360-
},
361-
"us-east-2": {
362-
"states": "states.us-east-2.amazonaws.com"
363-
},
364-
"us-gov-east-1": {
365-
"states": "states.us-gov-east-1.amazonaws.com"
366-
},
367-
"us-gov-west-1": {
368-
"states": "states.us-gov-west-1.amazonaws.com"
369-
},
370-
"us-iso-east-1": {
371-
"states": "states.amazonaws.com"
372-
},
373-
"us-iso-west-1": {
374-
"states": "states.amazonaws.com"
375-
},
376-
"us-isob-east-1": {
377-
"states": "states.amazonaws.com"
378-
},
379-
"us-west-1": {
380-
"states": "states.us-west-1.amazonaws.com"
381-
},
382-
"us-west-2": {
383-
"states": "states.us-west-2.amazonaws.com"
384-
}
385-
}
386-
},
387285
"Parameters": {
388286
"BootstrapVersion": {
389287
"Type": "AWS::SSM::Parameter::Value<String>",
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"20.0.0"}
1+
{"version":"21.0.0"}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"testCases": {
44
"step-functions-restapi/DefaultTest": {
55
"stacks": [
66
"StepFunctionsRestApiDeploymentStack"
77
],
8-
"assertionStack": "step-functions-restapi/DefaultTest/DeployAssert"
8+
"assertionStack": "step-functions-restapi/DefaultTest/DeployAssert",
9+
"assertionStackName": "stepfunctionsrestapiDefaultTestDeployAssert53C3797F"
910
}
1011
}
1112
}

packages/@aws-cdk/aws-apigateway/test/integ.stepfunctions-api.js.snapshot/manifest.json

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"artifacts": {
4-
"Tree": {
5-
"type": "cdk:tree",
6-
"properties": {
7-
"file": "tree.json"
8-
}
9-
},
104
"StepFunctionsRestApiDeploymentStack.assets": {
115
"type": "cdk:asset-manifest",
126
"properties": {
@@ -23,7 +17,7 @@
2317
"validateOnSynth": false,
2418
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2519
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/15b69b6acb0a3b911686881039fd821b7be7a59737df5c36a7f1e7f0dc306c40.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/06411bc9644c9af466e4101cc159122b7c5422ecbd496553c2a2ef821687361c.json",
2721
"requiresBootstrapStackVersion": 6,
2822
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2923
"additionalDependencies": [
@@ -105,12 +99,6 @@
10599
"data": "ApiEndpoint"
106100
}
107101
],
108-
"/StepFunctionsRestApiDeploymentStack/Service-principalMap": [
109-
{
110-
"type": "aws:cdk:logicalId",
111-
"data": "ServiceprincipalMap"
112-
}
113-
],
114102
"/StepFunctionsRestApiDeploymentStack/BootstrapVersion": [
115103
{
116104
"type": "aws:cdk:logicalId",
@@ -172,6 +160,12 @@
172160
]
173161
},
174162
"displayName": "step-functions-restapi/DefaultTest/DeployAssert"
163+
},
164+
"Tree": {
165+
"type": "cdk:tree",
166+
"properties": {
167+
"file": "tree.json"
168+
}
175169
}
176170
}
177171
}

packages/@aws-cdk/aws-apigateway/test/integ.stepfunctions-api.js.snapshot/stepfunctionsrestapiDefaultTestDeployAssert53C3797F.assets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"files": {
44
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
55
"source": {

packages/@aws-cdk/aws-apigateway/test/integ.stepfunctions-api.js.snapshot/tree.json

+49-31
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
"id": "App",
55
"path": "",
66
"children": {
7-
"Tree": {
8-
"id": "Tree",
9-
"path": "Tree",
10-
"constructInfo": {
11-
"fqn": "constructs.Construct",
12-
"version": "10.1.85"
13-
}
14-
},
157
"StepFunctionsRestApiDeploymentStack": {
168
"id": "StepFunctionsRestApiDeploymentStack",
179
"path": "StepFunctionsRestApiDeploymentStack",
@@ -44,15 +36,7 @@
4436
"Action": "sts:AssumeRole",
4537
"Effect": "Allow",
4638
"Principal": {
47-
"Service": {
48-
"Fn::FindInMap": [
49-
"ServiceprincipalMap",
50-
{
51-
"Ref": "AWS::Region"
52-
},
53-
"states"
54-
]
55-
}
39+
"Service": "states.amazonaws.com"
5640
}
5741
}
5842
],
@@ -453,22 +437,30 @@
453437
"id": "ApiEndpoint",
454438
"path": "StepFunctionsRestApiDeploymentStack/ApiEndpoint",
455439
"constructInfo": {
456-
"fqn": "constructs.Construct",
457-
"version": "10.1.85"
440+
"fqn": "@aws-cdk/core.CfnOutput",
441+
"version": "0.0.0"
458442
}
459443
},
460-
"Service-principalMap": {
461-
"id": "Service-principalMap",
462-
"path": "StepFunctionsRestApiDeploymentStack/Service-principalMap",
444+
"BootstrapVersion": {
445+
"id": "BootstrapVersion",
446+
"path": "StepFunctionsRestApiDeploymentStack/BootstrapVersion",
463447
"constructInfo": {
464-
"fqn": "constructs.Construct",
465-
"version": "10.1.85"
448+
"fqn": "@aws-cdk/core.CfnParameter",
449+
"version": "0.0.0"
450+
}
451+
},
452+
"CheckBootstrapVersion": {
453+
"id": "CheckBootstrapVersion",
454+
"path": "StepFunctionsRestApiDeploymentStack/CheckBootstrapVersion",
455+
"constructInfo": {
456+
"fqn": "@aws-cdk/core.CfnRule",
457+
"version": "0.0.0"
466458
}
467459
}
468460
},
469461
"constructInfo": {
470-
"fqn": "constructs.Construct",
471-
"version": "10.1.85"
462+
"fqn": "@aws-cdk/core.Stack",
463+
"version": "0.0.0"
472464
}
473465
},
474466
"step-functions-restapi": {
@@ -484,15 +476,33 @@
484476
"path": "step-functions-restapi/DefaultTest/Default",
485477
"constructInfo": {
486478
"fqn": "constructs.Construct",
487-
"version": "10.1.85"
479+
"version": "10.1.140"
488480
}
489481
},
490482
"DeployAssert": {
491483
"id": "DeployAssert",
492484
"path": "step-functions-restapi/DefaultTest/DeployAssert",
485+
"children": {
486+
"BootstrapVersion": {
487+
"id": "BootstrapVersion",
488+
"path": "step-functions-restapi/DefaultTest/DeployAssert/BootstrapVersion",
489+
"constructInfo": {
490+
"fqn": "@aws-cdk/core.CfnParameter",
491+
"version": "0.0.0"
492+
}
493+
},
494+
"CheckBootstrapVersion": {
495+
"id": "CheckBootstrapVersion",
496+
"path": "step-functions-restapi/DefaultTest/DeployAssert/CheckBootstrapVersion",
497+
"constructInfo": {
498+
"fqn": "@aws-cdk/core.CfnRule",
499+
"version": "0.0.0"
500+
}
501+
}
502+
},
493503
"constructInfo": {
494-
"fqn": "constructs.Construct",
495-
"version": "10.1.85"
504+
"fqn": "@aws-cdk/core.Stack",
505+
"version": "0.0.0"
496506
}
497507
}
498508
},
@@ -506,11 +516,19 @@
506516
"fqn": "@aws-cdk/integ-tests.IntegTest",
507517
"version": "0.0.0"
508518
}
519+
},
520+
"Tree": {
521+
"id": "Tree",
522+
"path": "Tree",
523+
"constructInfo": {
524+
"fqn": "constructs.Construct",
525+
"version": "10.1.140"
526+
}
509527
}
510528
},
511529
"constructInfo": {
512-
"fqn": "constructs.Construct",
513-
"version": "10.1.85"
530+
"fqn": "@aws-cdk/core.App",
531+
"version": "0.0.0"
514532
}
515533
}
516534
}

packages/@aws-cdk/aws-appsync/test/integ.auth-apikey.js.snapshot/aws-appsync-integ.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"files": {
4-
"b0462850439179659920597f4327262b24073af4f4969622163b0a295fce1dda": {
4+
"8af15bf3b17fb15e9d1b558caa4d5484d9b85fd19d3d939c866e805212d8d66a": {
55
"source": {
66
"path": "aws-appsync-integ.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "b0462850439179659920597f4327262b24073af4f4969622163b0a295fce1dda.json",
12+
"objectKey": "8af15bf3b17fb15e9d1b558caa4d5484d9b85fd19d3d939c866e805212d8d66a.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/aws-appsync/test/integ.auth-apikey.js.snapshot/aws-appsync-integ.template.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"Action": "sts:AssumeRole",
4343
"Effect": "Allow",
4444
"Principal": {
45-
"Service": "appsync.amazonaws.com"
45+
"Service": "appsync"
4646
}
4747
}
4848
],
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"20.0.0"}
1+
{"version":"21.0.0"}

packages/@aws-cdk/aws-appsync/test/integ.auth-apikey.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"testCases": {
44
"integ.auth-apikey": {
55
"stacks": [

0 commit comments

Comments
 (0)