Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup-env.sh を高速化 #322

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Unix 系コマンドが使えるユーザー (Linux, MacOS 等)

以下のコマンドを実行することで、必要な環境変数を CloudFormation の Output から動的に取得し、サーバーを起動します。
なお、内部で `aws` コマンドと `jq` コマンドを利用しているので、未インストールの場合はインストールしてから実行してください。

```bash
npm run web:devw
Expand Down
45 changes: 21 additions & 24 deletions setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@ set -eu

STACK_NAME='GenerativeAiUseCasesStack'

function stack_output {
aws cloudformation describe-stacks \
--stack-name $STACK_NAME \
--query "Stacks[0].Outputs[?OutputKey=='$1'].OutputValue" \
--output text
function extract_value {
echo $1 | jq -r ".Stacks[0].Outputs[] | select(.OutputKey==\"$2\") | .OutputValue"
}

echo 'Setup environment variables...'
stack_output=`aws cloudformation describe-stacks --stack-name $STACK_NAME --output json`

export VITE_APP_API_ENDPOINT=`stack_output 'ApiEndpoint'`
export VITE_APP_REGION=`stack_output 'Region'`
export VITE_APP_USER_POOL_ID=`stack_output 'UserPoolId'`
export VITE_APP_USER_POOL_CLIENT_ID=`stack_output 'UserPoolClientId'`
export VITE_APP_IDENTITY_POOL_ID=`stack_output 'IdPoolId'`
export VITE_APP_PREDICT_STREAM_FUNCTION_ARN=`stack_output PredictStreamFunctionArn`
export VITE_APP_RAG_ENABLED=`stack_output RagEnabled`
export VITE_APP_AGENT_ENABLED=`stack_output AgentEnabled`
export VITE_APP_SELF_SIGN_UP_ENABLED=`stack_output SelfSignUpEnabled`
export VITE_APP_MODEL_REGION=`stack_output ModelRegion`
export VITE_APP_MODEL_IDS=`stack_output ModelIds`
export VITE_APP_IMAGE_MODEL_IDS=`stack_output ImageGenerateModelIds`
export VITE_APP_ENDPOINT_NAMES=`stack_output EndpointNames`
export VITE_APP_SAMLAUTH_ENABLED=`stack_output SamlAuthEnabled`
export VITE_APP_SAML_COGNITO_DOMAIN_NAME=`stack_output SamlCognitoDomainName`
export VITE_APP_SAML_COGNITO_FEDERATED_IDENTITY_PROVIDER_NAME=`stack_output SamlCognitoFederatedIdentityProviderName`
export VITE_APP_AGENT_NAMES=`stack_output AgentNames`
export VITE_APP_RECOGNIZE_FILE_ENABLED=`stack_output RecognizeFileEnabled`
export VITE_APP_API_ENDPOINT=`extract_value "$stack_output" 'ApiEndpoint'`
export VITE_APP_REGION=`extract_value "$stack_output" 'Region'`
export VITE_APP_USER_POOL_ID=`extract_value "$stack_output" 'UserPoolId'`
export VITE_APP_USER_POOL_CLIENT_ID=`extract_value "$stack_output" 'UserPoolClientId'`
export VITE_APP_IDENTITY_POOL_ID=`extract_value "$stack_output" 'IdPoolId'`
export VITE_APP_PREDICT_STREAM_FUNCTION_ARN=`extract_value "$stack_output" PredictStreamFunctionArn`
export VITE_APP_RAG_ENABLED=`extract_value "$stack_output" RagEnabled`
export VITE_APP_AGENT_ENABLED=`extract_value "$stack_output" AgentEnabled`
export VITE_APP_SELF_SIGN_UP_ENABLED=`extract_value "$stack_output" SelfSignUpEnabled`
export VITE_APP_MODEL_REGION=`extract_value "$stack_output" ModelRegion`
export VITE_APP_MODEL_IDS=`extract_value "$stack_output" ModelIds`
export VITE_APP_IMAGE_MODEL_IDS=`extract_value "$stack_output" ImageGenerateModelIds`
export VITE_APP_ENDPOINT_NAMES=`extract_value "$stack_output" EndpointNames`
export VITE_APP_SAMLAUTH_ENABLED=`extract_value "$stack_output" SamlAuthEnabled`
export VITE_APP_SAML_COGNITO_DOMAIN_NAME=`extract_value "$stack_output" SamlCognitoDomainName`
export VITE_APP_SAML_COGNITO_FEDERATED_IDENTITY_PROVIDER_NAME=`extract_value "$stack_output" SamlCognitoFederatedIdentityProviderName`
export VITE_APP_AGENT_NAMES=`extract_value "$stack_output" AgentNames`
export VITE_APP_RECOGNIZE_FILE_ENABLED=`extract_value "$stack_output" RecognizeFileEnabled`
Loading