Commit ade13005 authored by Thong Kuah's avatar Thong Kuah

Merge branch '218841-extend-ecs-for-fargate' into 'master'

Added Fargate related jobs

Closes #218841

See merge request gitlab-org/gitlab!35173
parents 4591e71c e3135392
---
title: Extend ECS Deploy template with Fargate jobs
merge_request: 35173
author:
type: added
......@@ -112,9 +112,9 @@ Variable. To do so, follow these steps:
section.
1. Specify which AWS platform to target during the Auto DevOps deployment
by adding the `AUTO_DEVOPS_PLATFORM_TARGET` variable.
1. Give this variable the value `ECS` before saving it.
by adding the `AUTO_DEVOPS_PLATFORM_TARGET` variable with one of the following values:
- `FARGATE` if the service you're targeting must be of launch type FARGATE.
- `ECS` if you're not enforcing any launch type check when deploying to ECS.
When you trigger a pipeline, if Auto DevOps is enabled and if you've correctly
[entered AWS credentials as environment variables](../../ci/cloud_deployment/index.md#deploy-your-application-to-the-aws-elastic-container-service-ecs),
......
......@@ -13,11 +13,20 @@
script:
- ecs update-task-definition
review_ecs:
extends: .deploy_to_ecs
.review_ecs_base:
stage: review
extends: .deploy_to_ecs
environment:
name: review/$CI_COMMIT_REF_NAME
.production_ecs_base:
stage: production
extends: .deploy_to_ecs
environment:
name: production
review_ecs:
extends: .review_ecs_base
rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
when: never
......@@ -29,11 +38,21 @@ review_ecs:
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
review_fargate:
extends: .review_ecs_base
rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
when: never
- if: '$CI_KUBERNETES_ACTIVE'
when: never
- if: '$REVIEW_DISABLED'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
production_ecs:
extends: .deploy_to_ecs
stage: production
environment:
name: production
extends: .production_ecs_base
rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
when: never
......@@ -42,3 +61,14 @@ production_ecs:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
production_fargate:
extends: .production_ecs_base
rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
when: never
- if: '$CI_KUBERNETES_ACTIVE'
when: never
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
......@@ -37,6 +37,7 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
context 'when the project is set for deployment to AWS' do
let(:platform_value) { 'ECS' }
let(:review_prod_build_names) { build_names.select {|n| n.include?('review') || n.include?('production')} }
before do
create(:ci_variable, project: project, key: 'AUTO_DEVOPS_PLATFORM_TARGET', value: platform_value)
......@@ -67,8 +68,15 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
end
it 'creates an ECS deployment job for production only' do
expect(build_names).not_to include('review_ecs')
expect(build_names).to include('production_ecs')
expect(review_prod_build_names).to contain_exactly('production_ecs')
end
context 'with FARGATE as a launch type' do
let(:platform_value) { 'FARGATE' }
it 'creates a FARGATE deployment job for production only' do
expect(review_prod_build_names).to contain_exactly('production_fargate')
end
end
context 'and we are not on the default branch' do
......@@ -79,15 +87,22 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
project.repository.create_branch(pipeline_branch)
end
it_behaves_like 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do
let(:job_name) { 'review_ecs' }
%w(review_ecs review_fargate).each do |job|
it_behaves_like 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do
let(:job_name) { job }
end
end
it 'creates an ECS deployment job for review only' do
expect(build_names).to include('review_ecs')
expect(build_names).not_to include('production_ecs')
expect(build_names).not_to include('review')
expect(build_names).not_to include('production')
expect(review_prod_build_names).to contain_exactly('review_ecs')
end
context 'with FARGATE as a launch type' do
let(:platform_value) { 'FARGATE' }
it 'creates an FARGATE deployment job for review only' do
expect(review_prod_build_names).to contain_exactly('review_fargate')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment