You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/platform/onboard-terraform-provider.md
+56-37Lines changed: 56 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Onboard with Terraform Provider
5
5
6
6
# Onboard with Terraform Provider
7
7
8
-
The [Harness Terraform Provider](https://registry.terraform.io/providers/harness/harness/) enables automated lifecycle management of the Harness Platform using Terraform. Currently the following Harness entities can be managed via the provider.
8
+
The [Harness Terraform Provider](https://registry.terraform.io/providers/harness/harness/) enables automated lifecycle management of the Harness Platform using Terraform. You can onboard onto Harness on day 1 and also make day 2 changes using tthis Provider. Currently the following Harness resources can be managed via the Provider.
9
9
10
10
- Organizations
11
11
- Projects
@@ -17,7 +17,7 @@ The [Harness Terraform Provider](https://registry.terraform.io/providers/harness
17
17
- Permissions
18
18
- Secrets
19
19
20
-
This tutorial shows you how to manage all the above entities except Permissions and Secrets.
20
+
This tutorial shows you how to manage all the above resources except Permissions and Secrets.
21
21
22
22
## Prerequisite
23
23
@@ -30,7 +30,7 @@ terraform -version
30
30
31
31
### Get Your Harness Account ID
32
32
33
-
You will also need to provde your Harness accountId as an input parameter to the terraform provider. This accountId is present in every Harness URL. For example, in the following URL
33
+
You will also need to provde your Harness accountId as an input parameter to the Provider. This accountId is present in every Harness URL. For example, in the following URL
Open the `main.tf` file in a text editor and replace `PUT_YOUR_HARNESS_ACCOUNTID_HERE` and `PUT_YOUR_API_KEY_TOKEN_HERE` with your Harness accountId and PAT values respectively.
55
+
Open the `main.tf` file in a text editor and replace `PUT_YOUR_HARNESS_ACCOUNTID_HERE` and `PUT_YOUR_API_KEY_TOKEN_HERE` with your Harness accountId and API key token values respectively.
56
56
57
57
```
58
58
terraform {
@@ -76,7 +76,7 @@ provider "harness" {
76
76
77
77
Review the`main.tf` file for the operations that terraform is going to execute for us. As you can see, the sample first creates a new organization as well as a new project inside that organization. It then creates a helm chart service that will be deployed to Kubernetes infrastructure running in a pre-production environment. A new pipeline is then created to make this service deployment happen.
78
78
79
-
At every step, you can use existing organizations, projects, services, environments if you so desire. We will now review the terraform resource definition for each of these entities.
79
+
At every step, you can use existing organizations, projects, services, environments if you so desire. We will now review the terraform resource definition for each of these resources.
This service will use the above Helm connector to deploy a Helm Chart.
117
118
```
118
119
resource "harness_platform_service" "service" {
119
-
identifier = "identifier"
120
-
name = "name"
121
-
description = "test"
122
-
org_id = "org_id"
123
-
project_id = "project_id"
120
+
name = "ServiceByTF"
121
+
identifier = "servicebytf"
122
+
description = "Created through Terraform"
123
+
org_id = "orgbytf"
124
+
project_id = "projbytf"
124
125
yaml = <<-EOT
125
-
...
126
+
...
126
127
EOT
128
+
129
+
depends_on = [
130
+
harness_platform_project.project
131
+
]
127
132
}
128
133
```
129
134
130
-
#### Create a kubernetes connector at account level
135
+
#### Create a Kubernetes connector at account level
131
136
132
-
We will deploy the service defined earlier to the Kubernetes cluster associated with this connector.
137
+
We will deploy the service defined earlier to the Kubernetes cluster associated with this connector. This connector will inherit the permissions of a delegate named `firstk8sdel` which you can install using the Kubernetes delegate instructions from [Install Delegate](/tutorials/platform/install-delegate)
Create an environment inside the project that refers to the Kubernetes connector we defined in the previous step. Environments can be of `PreProduction` or `Production` types and we will use the former for this example.
On Harness UI, you can go to Account Settings --> Organizations to see the new organization. Click View Projects to see the new project. Click the project and go into the "Continuous Delivery" module. When you click Pipelines now, you can see the new pipeline has been created. You can run this pipeline as long as you have previously installed a delegate with name `firstk8sdel` using the Kubernetes delegate instructions from the [Install Delegate](/tutorials/platform/install-delegate).
255
+
On Harness UI, you can go to Account Settings --> Organizations to see the new organization. Click View Projects to see the new project. Click the project and go into the "Continuous Delivery" module. When you click Pipelines now, you can see the new pipeline has been created. You can run this pipeline as long as you have previously installed a delegate with name `firstk8sdel` using the Kubernetes delegate instructions from [Install Delegate](/tutorials/platform/install-delegate). As previously shown, you can change the delegate name to any other delegate you may have installed by editing the Kubernetes connector resource of the main.tf file.
0 commit comments