Skip to content

Commit e1f3ac9

Browse files
committed
Add Google Cloud Storage bucket resource to Terraform configuration
1 parent 13d02bd commit e1f3ac9

File tree

2 files changed

+10
-61
lines changed

2 files changed

+10
-61
lines changed

.github/workflows/terraform.yml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +0,0 @@
1-
name: 'Terraform CI/CD'
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
9-
jobs:
10-
terraform:
11-
name: 'Terraform'
12-
runs-on: ubuntu-latest
13-
env:
14-
TF_VAR_project_id: ${{ secrets.GCP_PROJECT_ID }} # Make sure to set this secret in your repository
15-
16-
steps:
17-
- name: 'Checkout'
18-
uses: actions/checkout@v4
19-
20-
- name: 'Authenticate to Google Cloud'
21-
uses: 'google-github-actions/auth@v2'
22-
with:
23-
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}' # Make sure to set this secret in your repository
24-
25-
- name: 'Set up Terraform'
26-
uses: hashicorp/setup-terraform@v3
27-
with:
28-
terraform_version: latest # Or specify a version e.g., 1.0.0
29-
30-
- name: 'Terraform Init'
31-
id: init
32-
run: terraform init
33-
working-directory: ./terraform # Assuming your Terraform files are in a 'terraform' subdirectory
34-
35-
- name: 'Terraform Validate'
36-
id: validate
37-
run: terraform validate -no-color
38-
working-directory: ./terraform
39-
40-
- name: 'Terraform Plan'
41-
id: plan
42-
run: terraform plan -no-color -input=false -out=tfplan
43-
working-directory: ./terraform
44-
# Only run on pull requests or direct pushes to main (not on merges)
45-
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
46-
47-
- name: 'Terraform Apply'
48-
id: apply
49-
run: terraform apply -auto-approve -input=false tfplan
50-
working-directory: ./terraform
51-
# Only run on pushes to the main branch (e.g., after a PR is merged)
52-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
53-
54-
- name: 'Check BigQuery Dataset and Load Titanic Data'
55-
id: bigquery_check
56-
run: |
57-
chmod +x ../scripts/check_and_load_titanic_data.sh
58-
../scripts/check_and_load_titanic_data.sh ${{ secrets.GCP_PROJECT_ID }}
59-
working-directory: ./terraform
60-
# Only run on pushes to the main branch (after terraform apply)
61-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

terraform/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@ resource "google_bigquery_dataset" "test_dataset" {
1313
environment = var.environment
1414
project = var.project_id
1515
}
16+
}
17+
18+
# create a cloud storage bucket for temporary data
19+
resource "google_storage_bucket" "temp_bucket" {
20+
name = "${var.project_id}-temp-bucket"
21+
location = var.region
22+
labels = {
23+
environment = var.environment
24+
project = var.project_id
25+
}
1626
}

0 commit comments

Comments
 (0)