Skip to content

Commit f9bf4da

Browse files
feat: easier backend outputs for frontend (#52)
* feat: easier backend outputs for frontend --------- Signed-off-by: Scott Schreckengaust <[email protected]>
1 parent 1d591ae commit f9bf4da

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

samples/document-explorer/README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,27 @@ Default output format [None]: json
124124

125125
2. Configure your environment variables in `client_app/Dockerfile`. Replace the property values with the values the were outputted from the backend Terraform deployment in your terminal. You will leave `APP_URI` as a placeholder for now because the URI will be the Cloudfront URL output from your Front End Terraform deployment.
126126

127+
> [!TIP]
128+
> Use this command-line to get them from the Terraform outputs to copy and paste into the Dockerfile:
129+
130+
```shell
131+
terraform output | tr a-z A-Z | sed -e 's/ = /=/g' | sed -e 's/^/ENV /g' | sort -u
132+
```
133+
127134
```Dockerfile
128-
ENV COGNITO_DOMAIN = "<Output.CognitoDomain>"
129-
ENV REGION = "<Output.Region>"
130-
ENV USER_POOL_ID = "<Output.UserPoolId>"
131-
ENV CLIENT_ID = "<Output.ClientId>"
132-
ENV CLIENT_SECRET = "<COGNITO_CLIENT_SECRET>"
133-
ENV IDENTITY_POOL_ID = "<Output.IdentityPoolId>"
134-
ENV AUTHENTICATED_ROLE_ARN = "<Output.AuthenticatedRoleArn>"
135-
ENV GRAPHQL_ENDPOINT = "<Output.GraphQLEndpoint>"
136-
ENV S3_INPUT_BUCKET = "<Output.InputsAssetsBucket>"
137-
ENV S3_PROCESSED_BUCKET = "<Output.ProcessedAssetsBucket>"
138-
ENV CLIENT_NAME = "<Output.ClientName>"
135+
ENV AUTHENTICATED_ROLE_ARN='<AUTHENTICATED_ROLE_ARN>'
136+
ENV CLIENT_ID='<CLIENT_ID>'
137+
ENV CLIENT_NAME='<CLIENT_NAME>'
138+
ENV COGNITO_DOMAIN='<COGNITO_DOMAIN>'
139+
ENV GRAPHQL_ENDPOINT='<GRAPHQL_ENDPOINT>'
140+
ENV IDENTITY_POOL_ID='<IDENTITY_POOL_ID>'
141+
ENV REGION='<REGION>'
142+
ENV S3_INPUT_BUCKET='<S3_INPUT_BUCKET>'
143+
ENV S3_PROCESSED_BUCKET='<S3_PROCESSED_BUCKET>'
144+
ENV USER_POOL_ID='<USER_POOL_ID>'
139145
```
140146

141-
Note: The ```COGNITO_CLIENT_SECRET``` is a secret value that can be retrieved from the AWS Console. Go to the [Amazon Cognito page](https://console.aws.amazon.com/cognito/home) in the AWS console, then select the created user pool. Under App integration, select App client settings. Then, select Show Details and copy the value of the App client secret.
147+
Note: The ```location_of_cognito_user_client_secret``` is a location of the secret value that can be retrieved from the AWS Console. Go to the [Amazon Cognito page](https://console.aws.amazon.com/cognito/home) in the AWS console, then select the created user pool. Under App integration, select App client settings. Then, select Show Details and copy the value of the App client secret.
142148

143149
<!-- markdownlint-disable MD029 -->
144150
3. Run `terraform init`

samples/document-explorer/client_app/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ COPY requirements.txt ./requirements.txt
88
RUN pip3 install --no-cache-dir -r requirements.txt
99

1010
# Set most of the environment variables from Terraform backend deployment outputs
11-
ENV COGNITO_DOMAIN='<COGNITO_DOMAIN>'
12-
ENV REGION='us-east-1'
13-
ENV USER_POOL_ID='<USER_POOL_ID>'
14-
ENV CLIENT_ID='<CLIENT_ID>'
15-
# CLIENT_SECRET look in AWS Console
16-
ENV CLIENT_SECRET='<CLIENT_SECRET>'
17-
ENV IDENTITY_POOL_ID='<IDENTITY_POOL_ID>'
1811
ENV AUTHENTICATED_ROLE_ARN='<AUTHENTICATED_ROLE_ARN>'
12+
ENV CLIENT_ID='<CLIENT_ID>'
13+
ENV CLIENT_NAME='<CLIENT_NAME>'
14+
ENV COGNITO_DOMAIN='<COGNITO_DOMAIN>'
1915
ENV GRAPHQL_ENDPOINT='<GRAPHQL_ENDPOINT>'
16+
ENV IDENTITY_POOL_ID='<IDENTITY_POOL_ID>'
17+
ENV REGION='<REGION>'
2018
ENV S3_INPUT_BUCKET='<S3_INPUT_BUCKET>'
2119
ENV S3_PROCESSED_BUCKET='<S3_PROCESSED_BUCKET>'
22-
ENV CLIENT_NAME='<CLIENT_NAME>'
20+
ENV USER_POOL_ID='<USER_POOL_ID>'
21+
22+
# CLIENT_SECRET look in AWS Console
23+
ENV CLIENT_SECRET='<CLIENT_SECRET>'
2324

2425
# Replace APP_URI with the Amazon CloudFront output from Terraform frontend, then deploy Terraform frontend again
2526
ENV APP_URI='http://localhost:8501'

samples/document-explorer/terraform-config-backend/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
output "cognito_user_client_secret" {
1+
output "location_of_cognito_user_client_secret" {
22
description = "ARN of the AWS Secrets Manager secret for Cognito client secret key"
33
value = module.genai_doc_ingestion.cognito_user_client_secret
44
}

0 commit comments

Comments
 (0)