Skip to content

Add dags and plugins to staging composer #3833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/composer-apply-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Apply Airflow DAGs

on:
pull_request:
paths:
- 'airflow/**'

jobs:
staging:
name: Staging
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: 'google-github-actions/auth@v2'
with:
create_credentials_file: 'true'
project_id: cal-itp-data-infra-staging
workload_identity_provider: 'projects/473674835135/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'github-actions-terraform@cal-itp-data-infra-staging.iam.gserviceaccount.com'

- name: Terraform Apply
uses: dflook/terraform-apply@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: iac/cal-itp-data-infra-staging/airflow/us
29 changes: 29 additions & 0 deletions .github/workflows/composer-plan-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Plan Airflow DAGs

on:
pull_request:
paths:
- 'airflow/**'

jobs:
staging:
name: Staging
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: 'google-github-actions/auth@v2'
with:
create_credentials_file: 'true'
project_id: cal-itp-data-infra-staging
workload_identity_provider: 'projects/473674835135/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'github-actions-terraform@cal-itp-data-infra-staging.iam.gserviceaccount.com'

- name: Terraform Plan
uses: dflook/terraform-plan@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add_github_comment: changes-only
path: iac/cal-itp-data-infra-staging/airflow/us
10 changes: 4 additions & 6 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ jobs:

staging:
name: Staging

needs: targets

needs: [targets]
if: ${{ needs.targets.outputs.staging != '[]' && needs.targets.outputs.staging != '' }}
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -79,9 +78,8 @@ jobs:

production:
name: Production

needs: targets

needs: [targets]
if: ${{ needs.targets.outputs.production != '[]' && needs.targets.outputs.production != '' }}
runs-on: ubuntu-latest

permissions:
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
jobs:
targets:
name: Find targets

runs-on: ubuntu-latest

outputs:
Expand Down Expand Up @@ -37,9 +36,8 @@ jobs:

staging:
name: Staging

needs: targets

needs: [targets]
if: ${{ needs.targets.outputs.staging != '[]' && needs.targets.outputs.staging != '' }}
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -85,9 +83,8 @@ jobs:

production:
name: Production

needs: targets

needs: [targets]
if: ${{ needs.targets.outputs.production != '[]' && needs.targets.outputs.production != '' }}
runs-on: ubuntu-latest

permissions:
Expand Down
22 changes: 22 additions & 0 deletions iac/cal-itp-data-infra-staging/airflow/us/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions iac/cal-itp-data-infra-staging/airflow/us/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
provider "google" {
project = "cal-itp-data-infra-staging"
}

terraform {
required_providers {
google = {
version = "~> 4.59.0"
}
}

backend "gcs" {
bucket = "calitp-staging-gcp-components-tfstate"
prefix = "cal-itp-data-infra-staging/airflow"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locals {
files = setunion(
fileset("../../../../airflow", "dags/**/*.py"),
fileset("../../../../airflow", "dags/**/*.yml"),
fileset("../../../../airflow", "dags/**/*.md"),
fileset("../../../../airflow", "plugins/**/*.py")
)
}

resource "google_storage_bucket_object" "calitp-staging-composer" {
for_each = local.files
name = each.value
source = each.value
bucket = data.terraform_remote_state.gcs.outputs.google_storage_bucket_calitp-staging-composer_id
}
17 changes: 17 additions & 0 deletions iac/cal-itp-data-infra-staging/airflow/us/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
data "terraform_remote_state" "networks" {
backend = "gcs"

config = {
bucket = "calitp-staging-gcp-components-tfstate"
prefix = "cal-itp-data-infra-staging/networks"
}
}

data "terraform_remote_state" "gcs" {
backend = "gcs"

config = {
bucket = "calitp-staging-gcp-components-tfstate"
prefix = "cal-itp-data-infra-staging/gcs"
}
}
28 changes: 14 additions & 14 deletions iac/cal-itp-data-infra-staging/gcs/us/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions iac/cal-itp-data-infra-staging/gcs/us/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ output "google_storage_bucket_calitp-staging-composer_name" {
value = google_storage_bucket.calitp-staging-composer.name
}

output "google_storage_bucket_calitp-staging-composer_id" {
value = google_storage_bucket.calitp-staging-composer.id
}

output "google_storage_default_object_acl_tfer--calitp-staging-data-analyses-portfolio-draft_id" {
value = google_storage_default_object_acl.tfer--calitp-staging-data-analyses-portfolio-draft.id
}
Expand Down
2 changes: 1 addition & 1 deletion iac/cal-itp-data-infra-staging/gcs/us/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ provider "google" {
terraform {
required_providers {
google = {
version = "~> 4.59.0"
version = "~> 6.29.0"
}
}

Expand Down
4 changes: 4 additions & 0 deletions iac/cal-itp-data-infra-staging/gcs/us/storage_bucket.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,8 @@ resource "google_storage_bucket" "calitp-staging-composer" {
requester_pays = "false"
storage_class = "STANDARD"
uniform_bucket_level_access = "true"

lifecycle {
ignore_changes = [labels]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ resource "google_storage_bucket_iam_member" "calitp-staging-dbt-docs" {

resource "google_storage_bucket_iam_member" "calitp-staging-composer" {
bucket = google_storage_bucket.calitp-staging-composer.name
member = "projectEditor:cal-itp-data-infra"
member = "projectEditor:cal-itp-data-infra-staging"
role = "roles/storage.legacyBucketOwner"
}
28 changes: 14 additions & 14 deletions iac/cal-itp-data-infra/gcs/us/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion iac/cal-itp-data-infra/gcs/us/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ provider "google" {
terraform {
required_providers {
google = {
version = "~> 4.59.0"
version = "~> 6.29.0"
}
}

Expand Down