diff --git a/.gitignore b/.gitignore index 33fd7b01..20db911e 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,4 @@ tfplan*.txt *.save #tmp folder to validate casc bundles -blueprints/02-at-scale/cbci/casc-pre-validate \ No newline at end of file +blueprints/02-at-scale/cbci/casc-pre-validate diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9918f5eb..013f97d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,13 +48,13 @@ To submit a pull request: 1. Fork the repository. 2. Create a feature branch based on the `develop` branch. 3. Modify the source and focus on the specific change you are contributing. For example, if you reformat all the code, it is hard for reviewers to focus on your specific change. -4. **Ensure that local tests pass**. Local tests can be orchestrated via the companion [Makefile](Makefile). +4. **Ensure that local tests pass**. Local tests can be orchestrated via the companion [Makefile](blueprints/Makefile). 5. Make commits to your fork using clear commit messages. 6. Submit a pull request against the `develop` branch and answer any default questions in the pull request interface. 7. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. > [!IMPORTANT] -> If you make updates to embedded repository (for example, CasC bundles), you must push the changes to the public upstream (repository/branch) before running `terraform apply` locally. The endpoint and/or branch can be updated via `set-casc-location` from the companion [Makefile](Makefile). +> If you make updates to embedded repository (for example, CasC bundles), you must push the changes to the public upstream (repository/branch) before running `terraform apply` locally. The endpoint and/or branch can be updated via `set-casc-location` from the companion [Makefile](blueprints/Makefile). ### Pre-commits: Linting, formatting and secrets scanning @@ -68,7 +68,7 @@ Many of the files in the repository can be linted or formatted to maintain a sta Validate your pull request changes inside the blueprint agent described in the [Dockerfile](.docker/agent). It is the same agent used for the CI pipeline [bp-agent-ecr.yaml](.cloudbees/workflows/bp-agent-ecr.yaml). > [!NOTE] -> The agent and dependencies can be automated using the [Makefile](Makefile) at the root of the project, under the target `bpAgent-dRun`. It is the same Makefile used in the CloudBees CI pipeline. +> The agent and dependencies can be automated using the [Makefile](blueprints/Makefile) at the root of the project, under the target `bpAgent-dRun`. It is the same Makefile used in the CloudBees CI pipeline. The [bp-tf-ci.yaml](.cloudbees/workflows/bp-tf-ci.yaml) blueprints are orchestrated into the [CloudBees platform](https://www.cloudbees.com/products/saas-platform) inside the [CloudBees Professional Services (PS) sub-organization](https://cloudbees.io/orgs/cloudbees~professional-services/components/94c50dcf-125e-4767-b9c5-58d6d669a1f6/runs). @@ -89,7 +89,7 @@ The [bp-tf-ci.yaml](.cloudbees/workflows/bp-tf-ci.yaml) blueprints are orchestra CloudBees CI Terraform EKS Addon versions try to be in sync with the [CloudBees CI releases](https://docs.cloudbees.com/docs/release-notes/latest/cloudbees-ci/). 1. Ensure that `develop` branch follows its requisites from the [Design principles](#design-principles) section. -2. Test locally the (`develop`) for all the blueprints. Use the `test-all` target in the companion [Makefile](Makefile). +2. Test locally the (`develop`) for all the blueprints. Use the `test-all` target in the companion [Makefile](blueprints/Makefile). 3. Once all local tests passed successfully, create a PR against the `main` branch. It **must pass** the Center of Excellence (CoE) team validation. 4. Once the pull request is merged, update the `main` branch following its requisites from the [Design principles](#design-principles) section. The [Blueprint Terraform CI pipeline](#blueprint-terraform-ci-pipeline) must validate the changes. 5. Create a [new release](https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/releases). The release version semantics follow the Helm chart convention. diff --git a/README.md b/README.md index a58f3aa8..91167d7a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/blueprints/01-getting-started/README.md b/blueprints/01-getting-started/README.md index dbee24e3..4c85a382 100644 --- a/blueprints/01-getting-started/README.md +++ b/blueprints/01-getting-started/README.md @@ -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 @@ -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). diff --git a/blueprints/02-at-scale/README.md b/blueprints/02-at-scale/README.md index 0828c8ba..bb46898c 100644 --- a/blueprints/02-at-scale/README.md +++ b/blueprints/02-at-scale/README.md @@ -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 @@ -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). diff --git a/blueprints/02-at-scale/cbci/casc/oc/items.admin-folder.yaml b/blueprints/02-at-scale/cbci/casc/oc/items.admin-folder.yaml index 2a146ce8..1a4e62fc 100644 --- a/blueprints/02-at-scale/cbci/casc/oc/items.admin-folder.yaml +++ b/blueprints/02-at-scale/cbci/casc/oc/items.admin-folder.yaml @@ -144,6 +144,3 @@ items: trim: true name: TARGET_BRANCH description: Branch to validate casc bundles before merging to production branch - - - diff --git a/Makefile b/blueprints/Makefile similarity index 88% rename from Makefile rename to blueprints/Makefile index 7c938c2b..01a6fe51 100644 --- a/Makefile +++ b/blueprints/Makefile @@ -9,7 +9,7 @@ CBCI_BRANCH ?= main DESTROY_WL_ONLY ?= false define helpers - source blueprints/helpers.sh && $(1) + source helpers.sh && $(1) endef ########################## @@ -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)") @@ -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.") @@ -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)") diff --git a/blueprints/helpers.sh b/blueprints/helpers.sh index 45345e08..202c6041 100755 --- a/blueprints/helpers.sh +++ b/blueprints/helpers.sh @@ -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" }