@@ -18,11 +18,67 @@ Resources:
18
18
HelloWorldFunction :
19
19
Type : AWS::Serverless::Function
20
20
Properties :
21
- CodeUri : hello_world/
21
+ CodeUri : ../src
22
22
Handler : swagger_ui_oauth2.lambda_handler
23
+ Environment :
24
+ Variables :
25
+ COGNITO_USER_POOL_DOMAIN : !Ref UserPoolDomain
23
26
Events :
24
27
AnyApiEvent :
25
28
Type : Api
26
29
Properties :
27
30
Path : /{proxy+} # Send requests on any path to the lambda function
28
31
Method : ANY # Send requests using any http method to the lambda function
32
+
33
+ CognitoUserPool :
34
+ Type : AWS::Cognito::UserPool
35
+ Properties :
36
+ UserPoolName : PowertoolsUserPool
37
+ Policies :
38
+ PasswordPolicy :
39
+ MinimumLength : 8
40
+ RequireLowercase : true
41
+ RequireNumbers : true
42
+ RequireSymbols : true
43
+ RequireUppercase : true
44
+
45
+ CognitoUserPoolClient :
46
+ Type : AWS::Cognito::UserPoolClient
47
+ Properties :
48
+ ClientName : PowertoolsClient
49
+ UserPoolId : !Ref CognitoUserPool
50
+ GenerateSecret : true
51
+ RefreshTokenValidity : 30
52
+ ExplicitAuthFlows :
53
+ - ALLOW_USER_PASSWORD_AUTH
54
+ - ALLOW_REFRESH_TOKEN_AUTH
55
+ SupportedIdentityProviders :
56
+ - COGNITO
57
+ CallbackURLs :
58
+ # NOTE: for this to work, your OAuth2 redirect url needs to precisely follow this format:
59
+ # https://<your_api_id>.execute-api.<region>.amazonaws.com/<stage>/swagger?format=oauth2-redirect
60
+ - !Sub " https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/${ServerlessRestApi.Stage}/swagger?format=oauth2-redirect"
61
+ AllowedOAuthFlows :
62
+ - code
63
+ AllowedOAuthScopes :
64
+ - openid
65
+ - email
66
+ - profile
67
+ - aws.cognito.signin.user.admin
68
+ AllowedOAuthFlowsUserPoolClient : true
69
+
70
+ UserPoolDomain :
71
+ Type : AWS::Cognito::UserPoolDomain
72
+ Properties :
73
+ Domain : powertools-swagger-oauth2
74
+ UserPoolId : !Ref CognitoUserPool
75
+
76
+ Outputs :
77
+ HelloWorldApiUrl :
78
+ Value : !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/${ServerlessRestApi.Stage}/swagger"
79
+
80
+ CognitoOAuthClientId :
81
+ Value : !GetAtt CognitoUserPoolClient.ClientId
82
+
83
+ CognitoDomain :
84
+ Value : !Ref UserPoolDomain
0 commit comments