Skip to content

Commit

Permalink
Add terraform configurations for single-cluster ref arch
Browse files Browse the repository at this point in the history
  • Loading branch information
nandajavarma authored and roboquat committed Aug 18, 2022
1 parent d7362c6 commit b09a3eb
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 50 deletions.
92 changes: 47 additions & 45 deletions install/infra/single-cluster/aws/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,53 @@ apply: apply-cluster apply-tools
.PHONY: destroy
destroy: destroy-tools destroy-cluster

.PHONY: plan-cluster
plan-cluster:
@terraform plan -target=module.eks

.PHONY: plan-tools
plan-tools: plan-cm-edns plan-cluster-issuer

.PHONY: plan-cm-edns
plan-cm-edns:
@terraform plan -target=module.certmanager -target=module.externaldns

.PHONY: plan-cluster-issuer
plan-cluster-issuer:
@terraform plan -target=module.cluster-issuer

.PHONY: apply-cluster
apply-cluster:
@terraform apply -target=module.eks --auto-approve

.PHONY: apply-tools
apply-tools: install-cm-edns install-cluster-issuer

.PHONY: install-cm-edns
install-cm-edns:
@terraform apply -target=module.certmanager -target=module.externaldns --auto-approve

PHONY: install-cluster-issuer
install-cluster-issuer:
@terraform apply -target=module.cluster-issuer --auto-approve

.PHONY: destroy-cluster
destroy-cluster:
@terraform destroy -target=module.eks --auto-approve

.PHONY: destroy-tools
destroy-tools: destroy-cluster-issuer destroy-cm-edns

.PHONY: destroy-cm-edns
destroy-cm-edns:
@terraform destroy -target=module.certmanager -target=module.externaldns --auto-approve

.PHONY: destroy-cluster-issuer
destroy-cluster-issuer:
@terraform destroy -target=module.cluster-issuer --auto-approve

## Output targets

.PHONY: refresh
refresh:
@echo "Refreshing terraform state"
Expand Down Expand Up @@ -73,49 +120,4 @@ output-issuer:
@echo "================="
@terraform output -json cluster_issuer | jq

.PHONY: plan-cluster
plan-cluster:
@terraform plan -target=module.eks

.PHONY: plan-tools
plan-tools: plan-cm-edns plan-cluster-issuer

.PHONY: plan-cm-edns
plan-cm-edns:
@terraform plan -target=module.certmanager -target=module.externaldns

.PHONY: plan-cluster-issuer
plan-cluster-issuer:
@terraform plan -target=module.cluster-issuer

.PHONY: apply-cluster
apply-cluster:
@terraform apply -target=module.eks --auto-approve

.PHONY: apply-tools
apply-tools: install-cm-edns install-cluster-issuer

.PHONY: install-cm-edns
install-cm-edns:
@terraform apply -target=module.certmanager -target=module.externaldns --auto-approve

PHONY: install-cluster-issuer
install-cluster-issuer:
@terraform apply -target=module.cluster-issuer --auto-approve

.PHONY: destroy-cluster
destroy-cluster:
@terraform destroy -target=module.eks --auto-approve

.PHONY: destroy-tools
destroy-tools: destroy-cluster-issuer destroy-cm-edns

.PHONY: destroy-cm-edns
destroy-cm-edns:
@terraform destroy -target=module.certmanager -target=module.externaldns --auto-approve

.PHONY: destroy-cluster-issuer
destroy-cluster-issuer:
@terraform destroy -target=module.cluster-issuer --auto-approve

# end
3 changes: 3 additions & 0 deletions install/infra/single-cluster/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ corresponding TLS certificate requests.
## Initialize terraform backend and confirm the plan
> ⚠️ We ship 4 terraform modules here and some of them have dependencies among each other (eg: `cert-manager` module depends on `eks` module for `kubeconfig`, or the `cluster-issuer` module depends on `cert-manager` for the CRD). Hence a simple run of `terraform plan` or `terraform apply` may lead to errors. Hence we wrap [targeted `terraform` operations](https://learn.hashicorp.com/tutorials/terraform/resource-targeting) in the following make targets. If you wish you use `terraform` commands instead, please make sure you look into the Makefile to understand the target order.
* Initialize the terraform backend with:
``` sh
Expand Down
2 changes: 1 addition & 1 deletion install/infra/single-cluster/aws/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
terraform {
backend "s3" {
bucket = "nan-tf-bucket"
bucket = "gitpod-tf"
key = "aws/terraform.state"
}
}
8 changes: 4 additions & 4 deletions install/infra/single-cluster/aws/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# the cluster_name should be of length less than 16 characters
cluster_name = "nan"
# the cluster_name should be of length less than 15 characters and surrounded by double quotes
cluster_name =

# a route53 zone and certificate request will be created for this domain
domain_name = "nan-cluster.doptig.com"
# a route53 zone and certificate request will be created for this domain and surrounded by double quotes
domain_name =

region = "eu-west-1"

Expand Down
3 changes: 3 additions & 0 deletions install/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ module "eks" {
image_id = var.eks_node_image_id
kubeconfig = var.kubeconfig
cluster_version = var.cluster_version
create_external_registry = true
create_external_database = true
create_external_storage = true
}

module "certmanager" {
Expand Down

0 comments on commit b09a3eb

Please sign in to comment.