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

Reusable spack terraform module + staging deployment #386

Merged
merged 5 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add config for staging cluster using module
  • Loading branch information
mvandenburgh committed Feb 9, 2023
commit 98925d43e25f933cf446d06976dc86d7a5fe8061
185 changes: 185 additions & 0 deletions terraform/staging/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 112 additions & 0 deletions terraform/staging/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
terraform {
required_version = "~> 1.3.6"

backend "s3" {
bucket = "spack-terraform-state-staging"
key = "terraform.tfstate"
region = "us-west-1"
dynamodb_table = "spack-terraform-state-locks-staging"
encrypt = true
}

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.5"
}
kubectl = {
source = "gavinbunney/kubectl"
version = "~> 1.14"
}
flux = {
source = "fluxcd/flux"
version = "~> 0.22.2"
}
github = {
source = "integrations/github"
version = "~> 5.13.0"
}
}
}

provider "aws" {
region = "us-west-1"
}

provider "helm" {
kubernetes {
host = module.staging_cluster.cluster_endpoint
cluster_ca_certificate = module.staging_cluster.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.staging_cluster.cluster_name, "--region", "us-west-1"]
command = "aws"
}
}
}

provider "kubectl" {
host = module.staging_cluster.cluster_endpoint
cluster_ca_certificate = module.staging_cluster.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.staging_cluster.cluster_name, "--region", "us-west-1"]
command = "aws"
}
}

provider "kubernetes" {
host = module.staging_cluster.cluster_endpoint
cluster_ca_certificate = module.staging_cluster.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.staging_cluster.cluster_name, "--region", "us-west-1"]
command = "aws"
}
}


provider "github" {
owner = "mvandenburgh" # TODO: change this
jjnesbitt marked this conversation as resolved.
Show resolved Hide resolved
token = jsondecode(data.aws_secretsmanager_secret_version.flux_github_token.secret_string).flux_github_token
}


module "staging_cluster" {
source = "../modules/spack"

deployment_name = "staging"

single_nat_gateway = true

availability_zones = ["us-west-1b", "us-west-1c"]

vpc_cidr = "10.0.0.0/16"
public_subnets = [
"10.0.0.0/19",
"10.0.32.0/19",
]
private_subnets = [
"10.0.64.0/19",
"10.0.96.0/19",
"10.0.128.0/19",
"10.0.160.0/19",
]
database_subnets = [
"10.0.192.0/19",
"10.0.224.0/19",
]

flux_repo_name = "spack-infrastructure"
flux_repo_owner = "mvandenburgh"
jjnesbitt marked this conversation as resolved.
Show resolved Hide resolved
flux_branch = "staging"
flux_target_path = "k8s/"

# Use cheap DB instances for staging deployment
cdash_db_instance_class = "db.t3.small"
gitlab_db_instance_class = "db.t3.small"
}
3 changes: 3 additions & 0 deletions terraform/staging/secrets.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "aws_secretsmanager_secret_version" "flux_github_token" {
secret_id = "flux_github_token"
}