diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..610af6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.terraform/ +.terraform.* \ No newline at end of file diff --git a/README.md b/README.md index 365f973..7c16be2 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,31 @@ To destroy resources: `terraform destroy` +### Common to all +(I think ...) + +``` +provider "google" { + project = var.project_id + region = var.region +} + +data "google_compute_zones" "this" { + region = var.region + project = var.project_id +} + +locals { + type = ["public"] + zones = data.google_compute_zones.this.names +} +``` + ### vpc_with_subnets -Creates a VPC named with one or more subnets (set count) in for . \ No newline at end of file +Creates a VPC named with one or more subnets (set count) in for . + +### Bucket for static files + +Ref: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket + diff --git a/bucket_for_static_objs/main.tf b/bucket_for_static_objs/main.tf new file mode 100644 index 0000000..b251df9 --- /dev/null +++ b/bucket_for_static_objs/main.tf @@ -0,0 +1,34 @@ +provider "google" { + project = var.project_id + region = var.region +} + +data "google_compute_zones" "this" { + region = var.region + project = var.project_id +} + +locals { + type = ["public"] + zones = data.google_compute_zones.this.names +} + +resource "google_storage_bucket" "static-site" { + name = "" + location = var.region + force_destroy = true + project_number = var.project_number + + uniform_bucket_level_access = true + + website { + main_page_suffix = "index.html" + not_found_page = "404.html" + } + cors { + origin = ["*"] + method = ["GET"] + response_header = ["*"] + max_age_seconds = 3600 + } +} diff --git a/bucket_for_static_objs/variables.tf b/bucket_for_static_objs/variables.tf new file mode 100644 index 0000000..0db7481 --- /dev/null +++ b/bucket_for_static_objs/variables.tf @@ -0,0 +1,17 @@ +variable "project_id" { + type = string + description = "Project ID" + default = "" +} + +variable "region" { + type = string + description = "Region for this config" + default = "" +} + +variable "project_number" { + type = string + description = "Project Number" + default = "" +} diff --git a/common_template/main.tf b/common_template/main.tf new file mode 100644 index 0000000..0288e48 --- /dev/null +++ b/common_template/main.tf @@ -0,0 +1,14 @@ +provider "google" { + project = var.project_id + region = var.region +} + +data "google_compute_zones" "this" { + region = var.region + project = var.project_id +} + +locals { + type = ["public"] + zones = data.google_compute_zones.this.names +} diff --git a/common_template/variables.tf b/common_template/variables.tf new file mode 100644 index 0000000..2825517 --- /dev/null +++ b/common_template/variables.tf @@ -0,0 +1,11 @@ +variable "project_id" { + type = string + description = "Project ID" + default = "" +} + +variable "region" { + type = string + description = "Region for this config" + default = "" +}