Skip to content

Commit

Permalink
github workflows: remove ssm paramters and pass relevant vars to tg
Browse files Browse the repository at this point in the history
  • Loading branch information
digorgonzola committed Dec 10, 2023
1 parent 9d339bc commit 07c55dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 68 deletions.
42 changes: 8 additions & 34 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ jobs:
image_digest=$(cat metadata.json | jq -r '."containerimage.digest"')
echo "image_digest=$image_digest" >> $GITHUB_OUTPUT
- name: Export shared infrastructure SSM parameter values to auto.tfvars.json files
env:
deploy_path: ./deploy/tg/ecs
environment: ${{ vars.ENVIRONMENT }}
run: |
params=( apps/alb/${{ vars.ALB }} apps/ecr/${{ vars.ECR_REPOSITORY }} core rds/${{ vars.RDS_DB }} )
for param in ${params[@]}; do
filename="$environment.${param//\//-}.auto.tfvars.json"
aws ssm get-parameters-by-path \
--path "/$param/" \
--recursive \
--output json \
--query 'Parameters[*]' \
| jq '. |= map({ (.Name | split("/")[-1]): .Value }) | add' \
> "$deploy_path/$filename"
done
- name: Expose github environment as shell variables
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
Expand All @@ -76,6 +59,10 @@ jobs:
TF_IN_AUTOMATION: true
# get the image digest from the build job with optional override from vars context
TF_VAR_image: ${{ vars.IMAGE || steps.set_image_digest.outputs.image_digest }}
# set the parameter name variables
TF_VAR_alb_parameter_name: $ALB_PARAMETER_NAME
TF_VAR_ecr_parameter_name: ${{ vars.ECR_REPOSITORY }}
TF_VAR_rds_parameter_name: $RDS_PARAMETER_NAME

production_deploy_apply:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -104,23 +91,6 @@ jobs:
image_digest=$(cat metadata.json | jq -r '."containerimage.digest"')
echo "image_digest=$image_digest" >> $GITHUB_OUTPUT
- name: Export shared infrastructure SSM parameter values to auto.tfvars.json files
env:
deploy_path: ./deploy/tg/ecs
environment: ${{ vars.ENVIRONMENT }}
run: |
params=( apps/alb/${{ vars.ALB }} apps/ecr/${{ vars.ECR_REPOSITORY }} core rds/${{ vars.RDS_DB }} )
for param in ${params[@]}; do
filename="$environment.${param//\//-}.auto.tfvars.json"
aws ssm get-parameters-by-path \
--path "/$param/" \
--recursive \
--output json \
--query 'Parameters[*]' \
| jq '. |= map({ (.Name | split("/")[-1]): .Value }) | add' \
> "$deploy_path/$filename"
done
- name: Expose github environment as shell variables
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
Expand All @@ -144,3 +114,7 @@ jobs:
TF_IN_AUTOMATION: true
# get the image digest from the build job with optional override from vars context
TF_VAR_image: ${{ vars.IMAGE || steps.set_image_digest.outputs.image_digest }}
# set the parameter name variables
TF_VAR_alb_parameter_name: $ALB_PARAMETER_NAME
TF_VAR_ecr_parameter_name: ${{ vars.ECR_REPOSITORY }}
TF_VAR_rds_parameter_name: $RDS_PARAMETER_NAME
42 changes: 8 additions & 34 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,6 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}

- name: Export shared infrastructure SSM parameter values to auto.tfvars.json files
env:
deploy_path: ./deploy/tg/ecs
environment: ${{ vars.ENVIRONMENT }}
run: |
params=( apps/alb/${{ vars.ALB }} apps/ecr/${{ vars.ECR_REPOSITORY }} core rds/${{ vars.RDS_DB }} )
for param in ${params[@]}; do
filename="$environment.${param//\//-}.auto.tfvars.json"
aws ssm get-parameters-by-path \
--path "/$param/" \
--recursive \
--output json \
--query 'Parameters[*]' \
| jq '. |= map({ (.Name | split("/")[-1]): .Value }) | add' \
> "$deploy_path/$filename"
done
- name: Expose github environment as shell variables
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
Expand All @@ -121,6 +104,10 @@ jobs:
TF_IN_AUTOMATION: true
# get the image digest from the build job with optional override from vars context
TF_VAR_image: ${{ vars.IMAGE || needs.build_test_push.outputs.image_digest }}
# set the parameter name variables
TF_VAR_alb_parameter_name: $ALB_PARAMETER_NAME
TF_VAR_ecr_parameter_name: ${{ vars.ECR_REPOSITORY }}
TF_VAR_rds_parameter_name: $RDS_PARAMETER_NAME

staging_deploy_apply:
runs-on: ubuntu-latest
Expand All @@ -137,23 +124,6 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}

- name: Export shared infrastructure SSM parameter values to auto.tfvars.json files
env:
deploy_path: ./deploy/tg/ecs
environment: ${{ vars.ENVIRONMENT }}
run: |
params=( apps/alb/${{ vars.ALB }} apps/ecr/${{ vars.ECR_REPOSITORY }} core rds/${{ vars.RDS_DB }} )
for param in ${params[@]}; do
filename="$environment.${param//\//-}.auto.tfvars.json"
aws ssm get-parameters-by-path \
--path "/$param/" \
--recursive \
--output json \
--query 'Parameters[*]' \
| jq '. |= map({ (.Name | split("/")[-1]): .Value }) | add' \
> "$deploy_path/$filename"
done
- name: Expose github environment as shell variables
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
Expand All @@ -177,6 +147,10 @@ jobs:
TF_IN_AUTOMATION: true
# get the image digest from the build job with optional override from vars context
TF_VAR_image: ${{ vars.IMAGE || needs.build_test_push.outputs.image_digest }}
# set the parameter name variables
TF_VAR_alb_parameter_name: $ALB_PARAMETER_NAME
TF_VAR_ecr_parameter_name: ${{ vars.ECR_REPOSITORY }}
TF_VAR_rds_parameter_name: $RDS_PARAMETER_NAME

create_draft_release:
name: Create Release
Expand Down

0 comments on commit 07c55dd

Please sign in to comment.