[Infrastructure as Code (IaC) Terraform] Terraform Harbor Examples about using Terraform Harbor Provider to manage projects and users
Terraform Harbor Examples
Harbor is an open source registry that secures artifacts with policies and role-based access control, ensures images are scanned and free from vulnerabilities, and signs images as trusted. Harbor, a CNCF Graduated project, delivers compliance, performance, and interoperability to help you consistently and securely manage artifacts across cloud native compute platforms like Kubernetes and Docker.
Examples about using Terraform Harbor Provider to manage Harbor projects and users.
Prerequsites
-
Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service
1
2macOS
brew install terraformSee Download Terraform - Terraform by HashiCorp - https://www.terraform.io/downloads.html to learn more about others OS.
-
The Harbor provider is used to configure an instance of Harbor. The provider needs to be configured with the proper credentials before it can be used.
Configuration
Terraform Variables
First, Specify values for Harbor Provider variables within terraform.tfvars.
Remember to replace <> with your prefered value.
1 | harbor_url = "<Your Harbor URL>" |
Harbor Provider
Create or edit harbor.tf
file.
1 | # harbor.tf |
Harbor Project
Create or edit harbor_project.tf
file.
1 | # harbor_project.tf |
Harbor User
Create or edit harbor_user.tf
file.
Remember to replace <> with your prefered value.
1 | # harbor_user.tf |
Harbor Project Member User
Create or edit harbor_project_member_user.tf
file.
1 | # harbor_project_member_user.tf |
Run
Terraform Init
1 | terraform init |
It will download the Terraform Harbor Provider binary.
Terraform apply
1 | terraform apply |
It will dispaly the execute plan and wait for your make yes
or no
.
Then you will see the Harbor project and user on Harbor Web UI.
Terraform destroy
1 | terraform destroy |
It will destroy all above Harbor resources managed by Terraform.
Reference
[3] Terraform Registry - https://registry.terraform.io/