Skip to content

Commit

Permalink
Moving makefile inside the blueprints folder
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosrodlop committed Oct 29, 2024
1 parent 0752e2d commit 9a7052e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ By default, it uses a minimum required configuration described in the Helm chart
The blueprint `deploy` and `destroy` phases use the same requirements provided in the [AWS EKS Blueprints for Terraform - Prerequisites](https://aws-ia.github.io/terraform-aws-eks-blueprints/getting-started/#prerequisites). However, the blueprint `validate` phase may require additional tooling, such as `jq` and `velero`.

> [!NOTE]
> There is a companion [Dockerfile](https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/tree/main/.docker) to run the blueprints in a containerized development environment, ensuring all dependencies are met. It can be built locally using the [Makefile](https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/blob/main/Makefile) target `make bpAgent-dRun`.
> There is a companion [Dockerfile](https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/tree/main/.docker) to run the blueprints in a containerized development environment, ensuring all dependencies are met. It can be built locally using the [Makefile](https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/blob/main/blueprints/Makefile) target `make bpAgent-dRun`.
### AWS authentication

Expand Down
4 changes: 2 additions & 2 deletions blueprints/01-getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ When preparing to deploy, you must complete the following steps:
For more information, refer to [The Core Terraform Workflow](https://www.terraform.io/intro/core-workflow) documentation.

> [!TIP]
> The `deploy` phase can be orchestrated via the companion [Makefile](../../Makefile).
> The `deploy` phase can be orchestrated via the companion [Makefile](../Makefile).
## Validate

Expand Down Expand Up @@ -135,4 +135,4 @@ Once you can access the Kubernetes API from your terminal, complete the followin
To tear down and remove the resources created in the blueprint, complete the steps for [Amazon EKS Blueprints for Terraform - Destroy](https://aws-ia.github.io/terraform-aws-eks-blueprints/getting-started/#destroy).

> [!TIP]
> The `destroy` phase can be orchestrated via the companion [Makefile](../../Makefile).
> The `destroy` phase can be orchestrated via the companion [Makefile](../Makefile).
4 changes: 2 additions & 2 deletions blueprints/02-at-scale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ When preparing to deploy, you must complete the following steps:
For more information, refer to [The Core Terraform Workflow](https://www.terraform.io/intro/core-workflow) documentation.

> [!TIP]
> The `deploy` phase can be orchestrated via the companion [Makefile](../../Makefile).
> The `deploy` phase can be orchestrated via the companion [Makefile](../Makefile).
## Validate

Expand Down Expand Up @@ -456,4 +456,4 @@ To tear down and remove the resources created in the blueprint, refer to [Amazon

> [!TIP]
> - To avoid [#165](https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/issues/165), run `kube-prometheus-destroy.sh` after destroying the EKS cluster.
> - The `destroy` phase can be orchestrated via the companion [Makefile](../../Makefile).
> - The `destroy` phase can be orchestrated via the companion [Makefile](../Makefile).
14 changes: 7 additions & 7 deletions Makefile → blueprints/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CBCI_BRANCH ?= main
DESTROY_WL_ONLY ?= false

define helpers
source blueprints/helpers.sh && $(1)
source helpers.sh && $(1)
endef

##########################
Expand All @@ -19,8 +19,8 @@ endef
.PHONY: tfChecks
tfChecks: ## Run required terraform checks according to getting-started/README.md . Example: ROOT=02-at-scale make tfChecks
tfChecks: guard-ROOT
@if [ ! -f blueprints/$(ROOT)/.auto.tfvars ]; then $(call helpers,ERROR "blueprints/$(ROOT)/.auto.tfvars file does not exist and it is required to store your own values"); fi
@if ([ ! -f blueprints/$(ROOT)/k8s/secrets-values.yml ] && [ $(ROOT) == "02-at-scale" ]); then $(call helpers,ERROR "blueprints/$(ROOT)/secrets-values.yml file does not exist and it is required to store your secrets"); fi
@if [ ! -f $(ROOT)/.auto.tfvars ]; then $(call helpers,ERROR "$(ROOT)/.auto.tfvars file does not exist and it is required to store your own values"); fi
@if ([ ! -f $(ROOT)/k8s/secrets-values.yml ] && [ $(ROOT) == "02-at-scale" ]); then $(call helpers,ERROR "$(ROOT)/secrets-values.yml file does not exist and it is required to store your secrets"); fi
$(eval USER_ID := $(shell aws sts get-caller-identity | grep UserId | cut -d"," -f 1 | xargs ))
@if [ "$(USER_ID)" == "" ]; then $(call helpers,ERROR "AWS Authention for CLI is not configured"); fi
@$(call helpers,INFO "Terraform Preflight Checks OK for $(USER_ID)")
Expand All @@ -36,10 +36,10 @@ bpAgent-dRun: ## Build (if not locally present) and Run the Blueprint Agent usin
.PHONY: deploy
deploy: ## Deploy Terraform Blueprint passed as parameter. Example: ROOT=02-at-scale make deploy
deploy: tfChecks agentCheck
terraform -chdir=$(MKFILEDIR)/blueprints/$(ROOT) init
terraform -chdir=$(MKFILEDIR)/blueprints/$(ROOT) plan -no-color > $(MKFILEDIR)/blueprints/$(ROOT)/tfplan.txt
terraform -chdir=$(MKFILEDIR)/$(ROOT) init
terraform -chdir=$(MKFILEDIR)/$(ROOT) plan -no-color > $(MKFILEDIR)/$(ROOT)/tfplan.txt
ifeq ($(CI),false)
@$(call helpers,ask-confirmation "Deploy $(ROOT). Check plan at blueprints/$(ROOT)/tfplan.txt")
@$(call helpers,ask-confirmation "Deploy $(ROOT). Check plan at $(ROOT)/tfplan.txt")
endif
@$(call helpers,tf-apply $(ROOT))
@$(call helpers,INFO "CloudBees CI Blueprint $(ROOT) Deploy target finished succesfully.")
Expand All @@ -48,7 +48,7 @@ endif
validate: ## Validate CloudBees CI Blueprint deployment passed as parameter. Example: ROOT=02-at-scale make validate
validate: tfChecks agentCheck
ifeq ($(CI),false)
ifeq ($(wildcard $(MKFILEDIR)/blueprints/$(ROOT)/terraform.output),)
ifeq ($(wildcard $(MKFILEDIR)/$(ROOT)/terraform.output),)
@$(call helpers,WARN "Blueprint $(ROOT) did not complete the Deployment target thus it is not Ready to be validated.")
endif
@$(call helpers,ask-confirmation "Validate $(ROOT)")
Expand Down
1 change: 1 addition & 0 deletions blueprints/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ bpAgent-dRun (){
fi
docker run --rm -it --name "$bpAgentUser" \
-v "$SCRIPTDIR/..":"/$bpAgentUser/cbci-eks-addon" -v "$HOME/.aws":"/$bpAgentUser/.aws" \
--workdir="/$bpAgentUser/cbci-eks-addon/blueprints" \
"$bpAgentLocalImage"
}

Expand Down

0 comments on commit 9a7052e

Please sign in to comment.