Skip to content

Commit

Permalink
Merge pull request #206 from cloudbees/makefile
Browse files Browse the repository at this point in the history
[Makefile] Moving it inside blueprints folder
  • Loading branch information
carlosrodlop authored Oct 29, 2024
2 parents 0752e2d + 15f7c3c commit 9e83978
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ tfplan*.txt
*.save

#tmp folder to validate casc bundles
blueprints/02-at-scale/cbci/casc-pre-validate
blueprints/02-at-scale/cbci/casc-pre-validate
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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).

Expand All @@ -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.
Expand Down
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).
3 changes: 0 additions & 3 deletions blueprints/02-at-scale/cbci/casc/oc/items.admin-folder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,3 @@ items:
trim: true
name: TARGET_BRANCH
description: Branch to validate casc bundles before merging to production branch



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 9e83978

Please sign in to comment.