-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from skyscrapers/addConcourseTask
add concourse deploy task
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
platform: linux | ||
image_resource: | ||
type: docker-image | ||
source: | ||
repository: "python" | ||
tag: "2.7.13-alpine" | ||
|
||
params: | ||
TF_PROJECT_FOLDER: | ||
TF_VERSION: "0.10.8" | ||
AWS_DEFAULT_REGION: eu-west-1 | ||
TF_ENVIRONMENT: | ||
|
||
inputs: | ||
- name: terraform-repo | ||
- name: terraform-bluegreen | ||
- name: ami | ||
|
||
run: | ||
path: sh | ||
args: | ||
- -exc | ||
- | | ||
# Install dependencies | ||
apk add --update unzip curl jq git | ||
# Install terraform | ||
curl -s -o "terraform.zip" "https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip" | ||
unzip terraform.zip | ||
export PATH=$PATH:$PWD | ||
# Install dependencies of the deployment script | ||
pip install -r terraform-bluegreen/requirements.txt | ||
# Install awscli | ||
pip install awscli | ||
# Extract AMI id from packer manifest | ||
AMI_ID=$(cat ami/packer_manifest.json | jq -r ".last_run_uuid as \$last_run_uuid | .builds | map(select(.packer_run_uuid == \$last_run_uuid))[0].artifact_id" | cut -d: -f2) | ||
WORKDIR=$PWD | ||
cd terraform-repo/$TF_PROJECT_FOLDER | ||
# Init terraform | ||
terraform init | ||
terraform workspace select $TF_ENVIRONMENT | ||
# Deploy | ||
$WORKDIR/terraform-bluegreen/bluegreen.py -f $WORKDIR/terraform-repo/$TF_PROJECT_FOLDER -a $AMI_ID -c apply -t 500 -e $WORKDIR/terraform-repo/$TF_PROJECT_FOLDER/$TF_ENVIRONMENT.tfvars |