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 ec2.assume_role command
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt committed Feb 21, 2024
1 parent 019d0df commit 339946a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 48 deletions.
118 changes: 70 additions & 48 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 @@ -149,8 +154,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 +266,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 +278,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 +296,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 +310,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 +322,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 +338,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 +350,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 +362,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 +374,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 +390,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 +404,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 +418,42 @@ 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"
./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 339946a

Please sign in to comment.