stages:
- build
- test
build-code-job:
stage: build
script:
- echo "Check the ruby version, then build some Ruby project files:"
- ruby -v
- rake
test-code-job1:
stage: test
script:
- echo "If the files are built successfully, test some files with one command:"
- rake test1
test-code-job2:
stage: test
script:
- echo "If the files are built successfully, test other files with a different command:"
- rake test2
job:
# use regexp
image: golang:alpine
script:
- |
printenv
only:
- /^issue-.*$/
# use special keyword
except:
- branches
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
allow_failure: true
- if: '$CI_PIPELINE_SOURCE == "schedule"'
git cibr ${branch_name}
[alias]
cibr = !export cur_br=$1 && echo $1 && git branch ${cur_br} &&
git push origin ${cur_br} && sleep 30 && git push origin --delete ${cur_br} &&
git branch -d ${cur_br} && echo "done"
tools | Pulumi | Terraform | Cloudformation |
---|---|---|---|
language | JS/Go/python... | HCL | Json/Yaml |
Cloud | All | All | AWS |
Source | Open | Open | Close |
Rollback | ? | No | Yes |
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
MyEC2Instance: #An inline comment
Type: "AWS::EC2::Instance"
Properties:
ImageId: "ami-0ff8a91507f77f867" #Another comment -- This is a Linux AMI
InstanceType: t2.micro
KeyName: testkey
BlockDeviceMappings:
-
DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: 200
DeleteOnTermination: false
VolumeSize: 20
terraform {
backend "s3" {
bucket = "mybucket"
key = "path/to/my/key"
region = "us-east-1"
}
}
provider "aws" {
profile = "default"
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-2757f631"
instance_type = "t2.micro"
}
以Gitlab-ci搭配cloudformation示範
image: amazon/aws-sam-cli-build-image-python3.8
variables:
HANDLER: handler
stages:
- deploy
update_lambda:
stage: deploy
script:
- |
sam build --template-file template.yaml
sam package --region ap-northeast-1 --resolve-s3
sam deploy \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--region ap-northeast-1 \
--stack-name $BRANCH-migration \
--resolve-s3 \
--parameter-overrides Handler=${HANDLER}
only:
- test
- qa
- stag
- prep
- prod
- cust
Gitlab-ci.yml for lambda example
以Gitlab-ci搭配terraform示範