93 lines
2.1 KiB
YAML
93 lines
2.1 KiB
YAML
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: Terraform root module
|
|
|
|
trigger:
|
|
ref:
|
|
- refs/heads/main
|
|
- refs/pull/*/head
|
|
|
|
environment:
|
|
TF_IN_AUTOMATION: "1"
|
|
|
|
steps:
|
|
- name: terraform init
|
|
image: hashicorp/terraform:1.3.5
|
|
commands:
|
|
- mkdir -p ~/.ssh
|
|
- chmod 755 ~/.ssh
|
|
- echo "$${CI_SSH_KEY}" | base64 -d > ~/.ssh/id_rsa
|
|
- chmod 600 ~/.ssh/id_rsa
|
|
- terraform init
|
|
environment:
|
|
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
|
|
CI_SSH_KEY:
|
|
from_secret: ci-ssh-key
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: terraform-aws-key-id
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: terraform-aws-secret-access-key
|
|
|
|
- name: terraform plan
|
|
image: hashicorp/terraform:1.3.5
|
|
commands:
|
|
- terraform plan $([[ $${DRONE_BUILD_EVENT} = cron ]] && echo "-detailed-exitcode") -out .tfplan
|
|
environment:
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: terraform-aws-key-id
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: terraform-aws-secret-access-key
|
|
GITEA_TOKEN:
|
|
from_secret: gitea-token
|
|
KUBE_TOKEN:
|
|
from_secret: lawndale-k8s-ci-token
|
|
|
|
- name: terraform apply
|
|
when:
|
|
when:
|
|
branch:
|
|
- main
|
|
event:
|
|
- push
|
|
image: hashicorp/terraform:1.3.5
|
|
commands:
|
|
- terraform apply .tfplan
|
|
environment:
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: terraform-aws-key-id
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: terraform-aws-secret-access-key
|
|
GITEA_TOKEN:
|
|
from_secret: gitea-token
|
|
KUBE_TOKEN:
|
|
from_secret: lawndale-k8s-ci-token
|
|
|
|
---
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: Check docs and format
|
|
|
|
environment:
|
|
TF_IN_AUTOMATION: "1"
|
|
|
|
trigger:
|
|
ref:
|
|
- refs/pull/*/head
|
|
|
|
steps:
|
|
- name: format and generate docs
|
|
image: hashicorp/terraform:1.3.5
|
|
commands:
|
|
- apk add bash wget
|
|
- wget -q https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz -O - | tar -xz terraform-docs -C /usr/local/bin
|
|
- terraform fmt
|
|
- terraform-docs .
|
|
- git diff --exit-code
|
|
|
|
---
|
|
kind: signature
|
|
hmac: fab1e0f28b70ec8cee84520cd4b03df265e12e1ed0625403304ced079ecd11ae
|
|
|
|
...
|