Skip to content

Commit ba8e659

Browse files
authored
Merge branch 'main' into merge-back/2.159.1
2 parents c66f4e3 + 96e799e commit ba8e659

25 files changed

+5915
-202
lines changed

packages/@aws-cdk/aws-cognito-identitypool-alpha/lib/identitypool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
CfnIdentityPool,
3-
UserPool,
4-
UserPoolClient,
3+
IUserPool,
4+
IUserPoolClient,
55
} from 'aws-cdk-lib/aws-cognito';
66
import {
77
IOpenIdConnectProvider,
@@ -158,7 +158,7 @@ export class IdentityPoolProviderUrl {
158158
}
159159

160160
/** User Pool Provider Url */
161-
public static userPool(userPool: UserPool, userPoolClient: UserPoolClient): IdentityPoolProviderUrl {
161+
public static userPool(userPool: IUserPool, userPoolClient: IUserPoolClient): IdentityPoolProviderUrl {
162162
const url = `${userPool.userPoolProviderName}:${userPoolClient.userPoolClientId}`;
163163
return new IdentityPoolProviderUrl(IdentityPoolProviderType.USER_POOL, url);
164164
}

packages/@aws-cdk/aws-cognito-identitypool-alpha/test/identitypool.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
} from 'aws-cdk-lib/assertions';
44
import {
55
UserPool,
6+
UserPoolClient,
67
UserPoolIdentityProvider,
78
} from 'aws-cdk-lib/aws-cognito';
89
import {
@@ -728,4 +729,39 @@ describe('role mappings', () => {
728729
},
729730
});
730731
});
732+
733+
test('role mapping with an imported user pool and client', () => {
734+
const stack = new Stack();
735+
const importedPool = UserPool.fromUserPoolArn(stack, 'ImportedPool', 'arn:aws:cognito-idp:us-east-1:0123456789012:userpool/test-user-pool');
736+
const importedClient = UserPoolClient.fromUserPoolClientId(stack, 'ImportedPoolClient', 'client-id');
737+
new IdentityPool(stack, 'TestIdentityPoolRoleMappingRules', {
738+
roleMappings: [{
739+
mappingKey: 'cognito',
740+
providerUrl: IdentityPoolProviderUrl.userPool(importedPool, importedClient),
741+
useToken: true,
742+
}],
743+
});
744+
const temp = Template.fromStack(stack);
745+
temp.resourceCountIs('AWS::Cognito::IdentityPoolRoleAttachment', 1);
746+
temp.hasResourceProperties('AWS::Cognito::IdentityPoolRoleAttachment', {
747+
IdentityPoolId: {
748+
Ref: 'TestIdentityPoolRoleMappingRulesC8C07BC3',
749+
},
750+
RoleMappings: {
751+
cognito: {
752+
IdentityProvider: {
753+
'Fn::Join': [
754+
'',
755+
[
756+
'cognito-idp.us-east-1.',
757+
{ Ref: 'AWS::URLSuffix' },
758+
'/test-user-pool:client-id',
759+
],
760+
],
761+
},
762+
Type: 'Token',
763+
},
764+
},
765+
});
766+
});
731767
});

packages/@aws-cdk/aws-cognito-identitypool-alpha/test/integ.identitypool.js.snapshot/cdk.out

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-cognito-identitypool-alpha/test/integ.identitypool.js.snapshot/integ-identitypool.assets.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-cognito-identitypool-alpha/test/integ.identitypool.js.snapshot/integ-identitypool.template.json

Lines changed: 187 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
"PooltestClientFE8D4935": {
3535
"Type": "AWS::Cognito::UserPoolClient",
3636
"Properties": {
37-
"UserPoolId": {
38-
"Ref": "PoolD3F588B8"
39-
},
4037
"AllowedOAuthFlows": [
4138
"implicit",
4239
"code"
@@ -57,17 +54,15 @@
5754
"Ref": "PoolProviderGoogle76A1E8D0"
5855
},
5956
"COGNITO"
60-
]
57+
],
58+
"UserPoolId": {
59+
"Ref": "PoolD3F588B8"
60+
}
6161
}
6262
},
6363
"PoolProviderGoogle76A1E8D0": {
6464
"Type": "AWS::Cognito::UserPoolIdentityProvider",
6565
"Properties": {
66-
"ProviderName": "Google",
67-
"ProviderType": "Google",
68-
"UserPoolId": {
69-
"Ref": "PoolD3F588B8"
70-
},
7166
"AttributeMapping": {
7267
"given_name": "given_name",
7368
"family_name": "family_name",
@@ -79,6 +74,11 @@
7974
"client_id": "google-client-id",
8075
"client_secret": "google-client-secret",
8176
"authorize_scopes": "profile"
77+
},
78+
"ProviderName": "Google",
79+
"ProviderType": "Google",
80+
"UserPoolId": {
81+
"Ref": "PoolD3F588B8"
8282
}
8383
}
8484
},
@@ -116,9 +116,6 @@
116116
"OtherPoolUserPoolAuthenticationProviderClient08F670F8": {
117117
"Type": "AWS::Cognito::UserPoolClient",
118118
"Properties": {
119-
"UserPoolId": {
120-
"Ref": "OtherPool7DA7F2F7"
121-
},
122119
"AllowedOAuthFlows": [
123120
"implicit",
124121
"code"
@@ -139,17 +136,15 @@
139136
"Ref": "OtherPoolProviderAmazon4EB0592F"
140137
},
141138
"COGNITO"
142-
]
139+
],
140+
"UserPoolId": {
141+
"Ref": "OtherPool7DA7F2F7"
142+
}
143143
}
144144
},
145145
"OtherPoolProviderAmazon4EB0592F": {
146146
"Type": "AWS::Cognito::UserPoolIdentityProvider",
147147
"Properties": {
148-
"ProviderName": "LoginWithAmazon",
149-
"ProviderType": "LoginWithAmazon",
150-
"UserPoolId": {
151-
"Ref": "OtherPool7DA7F2F7"
152-
},
153148
"AttributeMapping": {
154149
"given_name": "name",
155150
"email": "email",
@@ -159,14 +154,76 @@
159154
"client_id": "amzn-client-id",
160155
"client_secret": "amzn-client-secret",
161156
"authorize_scopes": "profile"
157+
},
158+
"ProviderName": "LoginWithAmazon",
159+
"ProviderType": "LoginWithAmazon",
160+
"UserPoolId": {
161+
"Ref": "OtherPool7DA7F2F7"
162+
}
163+
}
164+
},
165+
"UserPoolToImport1A7C21D3": {
166+
"Type": "AWS::Cognito::UserPool",
167+
"Properties": {
168+
"AccountRecoverySetting": {
169+
"RecoveryMechanisms": [
170+
{
171+
"Name": "verified_phone_number",
172+
"Priority": 1
173+
},
174+
{
175+
"Name": "verified_email",
176+
"Priority": 2
177+
}
178+
]
179+
},
180+
"AdminCreateUserConfig": {
181+
"AllowAdminCreateUserOnly": true
182+
},
183+
"EmailVerificationMessage": "The verification code to your new account is {####}",
184+
"EmailVerificationSubject": "Verify your new account",
185+
"SmsVerificationMessage": "The verification code to your new account is {####}",
186+
"VerificationMessageTemplate": {
187+
"DefaultEmailOption": "CONFIRM_WITH_CODE",
188+
"EmailMessage": "The verification code to your new account is {####}",
189+
"EmailSubject": "Verify your new account",
190+
"SmsMessage": "The verification code to your new account is {####}"
191+
}
192+
},
193+
"UpdateReplacePolicy": "Retain",
194+
"DeletionPolicy": "Retain"
195+
},
196+
"UserPoolToImportclientToImport6885CDF7": {
197+
"Type": "AWS::Cognito::UserPoolClient",
198+
"Properties": {
199+
"AllowedOAuthFlows": [
200+
"implicit",
201+
"code"
202+
],
203+
"AllowedOAuthFlowsUserPoolClient": true,
204+
"AllowedOAuthScopes": [
205+
"profile",
206+
"phone",
207+
"email",
208+
"openid",
209+
"aws.cognito.signin.user.admin"
210+
],
211+
"CallbackURLs": [
212+
"https://example.com"
213+
],
214+
"SupportedIdentityProviders": [
215+
"COGNITO"
216+
],
217+
"UserPoolId": {
218+
"Ref": "UserPoolToImport1A7C21D3"
162219
}
163220
}
164221
},
165222
"identitypoolE2A6D099": {
166223
"Type": "AWS::Cognito::IdentityPool",
167224
"Properties": {
168-
"AllowUnauthenticatedIdentities": false,
169225
"AllowClassicFlow": true,
226+
"AllowUnauthenticatedIdentities": false,
170227
"CognitoIdentityProviders": [
171228
{
172229
"ClientId": {
@@ -193,6 +250,54 @@
193250
},
194251
"ServerSideTokenCheck": true
195252
},
253+
{
254+
"ClientId": {
255+
"Ref": "UserPoolToImportclientToImport6885CDF7"
256+
},
257+
"ProviderName": {
258+
"Fn::Join": [
259+
"",
260+
[
261+
"cognito-idp.",
262+
{
263+
"Ref": "AWS::Region"
264+
},
265+
".",
266+
{
267+
"Ref": "AWS::URLSuffix"
268+
},
269+
"/",
270+
{
271+
"Fn::Select": [
272+
1,
273+
{
274+
"Fn::Split": [
275+
"/",
276+
{
277+
"Fn::Select": [
278+
5,
279+
{
280+
"Fn::Split": [
281+
":",
282+
{
283+
"Fn::GetAtt": [
284+
"UserPoolToImport1A7C21D3",
285+
"Arn"
286+
]
287+
}
288+
]
289+
}
290+
]
291+
}
292+
]
293+
}
294+
]
295+
}
296+
]
297+
]
298+
},
299+
"ServerSideTokenCheck": true
300+
},
196301
{
197302
"ClientId": {
198303
"Ref": "OtherPoolUserPoolAuthenticationProviderClient08F670F8"
@@ -407,6 +512,69 @@
407512
]
408513
},
409514
"Type": "Token"
515+
},
516+
"importedUserPool": {
517+
"AmbiguousRoleResolution": "Deny",
518+
"IdentityProvider": {
519+
"Fn::Join": [
520+
"",
521+
[
522+
"cognito-idp.",
523+
{
524+
"Fn::Select": [
525+
3,
526+
{
527+
"Fn::Split": [
528+
":",
529+
{
530+
"Fn::GetAtt": [
531+
"UserPoolToImport1A7C21D3",
532+
"Arn"
533+
]
534+
}
535+
]
536+
}
537+
]
538+
},
539+
".",
540+
{
541+
"Ref": "AWS::URLSuffix"
542+
},
543+
"/",
544+
{
545+
"Fn::Select": [
546+
1,
547+
{
548+
"Fn::Split": [
549+
"/",
550+
{
551+
"Fn::Select": [
552+
5,
553+
{
554+
"Fn::Split": [
555+
":",
556+
{
557+
"Fn::GetAtt": [
558+
"UserPoolToImport1A7C21D3",
559+
"Arn"
560+
]
561+
}
562+
]
563+
}
564+
]
565+
}
566+
]
567+
}
568+
]
569+
},
570+
":",
571+
{
572+
"Ref": "UserPoolToImportclientToImport6885CDF7"
573+
}
574+
]
575+
]
576+
},
577+
"Type": "Token"
410578
}
411579
},
412580
"Roles": {

packages/@aws-cdk/aws-cognito-identitypool-alpha/test/integ.identitypool.js.snapshot/integ.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)