Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into resolve-backend-tem…
Browse files Browse the repository at this point in the history
…plate-content
  • Loading branch information
d33bs committed Apr 11, 2024
2 parents a35232d + 5ee5e75 commit 6ab3545
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# misc checks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -18,12 +18,12 @@ repos:
exclude: "tests/data/gcp-mock-credentials.json"
# checking yaml formatting
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
rev: v1.35.1
hooks:
- id: yamllint
# checking spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
exclude: >
Expand Down
30 changes: 30 additions & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Hook for checking values from cookiecutter variables before generating the project.
See the following for more information:
https://cookiecutter.readthedocs.io/en/1.7.0/advanced/hooks.html
"""

import sys

project_name = "{{ cookiecutter.project_name }}"
project_gc_project = "{{ cookiecutter.project_gc_project }}"

# checking for proper length of the project name
# note: we provide the limitation here based on constraints
# for Google service accounts and how the variable is used within template.
# See the following for more information:
# https://cloud.google.com/iam/docs/service-accounts-create#creating
if not 6 <= len(project_name) <= 21:
print(
"ERROR: %s Please use a project name of length 6-21 characters!" % project_name
)
sys.exit(1)

# limitation for google project names
# see the following for more information:
# https://cloud.google.com/resource-manager/docs/creating-managing-projects
if not 4 <= len(project_gc_project) <= 30:
print(
"ERROR: %s Please use a Google project name of length 4-30 characters!" % project_name
)
sys.exit(1)
2 changes: 1 addition & 1 deletion project.cue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import "universe.dagger.io/docker"
_tf_build: docker.#Build & {
steps: [
docker.#Pull & {
source: "ghcr.io/antonbabenko/pre-commit-terraform:v1.83.3"
source: "ghcr.io/antonbabenko/pre-commit-terraform:v1.88.4"
},
docker.#Set & {
config: {
Expand Down
24 changes: 12 additions & 12 deletions {{ cookiecutter.project_name }}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# misc checks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,32 +14,32 @@ repos:
- id: detect-private-key
# checking yaml formatting
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
rev: v1.35.1
hooks:
- id: yamllint
# checking spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
exclude: >
(?x)^(
.*\.lock|.*\.csv
)$
(?x)^(
.*\.lock|.*\.csv
)$
# checking markdown formatting
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
# ignore terraform autogenerated docs
exclude: >
(?x)^(
terraform/.* |
terraform/.*/.*
)$
(?x)^(
terraform/.* |
terraform/.*/.*
)$
# linting for terraform
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.83.3
rev: v1.88.4
hooks:
- id: terraform_docs
args:
Expand All @@ -48,4 +48,4 @@ repos:
- --hook-config=--create-file-if-not-exist=true
- id: terraform_fmt
- id: terraform_tflint
- id: terraform_tfsec
- id: terraform_trivy
2 changes: 1 addition & 1 deletion {{ cookiecutter.project_name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This repository uses [Terraform](https://developer.hashicorp.com/terraform/intro
See below for an overview of roles which are important to context for various parts of this repository.

- __Terraform Administrator__: this role involves administrating over cloud resources created with Terraform. Content found under the `terraform` directory and following steps under [Tutorial: Bucket Infrastructure](#%EF%B8%8F-bucket-infrastructure) apply to this role.
- __Data Provider__: this role involves using content under `utilties/data-provider` to synchronize (add, update, or remove) data to the bucket created by a Terraform Administrator. Instructions specific to this role are provided under [`utilities/data-provider/README.md`](utilities/data-provider/README.md).
- __Data Provider__: this role involves using content under `utilities/data-provider` to synchronize (add, update, or remove) data to the bucket created by a Terraform Administrator. Instructions specific to this role are provided under [`utilities/data-provider/README.md`](utilities/data-provider/README.md).
- __Data Receiver__: this role is involved with downloading content from the bucket after it has been uploaded by the data provider. Associated content may be found under [`utilities/data-receiver/README.md`](utilities/data-receiver/README.md).

## 🛠️ Install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.5.7 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.7.5 |
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 4.83.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | ~> 2.4.0 |

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tf account creation and related work
# Create a new service account
resource "google_service_account" "service_account" {
account_id = "${var.initiative_label}-svc-account"
account_id = "${var.initiative_label}-svc-acct"
}

#Create a service-account key for the associated service account
Expand Down
12 changes: 12 additions & 0 deletions {{ cookiecutter.project_name }}/terraform/operations/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
variable "project" {
description = "Google Cloud project to create the related resources in."
type = string
validation {
condition = length(var.project) >= 4 && length(var.project) <= 30
error_message = "Project name must be between 4 and 30 characters."
}
}

variable "region" {
Expand All @@ -12,9 +16,17 @@ variable "region" {
variable "bucket_name" {
description = "Name for the bucket being created."
type = string
validation {
condition = length(var.bucket_name) >= 3 && length(var.bucket_name) <= 63
error_message = "Bucket name must be between 3 and 63 characters."
}
}

variable "initiative_label" {
description = "Label for specific initiative useful for differentiating between various resources."
type = string
validation {
condition = length(var.initiative_label) >= 6 && length(var.initiative_label) <= 21
error_message = "Initiative label must be between 6 and 23 characters."
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tf versions
terraform {
required_version = "~> 1.5.7"
required_version = "~> 1.7.5"
required_providers {
google = {
source = "hashicorp/google"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.5.7 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.7.5 |
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 4.83.0 |

## Providers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
variable "project" {
description = "Google Cloud project to create the related resources in."
type = string
validation {
condition = length(var.project) >= 4 && length(var.project) <= 30
error_message = "Project name must be between 4 and 30 characters."
}
}

variable "region" {
Expand All @@ -12,9 +16,17 @@ variable "region" {
variable "bucket_name" {
description = "Name for the bucket being created."
type = string
validation {
condition = length(var.bucket_name) >= 3 && length(var.bucket_name) <= 63
error_message = "Bucket name must be between 3 and 63 characters."
}
}

variable "initiative_label" {
description = "Label for specific initiative useful for differentiating between various resources."
type = string
validation {
condition = length(var.initiative_label) >= 6 && length(var.initiative_label) <= 21
error_message = "Initiative label must be between 6 and 23 characters."
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tf versions
terraform {
required_version = "~> 1.5.7"
required_version = "~> 1.7.5"
required_providers {
google = {
source = "hashicorp/google"
Expand Down

0 comments on commit 6ab3545

Please sign in to comment.