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

fix: adjusting the terraform bootstrap to accelerate the creation/destroy #206

Merged
merged 1 commit into from
Jun 20, 2024
Merged
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
76 changes: 37 additions & 39 deletions bootstrap/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ module "eks" {
most_recent = true
}
vpc-cni = {
most_recent = true
before_compute = true # Ensure the addon is configured before compute resources are created
most_recent = true
}
}

Expand All @@ -130,6 +131,8 @@ module "eks" {
}

tags = local.tags

depends_on = [module.vpc]
}

#---------------------------------------------------------------
Expand All @@ -149,9 +152,6 @@ module "eks_blueprints_addons" {
argocd = {
namespace = "argocd"
chart_version = "7.1.0" # ArgoCD v2.11.2
wait = true
wait_for_jobs = true
timeout = "600"
values = [
templatefile("${path.module}/values/argocd.yaml", {
crossplane_aws_provider_enable = local.aws_provider.enable
Expand All @@ -165,13 +165,16 @@ module "eks_blueprints_addons" {

enable_kube_prometheus_stack = true
kube_prometheus_stack = {
wait = true
wait_for_jobs = true
timeout = "600"
values = [file("${path.module}/values/prometheus.yaml")]
timeout = "600"
values = [file("${path.module}/values/prometheus.yaml")]
}

depends_on = [module.eks.eks_managed_node_groups]
depends_on = [module.eks.cluster_addons]
}

resource "time_sleep" "addons_wait_60_seconds" {
create_duration = "60s"
depends_on = [module.eks_blueprints_addons]
}

#---------------------------------------------------------------
Expand All @@ -188,10 +191,8 @@ module "gatekeeper" {
chart = "gatekeeper"
chart_version = "3.16.3"
repository = "https://open-policy-agent.github.io/gatekeeper/charts"
wait = true
timeout = "600"

depends_on = [module.eks_blueprints_addons]
depends_on = [time_sleep.addons_wait_60_seconds]
}

#---------------------------------------------------------------
Expand All @@ -208,11 +209,10 @@ module "crossplane" {
chart = "crossplane"
chart_version = "1.16.0"
repository = "https://charts.crossplane.io/stable/"
wait = true
timeout = "600"
values = [file("${path.module}/values/crossplane.yaml")]

depends_on = [module.eks_blueprints_addons]
depends_on = [time_sleep.addons_wait_60_seconds]
}

resource "kubectl_manifest" "environmentconfig" {
Expand All @@ -233,7 +233,7 @@ locals {

upjet_aws_provider = {
enable = var.enable_upjet_aws_provider # defaults to true
version = "v1.5.0"
version = "v1.6.0"
runtime_config = "upjet-aws-runtime-config"
provider_config_name = "aws-provider-config" #this is the providerConfigName used in all the examples in this repo
families = [
Expand Down Expand Up @@ -307,6 +307,8 @@ module "upjet_irsa_aws" {
}

tags = local.tags

depends_on = [module.crossplane]
}

resource "kubectl_manifest" "upjet_aws_runtime_config" {
Expand All @@ -326,17 +328,16 @@ resource "kubectl_manifest" "upjet_aws_provider" {
version = local.upjet_aws_provider.version
runtime-config = local.upjet_aws_provider.runtime_config
})
wait = true

depends_on = [kubectl_manifest.upjet_aws_runtime_config]
depends_on = [kubectl_manifest.upjet_aws_runtime_config, module.crossplane]
}

# Wait for the Upbound AWS Provider CRDs to be fully created before initiating upjet_aws_provider_config
resource "time_sleep" "upjet_wait_60_seconds" {
count = local.upjet_aws_provider.enable == true ? 1 : 0
create_duration = "60s"

depends_on = [kubectl_manifest.upjet_aws_provider]
depends_on = [kubectl_manifest.upjet_aws_provider, module.crossplane]
}

resource "kubectl_manifest" "upjet_aws_provider_config" {
Expand All @@ -345,7 +346,7 @@ resource "kubectl_manifest" "upjet_aws_provider_config" {
provider-config-name = local.upjet_aws_provider.provider_config_name
})

depends_on = [kubectl_manifest.upjet_aws_provider, time_sleep.upjet_wait_60_seconds]
depends_on = [kubectl_manifest.upjet_aws_provider, time_sleep.upjet_wait_60_seconds, module.crossplane]
}

#---------------------------------------------------------------
Expand All @@ -371,6 +372,8 @@ module "irsa_aws_provider" {
}

tags = local.tags

depends_on = [module.crossplane]
}

resource "kubectl_manifest" "aws_runtime_config" {
Expand All @@ -390,17 +393,16 @@ resource "kubectl_manifest" "aws_provider" {
version = local.aws_provider.version
runtime-config = local.aws_provider.runtime_config
})
wait = true

depends_on = [kubectl_manifest.aws_runtime_config]
depends_on = [kubectl_manifest.aws_runtime_config, module.crossplane]
}

# Wait for the Upbound AWS Provider CRDs to be fully created before initiating aws_provider_config
resource "time_sleep" "aws_wait_60_seconds" {
count = local.aws_provider.enable == true ? 1 : 0
create_duration = "60s"

depends_on = [kubectl_manifest.aws_provider]
depends_on = [kubectl_manifest.aws_provider, module.crossplane]
}

resource "kubectl_manifest" "aws_provider_config" {
Expand All @@ -409,7 +411,7 @@ resource "kubectl_manifest" "aws_provider_config" {
provider-config-name = local.aws_provider.provider_config_name
})

depends_on = [kubectl_manifest.aws_provider, time_sleep.aws_wait_60_seconds]
depends_on = [kubectl_manifest.aws_provider, time_sleep.aws_wait_60_seconds, module.crossplane]
}

#---------------------------------------------------------------
Expand All @@ -432,9 +434,8 @@ resource "kubectl_manifest" "kubernetes_provider_clusterolebinding" {
cluster-role = local.kubernetes_provider.cluster_role
sa-name = kubernetes_service_account_v1.kubernetes_runtime[0].metadata[0].name
})
wait = true

depends_on = [module.crossplane]
depends_on = [kubernetes_service_account_v1.kubernetes_runtime, module.crossplane]
}

resource "kubectl_manifest" "kubernetes_runtime_config" {
Expand All @@ -443,9 +444,8 @@ resource "kubectl_manifest" "kubernetes_runtime_config" {
sa-name = kubernetes_service_account_v1.kubernetes_runtime[0].metadata[0].name
runtime-config = local.kubernetes_provider.runtime_config
})
wait = true

depends_on = [module.crossplane]
depends_on = [kubectl_manifest.kubernetes_provider_clusterolebinding, module.crossplane]
}

resource "kubectl_manifest" "kubernetes_provider" {
Expand All @@ -455,16 +455,15 @@ resource "kubectl_manifest" "kubernetes_provider" {
kubernetes-provider-name = local.kubernetes_provider.name
runtime-config = local.kubernetes_provider.runtime_config
})
wait = true

depends_on = [kubectl_manifest.kubernetes_runtime_config]
depends_on = [module.crossplane, kubectl_manifest.kubernetes_runtime_config]
}

# Wait for the AWS Provider CRDs to be fully created before initiating provider_config deployment
resource "time_sleep" "wait_60_seconds_kubernetes" {
create_duration = "60s"

depends_on = [kubectl_manifest.kubernetes_provider]
depends_on = [module.crossplane, kubectl_manifest.kubernetes_provider]
}

resource "kubectl_manifest" "kubernetes_provider_config" {
Expand All @@ -473,7 +472,7 @@ resource "kubectl_manifest" "kubernetes_provider_config" {
provider-config-name = local.kubernetes_provider.provider_config_name
})

depends_on = [kubectl_manifest.kubernetes_provider, time_sleep.wait_60_seconds_kubernetes]
depends_on = [module.crossplane, kubectl_manifest.kubernetes_provider, time_sleep.wait_60_seconds_kubernetes]
}

#---------------------------------------------------------------
Expand All @@ -496,9 +495,8 @@ resource "kubectl_manifest" "helm_runtime_clusterolebinding" {
cluster-role = local.helm_provider.cluster_role
sa-name = kubernetes_service_account_v1.helm_runtime[0].metadata[0].name
})
wait = true

depends_on = [module.crossplane]
depends_on = [kubernetes_service_account_v1.helm_runtime, module.crossplane]
}

resource "kubectl_manifest" "helm_runtime_config" {
Expand All @@ -507,9 +505,8 @@ resource "kubectl_manifest" "helm_runtime_config" {
sa-name = kubernetes_service_account_v1.helm_runtime[0].metadata[0].name
runtime-config = local.helm_provider.runtime_config
})
wait = true

depends_on = [module.crossplane]
depends_on = [kubectl_manifest.helm_runtime_clusterolebinding, module.crossplane]
}

resource "kubectl_manifest" "helm_provider" {
Expand All @@ -519,16 +516,15 @@ resource "kubectl_manifest" "helm_provider" {
helm-provider-name = local.helm_provider.name
runtime-config = local.helm_provider.runtime_config
})
wait = true

depends_on = [kubectl_manifest.helm_runtime_config]
depends_on = [kubectl_manifest.helm_runtime_config, module.crossplane]
}

# Wait for the AWS Provider CRDs to be fully created before initiating provider_config deployment
resource "time_sleep" "wait_60_seconds_helm" {
create_duration = "60s"

depends_on = [kubectl_manifest.helm_provider]
depends_on = [kubectl_manifest.helm_provider, module.crossplane]
}

resource "kubectl_manifest" "helm_provider_config" {
Expand All @@ -537,7 +533,7 @@ resource "kubectl_manifest" "helm_provider_config" {
provider-config-name = local.helm_provider.provider_config_name
})

depends_on = [kubectl_manifest.helm_provider, time_sleep.wait_60_seconds_helm]
depends_on = [kubectl_manifest.helm_provider, time_sleep.wait_60_seconds_helm, module.crossplane]
}

#---------------------------------------------------------------
Expand All @@ -548,6 +544,8 @@ module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"

manage_default_vpc = true
candonov marked this conversation as resolved.
Show resolved Hide resolved

name = local.vpc_name
cidr = local.vpc_cidr

Expand Down
Loading