Skip to content

Commit ee58331

Browse files
committed
Add api-key doc
1 parent 4b95aa1 commit ee58331

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

docs/resources/api-key.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# API Key resource
2+
3+
By default **terraform-provider-codefresh** uses API key, passed as provider's attribute, but it's possible to generate a new one.
4+
Codefresh API allows to operate only with entities in the current account, which owns the provided API Key.
5+
To be able to operate with entities in different accounts - you should create a new key in the relevant account and use providers [alias](https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-instances).
6+
7+
## Example usage
8+
9+
```hcl
10+
provider "codefresh" {
11+
api_url = "my API URL"
12+
token = "my init API token"
13+
}
14+
15+
resource "codefresh_account" "test" {
16+
name = "my new account"
17+
}
18+
19+
resource "random_string" "random" {
20+
length = 16
21+
special = false
22+
}
23+
24+
resource "codefresh_api_key" "new" {
25+
account_id = codefresh_account.test.id
26+
27+
name = "tfkey_${random_string.random.result}"
28+
29+
scopes = [
30+
"agent",
31+
"agents",
32+
"audit",
33+
"build",
34+
"cluster",
35+
"clusters",
36+
"environments-v2",
37+
"github-action",
38+
"helm",
39+
"kubernetes",
40+
"pipeline",
41+
"project",
42+
"repos",
43+
"runner-installation",
44+
"step-type",
45+
"step-types",
46+
"view",
47+
"workflow",
48+
]
49+
}
50+
51+
provider "codefresh" {
52+
alias = "new_account"
53+
api_url = "my API URL"
54+
token = codefresh_api_key.new.token
55+
}
56+
57+
58+
resource "codefresh_team" "team_1" {
59+
60+
provider = codefresh.new_account
61+
62+
name = "team name"
63+
}
64+
```
65+
66+
## Argument Reference
67+
68+
- `name` - (Required) The display name for the API key.
69+
- `account_id` - (Required) The ID of account than should own the new API key.
70+
- `scopes` - (Optional) A list of access scopes, that can be targeted. The possible values:
71+
- `agent`
72+
- `agents`
73+
- `audit`
74+
- `build`
75+
- `cluster`
76+
- `clusters`
77+
- `environments-v2`
78+
- `github-action`
79+
- `helm`
80+
- `kubernetes`
81+
- `pipeline`
82+
- `project`
83+
- `repos`
84+
- `runner-installation`
85+
- `step-type`
86+
- `step-types`
87+
- `view`
88+
- `workflow`
89+
90+
## Attributes Reference
91+
92+
- `id` - The Key ID.
93+
- `token` - The Token, that should used as a new provider's token attribute.
94+

0 commit comments

Comments
 (0)