Skip to content

Commit 2b838d8

Browse files
authored
Merge pull request #25 from diggerhq/bot-pr-1739241000798
Opsless setup 2/4 - create Terraform files
2 parents 6ad0178 + 368d109 commit 2b838d8

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

opsless_system/main.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
terraform {
2+
required_version = ">= 1.0.0"
3+
4+
required_providers {
5+
google = {
6+
source = "hashicorp/google"
7+
version = "~> 4.0"
8+
}
9+
}
10+
}
11+
12+
provider "google" {
13+
# You can also specify credentials if needed, e.g.:
14+
# credentials = file("path/to/service_account_key.json")
15+
16+
# Replace these with your actual project/region or pass them via variables
17+
project = var.project_id
18+
region = var.region
19+
}
20+
21+
# Ensure the Cloud Storage API is enabled
22+
resource "google_project_service" "storage_api" {
23+
project = var.project_id
24+
service = "storage.googleapis.com"
25+
}
26+
27+
resource "google_storage_bucket" "terraform_state" {
28+
name = var.bucket_name
29+
location = var.region
30+
uniform_bucket_level_access = true
31+
32+
versioning {
33+
enabled = true
34+
}
35+
36+
# If you want Terraform to be able to delete a non-empty bucket,
37+
# set force_destroy to true. Otherwise, it must be empty before deletion.
38+
force_destroy = false
39+
}
40+
41+
output "bucket_name" {
42+
description = "Name of the GCS bucket for Terraform remote state."
43+
value = google_storage_bucket.terraform_state.name
44+
}

opsless_system/variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
variable "project_id" {
2+
type = string
3+
description = "The GCP project ID where resources will be created."
4+
}
5+
6+
variable "region" {
7+
type = string
8+
description = "The region in which to create the bucket (e.g., 'us-central1')."
9+
default = "us-central1"
10+
}
11+
12+
variable "bucket_name" {
13+
type = string
14+
description = "Name of the GCS bucket to store Terraform state."
15+
}

0 commit comments

Comments
 (0)