Skip to content

Commit 16485e9

Browse files
committed
change_account module
1 parent c6bc1cc commit 16485e9

File tree

8 files changed

+196
-2
lines changed

8 files changed

+196
-2
lines changed

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ The provider is still under development, and can be used as a terraform [third-p
66

77
## Requirements
88

9-
- [Terraform](https://www.terraform.io/downloads.html) 0.11+ ;
9+
- [Terraform](https://www.terraform.io/downloads.html) 0.12+ ;
1010
- [Go](https://golang.org/doc/install) 1.12+ (to build the provider plugin).
1111

12+
## Download Provider
13+
Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases)
14+
1215
## Building the Provider
1316

1417
```sh
@@ -24,7 +27,11 @@ For Linux OS it can be:
2427
- _~/.terraform.d/plugins/linux\_amd64_
2528
- _./terraform.d/plugins/linux\_amd64_. The relative path in your Terraform project.
2629

27-
To configure codefresh provider:
30+
## [Documentations](./docs)
31+
32+
## [Examples](./examples)
33+
34+
## To configure codefresh provider:
2835

2936
```hcl
3037
provider "codefresh" {

docs/data/account.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# account data module
2+
3+
```
4+
data "codefresh_account" "acc" {
5+
name = "acc1"
6+
}
7+
8+
resource "codefresh_user" "user1" {
9+
10+
user_name = "user1"
11+
12+
accounts = [
13+
data.codefresh_account.acc.id
14+
]
15+
16+
activate = true
17+
18+
roles = [
19+
"Admin",
20+
"User"
21+
]
22+
23+
login {
24+
idp_id = data.codefresh_idps.idp_azure.id
25+
sso = true
26+
}
27+
28+
login {
29+
idp_id = data.codefresh_idps.local.id
30+
//sso = false
31+
}
32+
33+
34+
personal {
35+
first_name = "John"
36+
last_name = "Smith"
37+
}
38+
}
39+
```

docs/data/idps.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# data codefresh_idps
2+
```
3+
data "codefresh_idps" "idp_azure" {
4+
display_name = "codefresh-onprem-tst-2"
5+
# client_name = "2222"
6+
# _id = "5df234543"
7+
client_type = "azure"
8+
}
9+
10+
data "codefresh_idps" "local" {
11+
display_name = "local"
12+
}
13+
14+
resource "codefresh_account" "acc" {
15+
name = "acc1"
16+
17+
features = var.accountFeatures
18+
19+
limits {
20+
collaborators = 25
21+
data_retention_weeks = 5
22+
}
23+
24+
build {
25+
parallel = 25
26+
nodes = 7
27+
}
28+
29+
}
30+
31+
resource "codefresh_user" "user1" {
32+
33+
user_name = "user1"
34+
35+
activate = true
36+
37+
roles = [
38+
"Admin",
39+
"User"
40+
]
41+
42+
login {
43+
idp_id = data.codefresh_idps.idp_azure.id
44+
sso = true
45+
}
46+
47+
login {
48+
idp_id = data.codefresh_idps.local.id
49+
//sso = false
50+
}
51+
52+
personal {
53+
first_name = "John"
54+
last_name = "Smith"
55+
}
56+
57+
accounts = [
58+
codefresh_account.acc.id
59+
]
60+
}
61+
62+
resource "codefresh_idp_accounts" "acc_idp" {
63+
idp_id = data.codefresh_idps.idp_azure.id
64+
account_ids = [codefresh_account.acc.id]
65+
}
66+
```

docs/data/team.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# data codefresh_team
2+
3+
*Note*: Teams resources should be called with account specific access token
4+
5+
```
6+
data "codefresh_team" "admin" {
7+
provider = codefresh.acc1
8+
name = "users"
9+
}
10+
11+
resource "codefresh_permission" "permission2" {
12+
provider = codefresh.acc1
13+
team = data.codefresh_team.admin.id
14+
action = "create"
15+
resource = "pipeline"
16+
tags = ["frontend"]
17+
}
18+
19+
```
20+

docs/resources/permissions.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# resource codefresh_permission
2+
3+
```
4+
5+
6+
```

tf_modules/change_account/main.tf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
data "codefresh_account" "acc" {
2+
name = var.account_id
3+
}
4+
5+
resource "random_string" "random" {
6+
length = 16
7+
special = false
8+
}
9+
10+
resource "codefresh_api_key" "new" {
11+
account_id = data.codefresh_account.acc.id
12+
user_id = data.codefresh_account.acc.admins[0]
13+
name = "tfkey_${random_string.random.result}"
14+
15+
scopes = [
16+
"agent",
17+
"agents",
18+
"audit",
19+
"build",
20+
"cluster",
21+
"clusters",
22+
"environments-v2",
23+
"github-action",
24+
"helm",
25+
"kubernetes",
26+
"pipeline",
27+
"project",
28+
"repos",
29+
"runner-installation",
30+
"step-type",
31+
"step-types",
32+
"view",
33+
"workflow",
34+
]
35+
}
36+
37+
output "token" {
38+
value = codefresh_api_key.new.token
39+
}

tf_modules/change_account/provider.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "codefresh" {
2+
api_url = var.api_url
3+
token = var.token
4+
}

tf_modules/change_account/vars.tf

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
variable api_url {
2+
type = string
3+
}
4+
5+
#
6+
variable token {
7+
type = string
8+
default = ""
9+
}
10+
11+
variable account_id {
12+
type = string
13+
}

0 commit comments

Comments
 (0)