From 8ccc5b0a85544993cd4cf7dfde03d05adfee157d Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Thu, 9 Jun 2022 02:45:38 +0000 Subject: [PATCH 1/3] woodpecker: refactor pipeline --- .woodpecker/dns.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.woodpecker/dns.yml b/.woodpecker/dns.yml index 0e117ea..f8903a0 100644 --- a/.woodpecker/dns.yml +++ b/.woodpecker/dns.yml @@ -1,6 +1,6 @@ pipeline: validate: - image: alpine + image: alpine:3.16 when: path: "dns/**" event: pull_request @@ -11,16 +11,16 @@ pipeline: commands: - apk add --no-cache terraform - terraform version - - | - cd dns - echo 'token = "$${LINODE_TOKEN}"' > .auto.tfvars - terraform validate - terraform plan + - cd dns + - terraform init + - terraform validate + - terraform plan -var "token=$LINODE_TOKEN" deploy: - image: alpine + image: alpine:3.16 when: path: "dns/**" + branch: main event: push secrets: - linode_token @@ -29,9 +29,8 @@ pipeline: commands: - apk add --no-cache terraform - terraform version - - | - cd dns - echo 'token = "$${LINODE_TOKEN}"' > .auto.tfvars - terraform validate - terraform plan -out deploy.plan - terraform apply deploy.plan + - cd dns + - terraform init + - terraform validate + - terraform plan -out deploy.plan -var "token=$LINODE_TOKEN" + - terraform apply deploy.plan -var "token=$LINODE_TOKEN" From 0090f4312f1119fdd251257231581fb462972b2a Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Thu, 9 Jun 2022 02:38:02 +0000 Subject: [PATCH 2/3] dns: add test record --- dns/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dns/main.tf b/dns/main.tf index fb72342..bc40892 100644 --- a/dns/main.tf +++ b/dns/main.tf @@ -149,3 +149,10 @@ resource "linode_domain_record" "apex_domainkey" { record_type = "TXT" target = "v=DKIM1; k=rsa; s=email; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlJGZN1aCAUd8CqyQA7Akzkvns+Wq/w70ft2xr0B8jFp0DtW8BtyLLAsErpIp5ZTDgReYGgL7cNcSsNQRn+d6ZaOBGlC/gH1T3KYfbsvavOdnbGx9gofi6x8I5QOOLhp7epK5YkaP/Igg58Zm0ni3jdeMCuX+qkJVqn2WVv8IcRtIA3zJrTYOW3lGCj1ieezl5ref+43mFvcUqidToR9XyHNmi1RowmWAofbZASXkNqZiR1P2Jw3s7q6p0fAEz6bODNOmngIlRAaKjBfDVezsaTeQJwsMg9g58GigVTSb9gMHRZon61yxWcCJtcivPug7xAVlVU+MMkDr7MfvUke5KQIDAQAB" } + +resource "linode_domain_record" "apex_test" { + domain_id = "${linode_domain.treehouse_domain.id}" + name = "test" + record_type = "TXT" + target = "this is a test record" +} From 1b832284476525ee9408cf04db6174942870afb9 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Thu, 9 Jun 2022 03:23:53 +0000 Subject: [PATCH 3/3] dns: use linode object storage for tfstate --- .woodpecker/dns.yml | 10 ++-------- dns/main.tf | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.woodpecker/dns.yml b/.woodpecker/dns.yml index f8903a0..1a0a918 100644 --- a/.woodpecker/dns.yml +++ b/.woodpecker/dns.yml @@ -4,10 +4,6 @@ pipeline: when: path: "dns/**" event: pull_request - secrets: - - linode_token - - aws_access_key_id - - aws_secret_access_key commands: - apk add --no-cache terraform - terraform version @@ -15,6 +11,7 @@ pipeline: - terraform init - terraform validate - terraform plan -var "token=$LINODE_TOKEN" + secrets: [linode_token, aws_access_key_id, aws_secret_access_key] deploy: image: alpine:3.16 @@ -22,10 +19,6 @@ pipeline: path: "dns/**" branch: main event: push - secrets: - - linode_token - - aws_access_key_id - - aws_secret_access_key commands: - apk add --no-cache terraform - terraform version @@ -34,3 +27,4 @@ pipeline: - terraform validate - terraform plan -out deploy.plan -var "token=$LINODE_TOKEN" - terraform apply deploy.plan -var "token=$LINODE_TOKEN" + secrets: [linode_token, aws_access_key_id, aws_secret_access_key] diff --git a/dns/main.tf b/dns/main.tf index bc40892..17da10f 100644 --- a/dns/main.tf +++ b/dns/main.tf @@ -5,6 +5,15 @@ terraform { version = "1.26.0" } } + + backend "s3" { + bucket = "treehouse-state" + key = "tfstate" + region = "us-southeast-1" + endpoint = "us-southeast-1.linodeobjects.com" + skip_credentials_validation = true + skip_region_validation = true + } } provider "linode" {