Skip to content

Commit

Permalink
Update to stacks. Add import to all configs. Remove hardcoded set…
Browse files Browse the repository at this point in the history
…tings. Add Terraform S3 backend generation (#6)

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI

* Update CLI
  • Loading branch information
aknysh authored Nov 19, 2020
1 parent 2f876cc commit 835c568
Show file tree
Hide file tree
Showing 54 changed files with 941 additions and 1,515 deletions.
137 changes: 64 additions & 73 deletions README.md

Large diffs are not rendered by default.

137 changes: 64 additions & 73 deletions README.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions example/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ aws-assumed-role/
**/*.terraform.tfvars.json
**/*.terraform.auto.tfvars.json
**/*.helmfile.vars.yaml
**/vendir.lock.yml

# Module directory
**/.terraform/
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ aws-assumed-role/
**/*.terraform.tfvars.json
**/*.terraform.auto.tfvars.json
**/*.helmfile.vars.yaml
**/vendir.lock.yml

# Module directory
# Note that the leading "**/" appears necessary for Docker even if not for Git
Expand Down
14 changes: 8 additions & 6 deletions example/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ RUN apk add kubectl-1.17@cloudposse
# Install terraform.
# Install the latest 0.12 and 0.13 versions of terraform
RUN apk add -u terraform-0.12@cloudposse terraform-0.13@cloudposse~=0.13.3
# Set Terraform 0.12.x as the default `terraform`. You can still use
# Set Terraform 0.13.x as the default `terraform`. You can still use
# `terraform-0.12` or `terraform-0.13` to be explicit when needed.
RUN update-alternatives --set terraform /usr/share/terraform/0.12/bin/terraform
RUN update-alternatives --set terraform /usr/share/terraform/0.13/bin/terraform

# https://github.com/Versent/saml2aws#linux
RUN apk add saml2aws@cloudposse

# Install assume-role
RUN apk add assume-role@cloudposse

# Install vendir
RUN apk add vendir@cloudposse

# Install variant2
RUN apk add variant2@cloudposse
RUN update-alternatives --set variant /usr/share/variant/2/bin/variant
Expand All @@ -71,8 +74,7 @@ RUN update-alternatives --set variant /usr/share/variant/2/bin/variant
ARG CLI_NAME
COPY --from=cli /usr/cli/$CLI_NAME /usr/local/bin

COPY projects/ /projects/
COPY config/ /config/

COPY stacks/ /stacks/
COPY vendir.yml /vendir.yml

WORKDIR /projects
WORKDIR /
27 changes: 11 additions & 16 deletions example/cli/main.variant
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/usr/bin/env variant
# vim: filetype=hcl

option "region" {
default = "us-east-2"
description = "AWS region"
type = string
}

option "dry-run" {
default = false
description = "Disable execution of any commands and echo the commands instead"
description = "Disable execution of any commands and echo the command instead"
type = bool
}

Expand All @@ -20,42 +14,43 @@ option "kubeconfig-path" {
}

option "kubeconfig-profile-pattern" {
default = "eg-gbl-$$stage-helm"
default = "{namespace}-{environment}-{stage}-helm"
description = "AWS profile pattern for kubeconfig"
type = string
}

option "cluster-name-pattern" {
default = "eg-$$environment-$$stage-eks-cluster"
default = "{namespace}-{environment}-{stage}-eks-cluster"
description = "Cluster name pattern"
type = string
}

option "terraform-dir" {
default = "./"
description = "Terraform projects directory"
default = "./components/terraform"
description = "Terraform components directory"
type = string
}

option "helmfile-dir" {
default = "./helmfiles"
description = "Helmfile projects directory"
default = "./components/helmfiles"
description = "Helmfile components directory"
type = string
}

option "config-dir" {
default = "../config"
description = "Config directory"
default = "./stacks"
description = "Stacks config directory"
type = string
}

option "vendor-config-path" {
default = "../vendor/vendir.yml"
default = "./vendir.yml"
description = "Path to the vendor configuration file"
type = string
}

imports = [
"git::https://[email protected]/cloudposse/atmos@modules/utils?ref=master",
"git::https://[email protected]/cloudposse/atmos@modules/shell?ref=master",
"git::https://[email protected]/cloudposse/atmos@modules/kubeconfig?ref=master",
"git::https://[email protected]/cloudposse/atmos@modules/terraform?ref=master",
Expand Down
20 changes: 0 additions & 20 deletions example/components/eks/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions example/components/helmfiles/ingress-nginx/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions example/components/vpc/.gitignore

This file was deleted.

38 changes: 0 additions & 38 deletions example/config/workflows.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions example/stacks/globals.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace: eg

terraform_backend_environment: ue2

terraform_backend_stage: root

terraform_backend_role_environment: gbl

terraform_backend_role_stage: root

kubeconfig_profile_environment: gbl
13 changes: 10 additions & 3 deletions example/config/ue2-dev.yaml → example/stacks/ue2-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
projects:
import:
- globals
- ue2-globals

components:
globals:
stage: dev

terraform:
vpc:
command: "/usr/bin/terraform-0.13"
terraform_backend_assume_role: true
vars:
cidr_block: "10.100.0.0/18"
# ...

eks:
command: "/usr/bin/terraform-0.13"
terraform_backend_assume_role: true
vars:
cluster_kubernetes_version: "1.17"
# ...

helmfile:
ingress-nginx:
nginx-ingress:
vars:
installed: true

Expand All @@ -26,4 +33,4 @@ workflows:
steps:
- job: terraform deploy vpc
- job: terraform deploy eks
- job: helmfile deploy ingress-nginx
- job: helmfile deploy nginx-ingress
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace: eg
region: us-east-2

environment: ue2

account_id: ""
10 changes: 8 additions & 2 deletions example/config/ue2-prod.yaml → example/stacks/ue2-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
projects:
import:
- globals
- ue2-globals

components:
globals:
stage: prod

terraform:
vpc:
terraform_backend_assume_role: true
vars:
cidr_block: "10.102.0.0/18"
# ...

eks:
terraform_backend_assume_role: true
command: "/usr/bin/terraform-0.13"
vars:
cluster_kubernetes_version: "1.17"
# ...

helmfile:
ingress-nginx:
nginx-ingress:
vars:
installed: true
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
projects:
import:
- globals
- ue2-globals

components:
globals:
stage: staging

terraform:
vpc:
terraform_backend_assume_role: true
vars:
cidr_block: "10.104.0.0/18"
# ...

eks:
command: "/usr/bin/terraform-0.13"
terraform_backend_assume_role: true
vars:
cluster_kubernetes_version: "1.17"
# ...

helmfile:
ingress-nginx:
nginx-ingress:
vars:
installed: true
29 changes: 29 additions & 0 deletions example/stacks/workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
workflows:
deploy-all:
description: Deploy terraform project and helmfiles for a stack (provided as a command-line argument)
steps:
- job: terraform deploy vpc
- job: terraform deploy eks
- job: helmfile deploy nginx-ingress

plan-all:
description: Run 'terraform plan' and 'helmfile diff' on all components
steps:
- job: terraform plan vpc
stack: ue2-dev
- job: terraform plan eks
stack: ue2-dev
- job: helmfile diff nginx-ingress
stack: ue2-dev
- job: terraform plan vpc
stack: ue2-staging
- job: terraform plan eks
stack: ue2-staging
- job: helmfile diff nginx-ingress
stack: ue2-staging
- job: terraform plan vpc
stack: ue2-prod
- job: terraform plan eks
stack: ue2-prod
- job: helmfile diff nginx-ingress
stack: ue2-prod
Loading

0 comments on commit 835c568

Please sign in to comment.