Skip to content
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
1 change: 1 addition & 0 deletions .gemini/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Evaluate diffs and static analysis findings from a skeptical maintainer perspect
* Declare `provider = google-beta` explicitly on resources and attributes that require the beta provider under the active `versions.tf` constraints, including `google_cloud_run_v2_worker_pool`, `google_kms_autokey_config`, `google_folder_service_identity`, and `google_spanner_instance`.
* Prefer compact `object({...})` variables with `optional()` attributes over proliferating scalar variables, omitting explicit defaults on `optional()` when the underlying provider default should apply.
* Use `map(...)` collections rather than `list(...)` for multi-instance resources so `for_each` state keys remain stable across insertions and removals, and use deterministic `prefix` tokens rather than random string suffixes for resource naming.
* Name resource, data source, variable, and output labels in snake_case and module labels in kebab-case, as the `terraform_naming_convention` rule in the `.tflint.hcl` file enforces through the `tools/tflint.sh` script, and require a `moved` block for every renamed resource or module so Terraform moves existing state instead of replacing the resource.
* Include plan-time `validation` blocks on variables that mirror underlying provider ENUM values.
* Never hardcode project IDs, folder IDs, or regions in module or stage code, never set `project`, `region`, or `zone` on `provider "google"` or `provider "google-beta"` blocks, and never use `local-exec` or `remote-exec` provisioners when native Terraform resources or data sources exist.
* Preserve safe upstream defaults such as `deletion_protection = coalesce(each.value.deletion_protection, true)` on stateful resources.
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ jobs:
run: |
bash tests/scripts/run_shell_tests.sh

tflint:
name: Terraform Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
persist-credentials: false

- name: Set up TFLint
uses: terraform-linters/setup-tflint@6ffdbaa3be476b3431f7275c26966ef32ff60337 # v6.3.2
with:
tflint_version: v0.64.0
checksums: cca9d13e2e1d7a2c627af60ff899a3c9b74212899416aeb96ec764d2ef954537

- name: Test TFLint Runner
run: |
bash tests/scripts/test_tflint.sh

- name: Run TFLint
run: |
bash tools/tflint.sh -f compact

python-tests:
name: Python Unit Tests & Code Quality
runs-on: ubuntu-latest
Expand Down
24 changes: 24 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,27 @@ rule "terraform_required_providers" {
rule "terraform_required_version" {
enabled = false
}

rule "terraform_naming_convention" {
enabled = true
format = "snake_case"

custom_formats = {
private_snake = {
description = "snake_case with leading _"
regex = "^[_a-z][a-z0-9_]*$"
}
kebab = {
description = "lower kebab case"
regex = "^[a-z][a-z0-9-]*$"
}
}

locals {
format = "private_snake"
}

module {
format = "kebab"
}
}
7 changes: 6 additions & 1 deletion blueprints/fedramp-high/access-context-manager/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

module "access_context_manager" {
moved {
from = module.access_context_manager
to = module.access-context-manager
}

module "access-context-manager" {
source = "../../../modules/access-context-manager"

project_id = var.main_project_id
Expand Down
4 changes: 2 additions & 2 deletions blueprints/fedramp-high/access-context-manager/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

output "access_levels" {
description = "The list of created access levels with their details."
value = module.access_context_manager.access_levels
value = module.access-context-manager.access_levels
}

output "service_perimeters" {
description = "The list of created service perimeters with their details."
value = module.access_context_manager.service_perimeters
value = module.access-context-manager.service_perimeters
}

21 changes: 18 additions & 3 deletions blueprints/fedramp-high/cloud-functions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,34 @@ resource "google_kms_crypto_key_iam_member" "cloud_storage" {
member = each.value
}

resource "google_project_iam_member" "artifactregistry_createOnPushWriter" {
moved {
from = google_project_iam_member.artifactregistry_createOnPushWriter
to = google_project_iam_member.artifactregistry_create_on_push_writer
}

resource "google_project_iam_member" "artifactregistry_create_on_push_writer" {
project = var.main_project_id
role = "roles/artifactregistry.createOnPushWriter"
member = module.service-account-runner.iam_email
}

resource "google_project_iam_member" "logging_logWriter" {
moved {
from = google_project_iam_member.logging_logWriter
to = google_project_iam_member.logging_log_writer
}

resource "google_project_iam_member" "logging_log_writer" {
project = var.main_project_id
role = "roles/logging.logWriter"
member = module.service-account-runner.iam_email
}

resource "google_project_iam_member" "storage_objectUser" {
moved {
from = google_project_iam_member.storage_objectUser
to = google_project_iam_member.storage_object_user
}

resource "google_project_iam_member" "storage_object_user" {
project = var.main_project_id
role = "roles/storage.objectUser"
member = module.service-account-runner.iam_email
Expand Down
6 changes: 3 additions & 3 deletions blueprints/fedramp-high/cloud-functions/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

output "artifact_registry_iam_member" {
description = "IAM member assigned to roles/artifactregistry.createOnPushWriter."
value = google_project_iam_member.artifactregistry_createOnPushWriter.member
value = google_project_iam_member.artifactregistry_create_on_push_writer.member
}

output "bucket" {
Expand All @@ -34,10 +34,10 @@ output "kms_crypto_key_iam_binding_members" {

output "logging_iam_member" {
description = "IAM member assigned to roles/logging.logWriter."
value = google_project_iam_member.logging_logWriter.member
value = google_project_iam_member.logging_log_writer.member
}

output "storage_object_admin_iam_member" {
description = "IAM member assigned to roles/storage.objectAdmin."
value = google_project_iam_member.storage_objectUser.member
value = google_project_iam_member.storage_object_user.member
}
16 changes: 13 additions & 3 deletions blueprints/fedramp-high/cloud-ids/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

resource "google_project_service" "net-host-services" {
moved {
from = google_project_service.net-host-services
to = google_project_service.net_host_services
}

resource "google_project_service" "net_host_services" {
project = var.network_project_id
for_each = toset([
"accesscontextmanager.googleapis.com",
Expand Down Expand Up @@ -45,7 +50,12 @@ data "google_compute_zones" "available" {
status = "UP"
}

module "cloud_ids" {
moved {
from = module.cloud_ids
to = module.cloud-ids
}

module "cloud-ids" {
source = "../../../modules/intrusion-detection-system"
project = var.network_project_id
landing_vpc_network = var.network_name
Expand All @@ -60,5 +70,5 @@ module "cloud_ids" {
severity = var.severity
packet_mirroring_policy_name = "${var.prefix}-${var.packet_mirroring_policy_name}"

depends_on = [google_project_service.net-host-services]
depends_on = [google_project_service.net_host_services]
}
6 changes: 3 additions & 3 deletions blueprints/fedramp-high/cloud-ids/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

output "ids_name" {
description = "The name of the Cloud IDS instance."
value = module.cloud_ids.ids_name
value = module.cloud-ids.ids_name
}

output "ids_private_ip_range_name" {
description = "The private IP range name for the IDS."
value = module.cloud_ids.ids_private_ip_range_name
value = module.cloud-ids.ids_private_ip_range_name
}

output "packet_mirroring_policy_name" {
description = "The name of the packet mirroring policy."
value = module.cloud_ids.packet_mirroring_policy_name
value = module.cloud-ids.packet_mirroring_policy_name
}
2 changes: 1 addition & 1 deletion blueprints/fedramp-high/cloud-run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ https://console.cloud.google.com/run
| name | description | sensitive |
|---|---|:---:|
| [cloud_run](outputs.tf#L1) | Cloud Run Service that was created. | |
| [service-account](outputs.tf#L6) | Service account that was created to run the Cloud Run Service. | |
| [service_account](outputs.tf#L6) | Service account that was created to run the Cloud Run Service. | |
<!-- END TFDOC -->
7 changes: 6 additions & 1 deletion blueprints/fedramp-high/cloud-run/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ resource "google_kms_crypto_key_iam_member" "cloud_run_service_agent_kms_permiss
member = "serviceAccount:service-${data.google_project.project.number}@serverless-robot-prod.iam.gserviceaccount.com"
}

module "cloud_run" {
moved {
from = module.cloud_run
to = module.cloud-run
}

module "cloud-run" {
source = "../../../modules/cloud-run-v2-se/"
project_id = var.main_project_id
name = var.name
Expand Down
4 changes: 2 additions & 2 deletions blueprints/fedramp-high/cloud-run/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

output "cloud_run" {
description = "Cloud Run Service that was created."
value = module.cloud_run
value = module.cloud-run
}

output "service-account" {
output "service_account" {
description = "Service account that was created to run the Cloud Run Service."
value = google_service_account.cloud_run_service_account.email
}
7 changes: 6 additions & 1 deletion blueprints/fedramp-high/cloud-scheduler-job/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ resource "google_kms_crypto_key_iam_member" "pubsub" {
depends_on = [google_project_service.cloudscheduler_api] # Ensure API is enabled before IAM
}

module "pubsub_job" {
moved {
from = module.pubsub_job
to = module.pubsub-job
}

module "pubsub-job" {
source = "../../../modules/cloud-scheduler"
name = var.name
description = var.description
Expand Down
4 changes: 2 additions & 2 deletions blueprints/fedramp-high/cloud-scheduler-job/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

output "id" {
description = "Job ID."
value = module.pubsub_job.id
value = module.pubsub-job.id
}

output "state" {
description = "Job state."
value = module.pubsub_job.state
value = module.pubsub-job.state
}
7 changes: 6 additions & 1 deletion blueprints/fedramp-high/cloud-spanner/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ resource "google_project_service" "spanner_api" {
disable_on_destroy = false
}

module "cloud_spanner" {
moved {
from = module.cloud_spanner
to = module.cloud-spanner
}

module "cloud-spanner" {
source = "../../../modules/spanner-instance-se"
project_id = var.main_project_id
edition = var.edition
Expand Down
2 changes: 1 addition & 1 deletion blueprints/fedramp-high/cloud-spanner/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

output "instance" {
description = "Cloud spanner instance."
value = module.cloud_spanner
value = module.cloud-spanner
}
18 changes: 14 additions & 4 deletions blueprints/fedramp-high/cloud-translation/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ resource "google_project_service" "translate" {

data "google_project" "project" {}

module "input_bucket" {
moved {
from = module.input_bucket
to = module.input-bucket
}

module "input-bucket" {
source = "../../../modules/gcs"
project_id = var.main_project_id
prefix = var.main_project_id
Expand All @@ -35,7 +40,12 @@ module "input_bucket" {
uniform_bucket_level_access = true
}

module "output_bucket" {
moved {
from = module.output_bucket
to = module.output-bucket
}

module "output-bucket" {
source = "../../../modules/gcs"
project_id = var.main_project_id
prefix = var.main_project_id
Expand All @@ -61,8 +71,8 @@ module "workflows" {
kms_key_self_link = var.kms_key_self_link
service_account = google_service_account.workflow_sa.email
env_vars = {
input_bucket = "${module.input_bucket.url}/*.txt"
output_bucket = "${module.output_bucket.url}/${var.output_folder}/"
input_bucket = "${module.input-bucket.url}/*.txt"
output_bucket = "${module.output-bucket.url}/${var.output_folder}/"
src_lang = var.src_lang
target_lang = var.target_lang
parent = "projects/${var.main_project_id}/locations/us-central1"
Expand Down
4 changes: 2 additions & 2 deletions blueprints/fedramp-high/cloud-translation/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

output "input_bucket" {
description = "Bucket that takes documents as input."
value = module.input_bucket
value = module.input-bucket
}

output "output_bucket" {
description = "Bucket that stores translated output."
value = module.output_bucket
value = module.output-bucket
}

output "workflow" {
Expand Down
7 changes: 6 additions & 1 deletion blueprints/fedramp-high/cnap/access_policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

resource "google_access_context_manager_access_levels" "access-levels" {
moved {
from = google_access_context_manager_access_levels.access-levels
to = google_access_context_manager_access_levels.access_levels
}

resource "google_access_context_manager_access_levels" "access_levels" {
parent = "accessPolicies/${var.access_policy_number}"

# Access level for US Region
Expand Down
9 changes: 7 additions & 2 deletions blueprints/fedramp-high/cnap/cloud_ids.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

module "cloud_ids" {
moved {
from = module.cloud_ids
to = module.cloud-ids
}

module "cloud-ids" {
source = "../../../modules/intrusion-detection-system"
project = var.network_project_id
landing_vpc_network = var.network_name # Duplicate variable (landing_network)
Expand All @@ -29,5 +34,5 @@ module "cloud_ids" {
severity = var.severity
packet_mirroring_policy_name = "${var.prefix}-${var.packet_mirroring_policy_name}"

depends_on = [google_project_service.net-host-services]
depends_on = [google_project_service.net_host_services]
}
Loading
Loading