Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
DEVPROD-4976: Use temporary AWS credentials from ec2.assume_role comm…
Browse files Browse the repository at this point in the history
…and (#2269)
  • Loading branch information
minnakt authored Feb 21, 2024
1 parent c664610 commit 8ecfa7c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 51 deletions.
124 changes: 73 additions & 51 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ post:
# Functions #
#######################################
functions:
assume-ec2-role:
command: ec2.assume_role
params:
role_arn: ${ASSUME_ROLE_ARN}

get-project:
command: git.get_project
type: setup
Expand Down Expand Up @@ -126,12 +131,10 @@ functions:
script: ./scripts/wait-for-evergreen.sh

sym-link:
command: shell.exec
command: subprocess.exec
params:
working_dir: spruce
shell: bash
script: |
ln -s evergreen/graphql/schema sdlschema
command: ln -s evergreen/graphql/schema sdlschema

run-logkeeper:
command: shell.exec
Expand All @@ -149,8 +152,9 @@ functions:
command: s3.get
type: setup
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
extract_to: spruce/logkeeper
remote_file: _bucketdata.tar.gz
bucket: parsley-test
Expand Down Expand Up @@ -260,8 +264,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter: ["spruce/cypress/screenshots/*"]
remote_file: spruce/${task_id}/
bucket: mciuploads
Expand All @@ -271,8 +276,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter: ["spruce/cypress/videos/*"]
remote_file: spruce/${task_id}/
bucket: mciuploads
Expand All @@ -288,8 +294,9 @@ functions:
command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_file: "spruce/build/source_map.html"
remote_file: spruce/${task_id}/source_map.html
bucket: mciuploads
Expand All @@ -301,8 +308,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter: ["spruce/storybook-static/*.html"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
Expand All @@ -312,8 +320,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter:
[
"spruce/storybook-static/**/*.js$",
Expand All @@ -327,8 +336,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter: ["spruce/storybook-static/**/*.js.map"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
Expand All @@ -338,8 +348,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter: ["spruce/storybook-static/**/*.css"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
Expand All @@ -349,8 +360,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter: ["spruce/storybook-static/**/*.json"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
Expand All @@ -360,8 +372,9 @@ functions:
- command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter:
- "spruce/storybook-static/**/*.woff"
- "spruce/storybook-static/**/*.woff2"
Expand All @@ -375,8 +388,9 @@ functions:
command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter:
- "spruce/bin/codegen.diff"
remote_file: spruce/${task_id}/codegen/
Expand All @@ -388,8 +402,9 @@ functions:
command: s3.put
type: system
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter:
- "spruce/body.txt"
remote_file: spruce/${task_id}/
Expand All @@ -401,42 +416,44 @@ functions:
command: shell.exec
params:
working_dir: spruce
env:
REACT_APP_SENTRY_AUTH_TOKEN: ${REACT_APP_SENTRY_AUTH_TOKEN}
REACT_APP_SENTRY_DSN: ${REACT_APP_SENTRY_DSN}
REACT_APP_NEW_RELIC_ACCOUNT_ID: ${REACT_APP_NEW_RELIC_ACCOUNT_ID}
REACT_APP_NEW_RELIC_AGENT_ID: ${REACT_APP_NEW_RELIC_AGENT_ID}
REACT_APP_NEW_RELIC_APPLICATION_ID: ${REACT_APP_NEW_RELIC_APPLICATION_ID}
REACT_APP_NEW_RELIC_LICENSE_KEY: ${REACT_APP_NEW_RELIC_LICENSE_KEY}
REACT_APP_NEW_RELIC_TRUST_KEY: ${REACT_APP_NEW_RELIC_TRUST_KEY}
REACT_APP_DEPLOYS_EMAIL: ${REACT_APP_DEPLOYS_EMAIL}
REACT_APP_HONEYCOMB_BASE_URL: ${REACT_APP_HONEYCOMB_BASE_URL}
EVERGREEN_API_SERVER_HOST: ${evergreen_api_server_host}
EVERGREEN_UI_SERVER_HOST: ${evergreen_api_server_host}
EVERGREEN_API_KEY: ${evergreen_api_key}
EVERGREEN_USER: ${evergreen_user}
script: |
echo "Generating .env-cmdrc.json"
REACT_APP_SENTRY_AUTH_TOKEN=${REACT_APP_SENTRY_AUTH_TOKEN} \
REACT_APP_SENTRY_DSN=${REACT_APP_SENTRY_DSN} \
REACT_APP_NEW_RELIC_ACCOUNT_ID=${REACT_APP_NEW_RELIC_ACCOUNT_ID} \
REACT_APP_NEW_RELIC_AGENT_ID=${REACT_APP_NEW_RELIC_AGENT_ID} \
REACT_APP_NEW_RELIC_APPLICATION_ID=${REACT_APP_NEW_RELIC_APPLICATION_ID} \
REACT_APP_NEW_RELIC_LICENSE_KEY=${REACT_APP_NEW_RELIC_LICENSE_KEY} \
REACT_APP_NEW_RELIC_TRUST_KEY=${REACT_APP_NEW_RELIC_TRUST_KEY} \
REACT_APP_DEPLOYS_EMAIL=${REACT_APP_DEPLOYS_EMAIL} \
REACT_APP_HONEYCOMB_BASE_URL=${REACT_APP_HONEYCOMB_BASE_URL} \
node scripts/setup-credentials.js
echo "populating evergreen.yml"
cat <<EOF > .evergreen.yml
api_server_host: ${evergreen_api_server_host}
ui_server_host: ${evergreen_ui_server_host}
api_key: ${evergreen_api_key}
user: ${evergreen_user}
EOF
echo "Done populating"
chmod +x ./scripts/create-evergreen-yml.sh
./scripts/create-evergreen-yml.sh
echo "Done populating evergreen.yml"
prod-deploy:
command: shell.exec
params:
working_dir: spruce
shell: bash
env:
BUCKET: ${bucket}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}
EXECUTION: ${execution}
DEPLOYS_EMAIL: ${DEPLOYS_EMAIL}
AUTHOR_EMAIL: ${author_email}
script: |
${PREPARE_SHELL}
BUCKET=${bucket} \
AWS_ACCESS_KEY_ID=${aws_key} \
AWS_SECRET_ACCESS_KEY=${aws_secret} \
EXECUTION=${execution} \
DEPLOYS_EMAIL=${DEPLOYS_EMAIL} \
AUTHOR_EMAIL=${author_email} \
yarn deploy:prod
#######################################
Expand All @@ -446,11 +463,13 @@ functions:
tasks:
- name: compile
commands:
- func: assume-ec2-role
- func: sym-link
- func: yarn-build

- name: storybook
commands:
- func: assume-ec2-role
- func: yarn-build-storybook

- name: test
Expand All @@ -473,6 +492,7 @@ tasks:

- name: e2e_test
commands:
- func: assume-ec2-role
- func: setup-mongodb
- func: run-make-background
vars:
Expand All @@ -487,11 +507,13 @@ tasks:

- name: check_codegen
commands:
- func: assume-ec2-role
- func: sym-link
- func: check-codegen

- name: deploy_to_prod
commands:
- func: assume-ec2-role
- func: setup-credentials
- func: sym-link
- func: prod-deploy
Expand Down
6 changes: 6 additions & 0 deletions scripts/deploy/create-evergreen-yml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cat <<EOF > .evergreen.yml
api_server_host: $EVERGREEN_API_SERVER_HOST
ui_server_host: $EVERGREEN_UI_SERVER_HOST
api_key: $EVERGREEN_API_KEY
user: $EVERGREEN_USER
EOF

0 comments on commit 8ecfa7c

Please sign in to comment.