Skip to content

Commit

Permalink
Merge pull request #14 from sjmiller609/master
Browse files Browse the repository at this point in the history
fix pipeline failure
  • Loading branch information
sjmiller609 authored Jul 5, 2019
2 parents b9e549f + 4f2cc9a commit 610fbd2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 67 deletions.
65 changes: 2 additions & 63 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ steps:
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
commands:
- cp providers.tf.example examples/from_scratch/providers.tf
- cp backend.tf.example examples/from_scratch/backend.tf
- cd examples/from_scratch
- sed -i "s/REPLACE/$DRONE_BUILD_NUMBER/g" backend.tf
- terraform init
- terraform apply --auto-approve -var "deployment_id=fromscratch$DRONE_BUILD_NUMBER"
- terraform -v
- EXAMPLE=from_scratch pipeline/run_terraform.sh
when:
event:
- push
Expand All @@ -59,62 +53,7 @@ steps:
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
commands:
- cp providers.tf.example examples/from_scratch/providers.tf
- cp backend.tf.example examples/from_scratch/backend.tf
- cd examples/from_scratch
- sed -i "s/REPLACE/$DRONE_BUILD_NUMBER/g" backend.tf
- terraform init
- terraform destroy --auto-approve -var "deployment_id=fromscratch$DRONE_BUILD_NUMBER" -refresh=false
- terraform -v
when:
event:
- push
status:
- failure
- success
branch:
- master

- name: into_subnets
image: hashicorp/terraform:light
depends_on:
- lint
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
commands:
- cp providers.tf.example examples/into_existing_subnets/providers.tf
- cp backend.tf.example examples/into_existing_subnets/backend.tf
- cd examples/into_existing_subnets
- sed -i "s/REPLACE/intosubnets$DRONE_BUILD_NUMBER/g" backend.tf
- terraform init
- terraform apply --auto-approve -var "deployment_id=intosubnets$DRONE_BUILD_NUMBER"
- terraform -v
when:
event:
- push
branch:
- master

- name: into_subnets_cleanup
depends_on:
- into_subnets
image: hashicorp/terraform:light
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
commands:
- cp providers.tf.example examples/into_existing_subnets/providers.tf
- cp backend.tf.example examples/into_existing_subnets/backend.tf
- cd examples/into_existing_subnets
- sed -i "s/REPLACE/intosubnets$DRONE_BUILD_NUMBER/g" backend.tf
- terraform init
- terraform destroy --auto-approve -var "deployment_id=intosubnets$DRONE_BUILD_NUMBER" -refresh=false
- terraform -v
- DESTROY=1 EXAMPLE=from_scratch pipeline/run_terraform.sh
when:
event:
- push
Expand Down
4 changes: 0 additions & 4 deletions eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ module "eks" {

worker_additional_security_group_ids = [aws_security_group.all_worker_mgmt.id]

map_roles = []
map_accounts = []
map_users = []

cluster_endpoint_private_access = "true"

cluster_endpoint_public_access = var.management_api == "public" ? true : false
Expand Down
3 changes: 3 additions & 0 deletions examples/from_scratch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ module "astronomer_aws_with_vpc" {
admin_email = "steven@astronomer.io"
route53_domain = "astronomer-development.com"
management_api = "public"
tags = {
"CI" = "true"
}
}
21 changes: 21 additions & 0 deletions pipeline/run_terraform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set -xe

terraform -v

# unique deployment ID to avoid collisions in CI
# needs to be 32 characters or less and start with letter
DEPLOYMENT_ID=ci$(echo "$DRONE_REPO_NAME$DRONE_BUILD_NUMBER" | md5sum | awk '{print substr($1,0,30)}')
echo $DEPLOYMENT_ID

cp providers.tf.example examples/$EXAMPLE/providers.tf
cp backend.tf.example examples/$EXAMPLE/backend.tf
cd examples/$EXAMPLE
sed -i "s/REPLACE/$DEPLOYMENT_ID/g" backend.tf

terraform init

if [ $DESTROY -eq 1 ]; then
terraform destroy --auto-approve -var "deployment_id=$DEPLOYMENT_ID"
else
terraform apply --auto-approve -var "deployment_id=$DEPLOYMENT_ID"
fi

0 comments on commit 610fbd2

Please sign in to comment.