Skip to content

Commit

Permalink
feat: add prepare tf workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Kami Wan <[email protected]>
  • Loading branch information
KaimingWan authored and Kami Wan committed May 16, 2024
1 parent 44d8394 commit 9439a4f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/prepare-automq-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Prepare AutoMQ Cluster

on:
workflow_dispatch:
inputs:
cloud_provider:
default: aws-cn
required: true
type: string
region:
default: cn-northwest-1
required: true
type: string
jobs:
prepare_env:
name: Prepare AWS Environment
runs-on: ubuntu-latest
environment: ${{ inputs.cloud_provider }}
steps:
- name: Checkout code
uses: actions/checkout@v3
working-directory: driver-automq/deploy/terraform-aws
## Set AK/SK and terraform s3 backend info
run: |
sed -i 's/\${TF_BACKEND_BUCKET}/${{ secrets.TF_BACKEND_BUCKET }}/g' ${{vars.TF_FILENAME}}
TIMESTAMP=$(date +%s)
sed -i "s/\${TF_BACKEND_BUCKET}/${{ secrets.TF_BACKEND_KEY }}.$TIMESTAMP/g" ${{vars.TF_FILENAME}}
sed -i "s/\${TF_BACKEND_BUCKET}/${{ inputs.region }}/g" ${{vars.TF_FILENAME}}
sed -i "s/\${AUTOMQ_ACCESS_KEY}/${{ secrets.AUTOMQ_ACCESS_KEY }}/g" ${{vars.TF_VAR_FILENAME}}
sed -i "s/\${AUTOMQ_SECRET_KEY}/${{ secrets.AUTOMQ_SECRET_KEY }}/g" ${{vars.TF_VAR_FILENAME}}
- name: Setup terraform
uses: hashicorp/setup-terraform@v3

- name: Initialize terraform
working-directory: driver-automq/deploy/terraform-aws
run: terraform init

- name: Apply terraform
working-directory: driver-automq/deploy/terraform-aws
run: terraform apply -var-file terraform-aws-cn.tfvars

- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install ansible
run: |
python -m pip install --upgrade pip
python -m pip install --user ansible
python -m pip install --user jmespath
- name: Run ansible lint
uses: ansible/ansible-lint@v6
6 changes: 6 additions & 0 deletions driver-automq/deploy/terraform-aws/provision-kafka-aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ terraform {
version = "3.5.1"
}
}
backend "s3" {
## terraform s3 backend configuration ${TF_BACKEND_BUCKET}
bucket = "${TF_BACKEND_BUCKET}"
key = "${TF_BACKEND_KEY}"
region = "${TF_BACKEND_REGION}"
}
}

variable "public_key_path" {
Expand Down
4 changes: 2 additions & 2 deletions driver-automq/deploy/terraform-aws/terraform-aws-cn.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ebs_volume_type = "gp3"
ebs_volume_size = 10
ebs_iops = 3000

access_key = "your_access_key"
secret_key = "your_secret_key"
access_key = "${AUTOMQ_ACCESS_KEY}"
secret_key = "${AUTOMQ_SECRET_KEY}"

aws_cn = true
4 changes: 2 additions & 2 deletions driver-automq/deploy/terraform-aws/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ebs_volume_type = "gp3"
ebs_volume_size = 10
ebs_iops = 3000

access_key = "your_access_key"
secret_key = "your_secret_key"
access_key = "${AUTOMQ_ACCESS_KEY}"
secret_key = "${AUTOMQ_SECRET_KEY}"

aws_cn = false

0 comments on commit 9439a4f

Please sign in to comment.