Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Init terraform #1

Merged
merged 10 commits into from
Aug 27, 2024
Merged

feat: Init terraform #1

merged 10 commits into from
Aug 27, 2024

Conversation

adityachoudhari26
Copy link
Contributor

No description provided.

resource "random_pet" "postgres" {
length = 2
keepers = {
namespace = var.database_version
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just formatted POSTGRES_16 so I think we can just use the version directly

database_version = var.database_version

settings {
tier = var.tier
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we aren't doing anything with the tier but felt wrong to hardcode directly here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are doing this fine within the module, but you should pass this all the way through to the top level variables file so it is configurable.

# Disable client certificate authentication, which reduces the attack surface
# for the cluster by disabling this deprecated feature. It defaults to false,
# but this will make it explicit and quiet some security tooling.
master_auth {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kept this because the comment seemed like we should keep it


resource "random_pet" "node_pool" {
keepers = {
machine_type = var.machine_type
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, didn't feel right to hardcode the machine type here

"https://www.googleapis.com/auth/sqlservice.admin",
]

shielded_instance_config {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read into what this is, seems like we should keep it for security

variable "node_count" {
description = "The number of nodes in the cluster"
type = number
default = 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure what this should be

network = google_compute_network.vpc.self_link
}

resource "google_compute_global_address" "private_ip_address" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out we actually need this so that the pod can talk to the cloudsql instance since it lives outside the VPC

variable "machine_type" {
description = "The machine type for the cluster"
type = string
default = "n2-standard-4"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looked at the comparison chart and n2 is listed as "general purpose", I don't think we need the super high performant ones

main.tf Outdated
Comment on lines 2 to 3
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 14.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 is the latest. If this is greenfield, is there a reason not to use the latest?
https://registry.terraform.io/modules/terraform-google-modules/project-factory/google/16.0.0

database_version = var.database_version

settings {
tier = var.tier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are doing this fine within the module, but you should pass this all the way through to the top level variables file so it is configurable.


resource "google_compute_subnetwork" "default" {
name = "${var.namespace}-subnet"
ip_cidr_range = "10.10.0.0/16"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versions.tf Outdated
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.40"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.42

main.tf Outdated
source = "./modules/gke"
namespace = var.namespace

deletion_protection = var.gke_delete_protection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about protection for redis & db

main.tf Outdated
Comment on lines 22 to 25
network_connection_string = try(module.networking.network_connection_string)
network_self_link = try(module.networking.network_self_link)
subnetwork_self_link = try(module.networking.subnetwork_self_link)
network_id = try(module.networking.network_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the point of the try?


resource "google_service_account" "this" {
account_id = substr(random_id.this.dec, 0, 30)
display_name = "Ctrlplane"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe prefix with namespace

Copy link
Member

@zacharyblasczyk zacharyblasczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use deletion_protection everywhere.

@adityachoudhari26 adityachoudhari26 changed the title init tf feat: Init terraform Aug 27, 2024
@adityachoudhari26 adityachoudhari26 merged commit e4bc759 into main Aug 27, 2024
2 checks passed
@adityachoudhari26 adityachoudhari26 deleted the init-tf branch August 27, 2024 07:18
@adityachoudhari26
Copy link
Contributor Author

This issue has been resolved in version 1.0.1 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants