Templates for EC2 deployment and provisioning via CF
What does this MR do?
This MR introduces a new template named AWS/CF_Provision_and_Deploy_EC2.gitlab-ci.yml
that allows for the creation of a new stack on AWS CloudFormation and the deployment of an application to EC2, following what's described in this diagram:
Scripts can be found in this CloudDeploy
's MR: cloud-deploy!25 (merged)
Manual testing and screenshots
We'll be using a Jekyll sample application to test the new template. Jekyll websites can be deployed out-of-the-box with GitLab Pages. For the sake of testing, we removed everything related to GitLab Pages from the project's .gitlab-ci.yml
file, and added our own build
and review
stages.
- Jekyll demo application (
deploy-to-ec2
branch): https://gitlab.com/ebaque/jekyll-demo/-/tree/deploy-to-ec2 - JSON files to pass in to the scripts: https://gitlab.com/ebaque/jekyll-demo/-/tree/deploy-to-ec2/aws
The template has not merged in yet, so I copy-pasted its content directly in the project's .gitlab-ci.yml
(diffs in the original template -for comparison).
1. First commit, provisioning and application deployment
Commit: ebaque/jekyll-demo@8f2abbb3
Pipeline:
(Additional test: 3 stage pipeline):
The review_ec2
job: https://gitlab.com/ebaque/jekyll-demo/-/jobs/757019607
It does the following:
- it creates the EC2 stack (via CloudFormation)
- it pushes the code to S3
- it deploys to EC2
Checking the website now:
2. Second commit and deployment to update application
New commit: ebaque/jekyll-demo@86415f0e
Pipeline: https://gitlab.com/ebaque/jekyll-demo/-/pipelines/194396250
review_ec2
job skips the creation of the stack (fix: removed "Existing job now" here):
Website:
3. Trying to provision with an incorrect value in template.
CloudFormation JSON template has an incorrect value:
review_ec2
job fails when creating new stack:
3. Deploying with incorrect deployment JSON input
We're using now a deployment template that has an incorrect S3 bucket name:
The review_ec2
job fails, when trying to deploy:
On CodeDeploy:
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #201742 (closed)