Skip to content

Commit 81e10a9

Browse files
adityatapsclaude
andcommitted
feat(gcp): scaffold tapshalkar-com-web project with web-specific defaults
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 44a5631 commit 81e10a9

7 files changed

Lines changed: 201 additions & 1 deletion

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN := scripts/tf-module.sh $(CMD) $(AUTO_APPROVE)
2626
gcp-personal-tapshalkar-com gcp-personal-sandbox \
2727
aws-personal-tapshalkar-com aws-personal-sandbox aws-certs \
2828
github-sync \
29+
gcp-personal-tapshalkar-com-web \
2930
ci-plan
3031

3132
# ── Entry point ───────────────────────────────────────────────────────────────
@@ -45,7 +46,8 @@ all: github-sync
4546
# accounts read the repo name from github state — which must exist first.
4647
github-sync: gcp-management aws-management \
4748
gcp-personal-tapshalkar-com gcp-personal-sandbox \
48-
aws-personal-tapshalkar-com aws-personal-sandbox aws-certs
49+
aws-personal-tapshalkar-com aws-personal-sandbox aws-certs \
50+
gcp-personal-tapshalkar-com-web
4951
@$(RUN) providers/github
5052

5153
# ── Tier 3: depend on management accounts ─────────────────────────────────────
@@ -64,6 +66,9 @@ aws-personal-sandbox: pagerduty aws-org github-init aws-management
6466
aws-certs: pagerduty aws-org github-init aws-management
6567
@$(RUN) providers/aws/accounts/certs/tapshalkar-com-certs
6668

69+
70+
gcp-personal-tapshalkar-com-web: pagerduty gcp-org github-init gcp-management
71+
@$(RUN) providers/gcp/projects/personal/tapshalkar-com-web
6772
# ── Tier 2: depend on github + pagerduty + org layers ─────────────────────────
6873
gcp-management: pagerduty gcp-org github-init
6974
@$(RUN) providers/gcp/projects/management/tapshalkar-com
@@ -102,3 +107,4 @@ ci-plan:
102107
@$(RUN) providers/gcp/projects/management/tapshalkar-com
103108
@$(RUN) providers/gcp/projects/personal/tapshalkar-com-personal
104109
@$(RUN) providers/gcp/projects/personal/tapshalkar-com-sandbox
110+
\t@$(RUN) providers/gcp/projects/personal/tapshalkar-com-web
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bucket = "tapshalkar-com-tfstate"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
terraform {
2+
backend "gcs" {
3+
# bucket is set via -backend-config or backend.hcl (gitignored)
4+
prefix = "gcp/projects/personal/tapshalkar-com-web"
5+
}
6+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
terraform {
2+
required_version = ">= 1.5"
3+
required_providers {
4+
google = {
5+
source = "hashicorp/google"
6+
version = "~> 5.0"
7+
}
8+
}
9+
}
10+
11+
provider "google" {
12+
project = var.project_id
13+
region = var.region
14+
billing_project = var.management_project_id
15+
user_project_override = true
16+
}
17+
18+
data "terraform_remote_state" "pagerduty" {
19+
backend = "gcs"
20+
config = {
21+
bucket = "tapshalkar-com-tfstate"
22+
prefix = "pagerduty"
23+
}
24+
}
25+
26+
data "terraform_remote_state" "gcp_org" {
27+
backend = "gcs"
28+
config = {
29+
bucket = "tapshalkar-com-tfstate"
30+
prefix = "gcp/org"
31+
}
32+
}
33+
34+
data "terraform_remote_state" "github" {
35+
backend = "gcs"
36+
config = {
37+
bucket = "tapshalkar-com-tfstate"
38+
prefix = "github"
39+
}
40+
}
41+
42+
data "terraform_remote_state" "management" {
43+
backend = "gcs"
44+
config = {
45+
bucket = "tapshalkar-com-tfstate"
46+
prefix = "gcp/projects/management/tapshalkar-com"
47+
}
48+
}
49+
50+
module "baseline" {
51+
source = "../../../modules/baseline"
52+
53+
project_id = var.project_id
54+
project_name = var.project_name
55+
billing_account = data.terraform_remote_state.management.outputs.billing_account_id
56+
admin_user = var.admin_user
57+
region = var.region
58+
budget_amount = var.budget_amount
59+
budget_thresholds = var.budget_thresholds
60+
labels = var.labels
61+
enabled_apis = var.enabled_apis
62+
github_repo = data.terraform_remote_state.github.outputs.core_infra_repo_full_name
63+
enable_data_access_audit_logs = var.enable_data_access_audit_logs
64+
pagerduty_integration_key = data.terraform_remote_state.pagerduty.outputs.gcp_integration_key
65+
folder_id = data.terraform_remote_state.gcp_org.outputs.personal_folder_resource_name
66+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "project_id" {
2+
description = "The GCP project ID"
3+
value = module.baseline.project_id
4+
}
5+
6+
output "project_number" {
7+
description = "The GCP project number"
8+
value = module.baseline.project_number
9+
}
10+
11+
output "github_actions_service_account_email" {
12+
description = "Email of the GitHub Actions service account (set as GCP_SERVICE_ACCOUNT GitHub secret)"
13+
value = module.baseline.github_actions_service_account_email
14+
}
15+
16+
output "workload_identity_provider" {
17+
description = "WIF provider resource name (set as GCP_WORKLOAD_IDENTITY_PROVIDER GitHub secret)"
18+
value = module.baseline.workload_identity_provider
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
project_id = "your-gcp-project-id"
2+
project_name = "My GCP Project"
3+
admin_user = "you@gmail.com"
4+
region = "us-central1"
5+
budget_amount = 20
6+
budget_thresholds = [0.5, 0.9, 1.0]
7+
github_repo = "your-github-username/core-infra"
8+
9+
labels = {
10+
env = "web"
11+
owner = "your-name"
12+
"managed-by" = "terraform"
13+
}
14+
15+
enabled_apis = [
16+
"compute.googleapis.com",
17+
"iam.googleapis.com",
18+
"cloudbilling.googleapis.com",
19+
"billingbudgets.googleapis.com",
20+
"cloudresourcemanager.googleapis.com",
21+
"logging.googleapis.com",
22+
"monitoring.googleapis.com",
23+
"iamcredentials.googleapis.com",
24+
"storage.googleapis.com",
25+
]
26+
27+
# enable_data_access_audit_logs = false # default is false; set to true to enable billable DATA_READ/WRITE audit logs
28+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
variable "management_project_id" {
2+
type = string
3+
description = "Project ID of the management project, used as billing_project for API quota. Defaults to tapshalkar-com."
4+
default = "tapshalkar-com"
5+
}
6+
7+
variable "project_id" {
8+
type = string
9+
description = "GCP project ID"
10+
}
11+
12+
variable "project_name" {
13+
type = string
14+
description = "Human-readable display name for the GCP project"
15+
}
16+
17+
variable "admin_user" {
18+
type = string
19+
description = "Google account email to bind as project owner"
20+
21+
validation {
22+
condition = can(regex("^[^@]+@[^@]+\\.[^@]+$", var.admin_user))
23+
error_message = "admin_user must be a valid email address."
24+
}
25+
}
26+
27+
variable "region" {
28+
type = string
29+
description = "Default GCP region"
30+
default = "us-central1"
31+
}
32+
33+
variable "budget_amount" {
34+
type = number
35+
description = "Monthly budget cap in USD"
36+
}
37+
38+
variable "budget_thresholds" {
39+
type = list(number)
40+
description = "Fractional spend thresholds for budget alerts"
41+
default = [0.5, 0.9, 1.0]
42+
}
43+
44+
variable "labels" {
45+
type = map(string)
46+
description = "Labels to apply to the project"
47+
default = {
48+
env = "web"
49+
"managed-by" = "terraform"
50+
}
51+
}
52+
53+
variable "enabled_apis" {
54+
type = list(string)
55+
description = "GCP APIs to enable"
56+
default = [
57+
"compute.googleapis.com",
58+
"iam.googleapis.com",
59+
"cloudbilling.googleapis.com",
60+
"billingbudgets.googleapis.com",
61+
"cloudresourcemanager.googleapis.com",
62+
"logging.googleapis.com",
63+
"monitoring.googleapis.com",
64+
"iamcredentials.googleapis.com",
65+
"storage.googleapis.com",
66+
]
67+
}
68+
69+
variable "enable_data_access_audit_logs" {
70+
type = bool
71+
description = "Enable DATA_READ and DATA_WRITE audit logs. Billable beyond 50 GiB/month free tier."
72+
default = false
73+
}
74+

0 commit comments

Comments
 (0)