Skip to content

Add terraform import script #29

Add terraform import script

Add terraform import script #29

name: Import Script Tests
on:
pull_request:
push:
branches:
- main
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- name: Build import script
run: go build -o import_script ./import/import_script.go
test-import-script:
name: Import Script Tests
needs: build
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
terraform:
- latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- name: Run import script tests
env:
IMPORT: "1"
HOSTED_ORGANIZATION_API_TOKEN: ${{ secrets.DEV_HOSTED_ORGANIZATION_API_TOKEN }}
HOSTED_ORGANIZATION_ID: clx42kkcm01fo01o06agtmshg
run: |
cat <<EOF > main.tf
terraform {
required_providers {
astro = {
source = "astronomer/astro"
}
}
}
provider "astro" {
organization_id = "$HOSTED_ORGANIZATION_ID"
host = "https://api.astronomer-dev.io"
token = "$HOSTED_ORGANIZATION_API_TOKEN"
}
EOF
terraform init
make test-import-script
test-import-script-stage:
name: Import Script Tests - Stage
needs: build
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
terraform:
- latest
provider_version:
- v0.3.1
- v0.2.1
- v0.1.0-alpha
- main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- name: Run import script tests
env:
IMPORT: "1"
HOSTED_ORGANIZATION_API_TOKEN: ${{ secrets.STAGE_HOSTED_ORGANIZATION_API_TOKEN }}
HOSTED_ORGANIZATION_ID: clx46acvv060e01ilddqlbsmc
run: |
cat <<EOF > main.tf
terraform {
required_providers {
astro = {
source = "astronomer/astro"
}
}
}
provider "astro" {
organization_id = "$HOSTED_ORGANIZATION_ID"
host = "https://api.astronomer-dev.io"
token = "$HOSTED_ORGANIZATION_API_TOKEN"
}
EOF
terraform init
make test-import-script
test-import-script-dev:
name: Import Script Tests - Dev
needs: build
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
terraform:
- latest
provider_version:
- v0.3.1
- v0.2.1
- v0.1.0-alpha
- main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- name: Run import script tests
env:
IMPORT: "1"
HOSTED_ORGANIZATION_API_TOKEN: ${{ secrets.DEV_HOSTED_ORGANIZATION_API_TOKEN }}
HOSTED_ORGANIZATION_ID: clx42kkcm01fo01o06agtmshg
run: |
cat <<EOF > main.tf
terraform {
required_providers {
astro = {
source = "astronomer/astro"
}
}
}
provider "astro" {
organization_id = "$HOSTED_ORGANIZATION_ID"
host = "https://api.astronomer-dev.io"
token = "$HOSTED_ORGANIZATION_API_TOKEN"
}
EOF
terraform init
make test-import-script