Browse Source

Update aws deploy pipeline to allow different prefixes for roles and tasks

cldc-2812-run-app-from-relative-url
Rachael Booth 1 year ago
parent
commit
c9ad0459a3
  1. 27
      .github/workflows/aws_deploy.yml
  2. 3
      .github/workflows/production_pipeline.yml
  3. 3
      .github/workflows/staging_pipeline.yml

27
.github/workflows/aws_deploy.yml

@ -6,7 +6,10 @@ on:
aws_account_id: aws_account_id:
required: true required: true
type: string type: string
aws_resource_prefix: aws_role_prefix:
required: true
type: string
aws_task_prefix:
required: true required: true
type: string type: string
environment: environment:
@ -104,12 +107,12 @@ jobs:
uses: aws-actions/configure-aws-credentials@v3 uses: aws-actions/configure-aws-credentials@v3
with: with:
aws-region: ${{ env.aws_region }} aws-region: ${{ env.aws_region }}
role-to-assume: arn:aws:iam::${{ inputs.aws_account_id }}:role/${{ inputs.aws_resource_prefix }}-deployment role-to-assume: arn:aws:iam::${{ inputs.aws_account_id }}:role/${{ inputs.aws_role_prefix }}-deployment
role-chaining: true role-chaining: true
- name: Download ad hoc task definition - name: Download ad hoc task definition
env: env:
ad_hoc_task_definition: ${{ inputs.aws_resource_prefix }}-ad-hoc ad_hoc_task_definition: ${{ inputs.aws_task_prefix }}-ad-hoc
run: | run: |
aws ecs describe-task-definition --task-definition $ad_hoc_task_definition --query taskDefinition > ad-hoc-task-definition.json aws ecs describe-task-definition --task-definition $ad_hoc_task_definition --query taskDefinition > ad-hoc-task-definition.json
@ -128,9 +131,9 @@ jobs:
- name: Run migrations task - name: Run migrations task
env: env:
ad_hoc_task_definition: ${{ inputs.aws_resource_prefix }}-ad-hoc ad_hoc_task_definition: ${{ inputs.aws_task_prefix }}-ad-hoc
cluster: ${{ inputs.aws_resource_prefix }}-app cluster: ${{ inputs.aws_task_prefix }}-app
service: ${{ inputs.aws_resource_prefix }}-app service: ${{ inputs.aws_task_prefix }}-app
run: | run: |
network=$(aws ecs describe-services --cluster $cluster --services $service --query services[0].networkConfiguration) network=$(aws ecs describe-services --cluster $cluster --services $service --query services[0].networkConfiguration)
overrides='{ "containerOverrides" : [{ "name" : "app", "command" : ["bundle", "exec", "rake", "db:migrate"]}]}' overrides='{ "containerOverrides" : [{ "name" : "app", "command" : ["bundle", "exec", "rake", "db:migrate"]}]}'
@ -144,7 +147,7 @@ jobs:
- name: Download app service task definition - name: Download app service task definition
env: env:
app_task_definition: ${{ inputs.aws_resource_prefix }}-app app_task_definition: ${{ inputs.aws_task_prefix }}-app
run: | run: |
aws ecs describe-task-definition --task-definition $app_task_definition --query taskDefinition > app-task-definition.json aws ecs describe-task-definition --task-definition $app_task_definition --query taskDefinition > app-task-definition.json
@ -159,14 +162,14 @@ jobs:
- name: Deploy updated application - name: Deploy updated application
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
cluster: ${{ inputs.aws_resource_prefix }}-app cluster: ${{ inputs.aws_task_prefix }}-app
service: ${{ inputs.aws_resource_prefix }}-app service: ${{ inputs.aws_task_prefix }}-app
task-definition: ${{ steps.app-task-def.outputs.task-definition }} task-definition: ${{ steps.app-task-def.outputs.task-definition }}
wait-for-service-stability: true wait-for-service-stability: true
- name: Download sidekiq service task definition - name: Download sidekiq service task definition
env: env:
sidekiq_task_definition: ${{ inputs.aws_resource_prefix }}-sidekiq sidekiq_task_definition: ${{ inputs.aws_task_prefix }}-sidekiq
run: | run: |
aws ecs describe-task-definition --task-definition $sidekiq_task_definition --query taskDefinition > sidekiq-task-definition.json aws ecs describe-task-definition --task-definition $sidekiq_task_definition --query taskDefinition > sidekiq-task-definition.json
@ -181,7 +184,7 @@ jobs:
- name: Deploy updated sidekiq - name: Deploy updated sidekiq
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
cluster: ${{ inputs.aws_resource_prefix }}-app cluster: ${{ inputs.aws_task_prefix }}-app
service: ${{ inputs.aws_resource_prefix }}-sidekiq service: ${{ inputs.aws_task_prefix }}-sidekiq
task-definition: ${{ steps.sidekiq-task-def.outputs.task-definition }} task-definition: ${{ steps.sidekiq-task-def.outputs.task-definition }}
wait-for-service-stability: true wait-for-service-stability: true

3
.github/workflows/production_pipeline.yml

@ -276,7 +276,8 @@ jobs:
uses: ./.github/workflows/aws_deploy.yml uses: ./.github/workflows/aws_deploy.yml
with: with:
aws_account_id: 977287343304 aws_account_id: 977287343304
aws_resource_prefix: core-prod aws_task_prefix: core-prod
aws_role_prefix: core-prod
environment: production environment: production
release_tag: ${{ needs.test.outputs.releasetag }} release_tag: ${{ needs.test.outputs.releasetag }}
permissions: permissions:

3
.github/workflows/staging_pipeline.yml

@ -21,7 +21,8 @@ jobs:
uses: ./.github/workflows/aws_deploy.yml uses: ./.github/workflows/aws_deploy.yml
with: with:
aws_account_id: 837698168072 aws_account_id: 837698168072
aws_resource_prefix: core-review-0 aws_role_prefix: core-dev
aws_task_prefix: core-review-0
environment: review environment: review
permissions: permissions:
id-token: write id-token: write

Loading…
Cancel
Save