Skip to content

Commit f54aad7

Browse files
committed
[Custom Domain] Improve user experience to configure custom domains in PCUI.
In particular, we added the following new optional parameters to the PCUI stack: 1. CustomDomain 2. CustomDomainCertificateArn 3. CognitoCustomDomain 4. CognitoCustomDomainCertificateArn and the following new outputs when a custom domain is set: 1. CustomDomainEndpoint 2. CognitoCustomDomainEndpoint
1 parent 63bc480 commit f54aad7

File tree

4 files changed

+98
-5
lines changed

4 files changed

+98
-5
lines changed

infrastructure/environments/demo-cfn-create-args.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ Parameters:
3333
# - ParameterKey: IAMRoleAndPolicyPrefix
3434
# ParameterValue: xxxxxxxxxx
3535
# - ParameterKey: CustomDomain
36-
# ParameterValue: xxxxxxxxxx
36+
# ParameterValue: pcui.example.com
37+
# - ParameterKey: CustomDomainCertificateArn
38+
# ParameterValue: arn:<PARTITION>:acm:<REGION>:<ACCOUNT>:certificate/<CERTIFICATE_ID>
39+
# - ParameterKey: CognitoCustomDomain
40+
# ParameterValue: auth-pcui.example.com
41+
# - ParameterKey: CognitoCustomDomainCertificateArn
42+
# ParameterValue: arn:<PARTITION>:acm:<REGION>:<ACCOUNT>:certificate/<CERTIFICATE_ID>
3743
Capabilities:
3844
- CAPABILITY_AUTO_EXPAND
3945
- CAPABILITY_NAMED_IAM

infrastructure/environments/demo-cfn-update-args.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Parameters:
3434
UsePreviousValue: true
3535
- ParameterKey: CustomDomain
3636
UsePreviousValue: true
37+
- ParameterKey: CustomDomainCertificateArn
38+
UsePreviousValue: true
39+
- ParameterKey: CognitoCustomDomain
40+
UsePreviousValue: true
41+
- ParameterKey: CognitoCustomDomainCertificateArn
42+
UsePreviousValue: true
3743
Capabilities:
3844
- CAPABILITY_AUTO_EXPAND
3945
- CAPABILITY_NAMED_IAM

infrastructure/parallelcluster-ui-cognito.yaml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ Parameters:
1717
Description: 'Prefix applied to the name of every IAM role and policy (max length: 10)'
1818
Default: ''
1919
MaxLength: 10
20+
CustomDomain:
21+
Type: String
22+
Description: (Optional) Custom domain name. If omitted, the default domain name will be used.
23+
Default: ''
24+
CustomDomainCertificateArn:
25+
Type: String
26+
Description: '(Optional) ARN of the ACM Certificate issued for the custom domain. This is required only if `CustomDomain` is specified.'
27+
Default: ''
2028

2129
Conditions:
2230
GovCloud: !Equals [!Ref AWS::Region, 'us-gov-west-1']
2331
UsePermissionBoundary: !Not [ !Equals [ !Ref PermissionsBoundaryPolicy, '' ] ]
32+
UseCustomDomain: !Not [!Equals [!Ref CustomDomain, '']]
2433

2534
Metadata:
2635
AWS::CloudFormation::Interface:
@@ -34,6 +43,11 @@ Metadata:
3443
Parameters:
3544
- IAMRoleAndPolicyPrefix
3645
- PermissionsBoundaryPolicy
46+
- Label:
47+
default: (Optional) Custom Domain
48+
Parameters:
49+
- CustomDomain
50+
- CustomDomainCertificateArn
3751
ParameterLabels:
3852
AdminUserEmail:
3953
default: Initial Admin's Email
@@ -73,7 +87,14 @@ Resources:
7387
Type: AWS::Cognito::UserPoolDomain
7488
Properties:
7589
UserPoolId: !Ref CognitoUserPool
76-
Domain: !Join [ "-", ["pcui-auth", !Select [2, !Split [ "/", !Ref 'AWS::StackId']]]]
90+
Domain: !If
91+
- UseCustomDomain
92+
- !Ref CustomDomain
93+
- !Join [ "-", ["pcui-auth", !Select [2, !Split [ "/", !Ref 'AWS::StackId']]]]
94+
CustomDomainConfig: !If
95+
- UseCustomDomain
96+
- { CertificateArn: !Ref CustomDomainCertificateArn }
97+
- !Ref AWS::NoValue
7798

7899
CognitoUserPool:
79100
Type: AWS::Cognito::UserPool
@@ -125,9 +146,19 @@ Outputs:
125146

126147
UserPoolAuthDomain:
127148
Description: The domain of the authorization server.
128-
Value: !Sub
129-
- https://${Domain}.${Auth}.${AWS::Region}.amazoncognito.com
130-
- {Domain: !Ref UserPoolDomain, Auth: !If [GovCloud, 'auth-fips', 'auth']}
149+
Value: !If
150+
- UseCustomDomain
151+
- !Sub https://${UserPoolDomain}
152+
- !Sub
153+
- https://${Domain}.${Auth}.${AWS::Region}.amazoncognito.com
154+
- {Domain: !Ref UserPoolDomain, Auth: !If [GovCloud, 'auth-fips', 'auth']}
155+
156+
CustomDomainEndpoint:
157+
Condition: UseCustomDomain
158+
Description: |
159+
The endpoint associated with the custom domain name.
160+
Add an A record in your DNS for the custom domain name pointing to this endpoint.
161+
Value: !GetAtt UserPoolDomain.CloudFrontDistribution
131162

132163
UserPoolId:
133164
Description: Cognito UserPool Id

infrastructure/parallelcluster-ui.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ Parameters:
6666
Type: String
6767
Description: (Optional) Custom domain name. If omitted, the default domain name will be used.
6868
Default: ''
69+
CustomDomainCertificateArn:
70+
Type: String
71+
Description: '(Optional) ARN of the ACM Certificate issued for the custom domain. This is required only if `CustomDomain` is specified.'
72+
Default: ''
73+
CognitoCustomDomain:
74+
Type: String
75+
Description: '(Optional) Custom domain name for Cognito. If omitted, the default Cognito domain name will be used.'
76+
Default: ''
77+
CognitoCustomDomainCertificateArn:
78+
Type: String
79+
Description: '(Optional) ARN of the ACM Certificate issued for the Cognito custom domain. This is required only if `CognitoCustomDomain` is specified.'
80+
Default: ''
6981
Metadata:
7082
AWS::CloudFormation::Interface:
7183
ParameterGroups:
@@ -108,6 +120,9 @@ Metadata:
108120
default: (Optional) Custom Domain
109121
Parameters:
110122
- CustomDomain
123+
- CustomDomainCertificateArn
124+
- CognitoCustomDomain
125+
- CognitoCustomDomainCertificateArn
111126
- Label:
112127
default: (Debugging only) Infrastructure S3 Bucket
113128
Parameters:
@@ -153,6 +168,7 @@ Conditions:
153168
UsePermissionBoundaryPCAPI: !Not [!Equals [!Ref PermissionsBoundaryPolicyPCAPI, '']]
154169
UseIAMRoleAndPolicyPrefix: !Not [!Equals [!Ref IAMRoleAndPolicyPrefix, '']]
155170
UseCustomDomain: !Not [!Equals [!Ref CustomDomain, '']]
171+
UseCognitoCustomDomain: !Not [!Equals [!Ref CognitoCustomDomain, '']]
156172

157173
Mappings:
158174
ParallelClusterUI:
@@ -171,6 +187,8 @@ Resources:
171187
AdminUserEmail: !Ref AdminUserEmail
172188
PermissionsBoundaryPolicy: !Ref PermissionsBoundaryPolicy
173189
IAMRoleAndPolicyPrefix: !Ref IAMRoleAndPolicyPrefix
190+
CustomDomain: !Ref CognitoCustomDomain
191+
CustomDomainCertificateArn: !Ref CognitoCustomDomainCertificateArn
174192
TemplateURL: !Sub
175193
- '${Bucket}/parallelcluster-ui-cognito.yaml'
176194
- Bucket: !If
@@ -1026,6 +1044,26 @@ Resources:
10261044
Effect: Allow
10271045
Sid: SsmGetCommandInvocationPolicy
10281046

1047+
ApiGatewayCustomDomain:
1048+
Condition: UseCustomDomain
1049+
Type: AWS::ApiGateway::DomainName
1050+
Properties:
1051+
# CertificateArn: !Ref CustomDomainCertificateArn
1052+
DomainName: !Ref CustomDomain
1053+
EndpointConfiguration:
1054+
Types:
1055+
- REGIONAL
1056+
RegionalCertificateArn: !Ref CustomDomainCertificateArn
1057+
SecurityPolicy: TLS_1_2
1058+
1059+
ApiGatewayCustomDomainMapping:
1060+
Condition: UseCustomDomain
1061+
Type: AWS::ApiGateway::BasePathMapping
1062+
Properties:
1063+
BasePath: !FindInMap [ ParallelClusterUI, Constants, CustomDomainBasePath ]
1064+
DomainName: !Ref ApiGatewayCustomDomain
1065+
RestApiId: !Ref ApiGatewayRestApi
1066+
Stage: !Ref ApiGatewayRestStage
10291067

10301068
Outputs:
10311069
ParallelClusterUILambdaArn:
@@ -1043,6 +1081,12 @@ Outputs:
10431081
- !Sub
10441082
- https://${Api}.execute-api.${AWS::Region}.${AWS::URLSuffix}/${Stage}
10451083
- { Api: !Ref ApiGatewayRestApi, Stage: !Ref ApiGatewayRestStage }
1084+
CustomDomainEndpoint:
1085+
Condition: UseCustomDomain
1086+
Description: |
1087+
The endpoint associated with the custom domain name.
1088+
Add an A record in your DNS for the PCUI custom domain name pointing to this endpoint.
1089+
Value: !GetAtt ApiGatewayCustomDomain.RegionalDomainName
10461090
AppClientId:
10471091
Description: The id of the Cognito app client
10481092
Value: !Ref CognitoAppClient
@@ -1052,3 +1096,9 @@ Outputs:
10521096
UserPoolClientSecretName:
10531097
Description: The app client secret name for ParallelCluster UI.
10541098
Value: !GetAtt UserPoolClientSecret.SecretName
1099+
CognitoCustomDomainEndpoint:
1100+
Condition: UseCognitoCustomDomain
1101+
Description: |
1102+
The endpoint associated with the Cognito custom domain name.
1103+
Add an A record in your DNS for the Cognito custom domain name pointing to this endpoint.
1104+
Value: !GetAtt Cognito.Outputs.CustomDomainEndpoint

0 commit comments

Comments
 (0)