Skip to content

Commit

Permalink
change_account module
Browse files Browse the repository at this point in the history
  • Loading branch information
kosta709 committed Jul 27, 2020
1 parent c6bc1cc commit 16485e9
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ The provider is still under development, and can be used as a terraform [third-p

## Requirements

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

## Download Provider
Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases)

## Building the Provider

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

To configure codefresh provider:
## [Documentations](./docs)

## [Examples](./examples)

## To configure codefresh provider:

```hcl
provider "codefresh" {
Expand Down
39 changes: 39 additions & 0 deletions docs/data/account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# account data module

```
data "codefresh_account" "acc" {
name = "acc1"
}
resource "codefresh_user" "user1" {
email = "[email protected]"
user_name = "user1"
accounts = [
data.codefresh_account.acc.id
]
activate = true
roles = [
"Admin",
"User"
]
login {
idp_id = data.codefresh_idps.idp_azure.id
sso = true
}
login {
idp_id = data.codefresh_idps.local.id
//sso = false
}
personal {
first_name = "John"
last_name = "Smith"
}
}
```
66 changes: 66 additions & 0 deletions docs/data/idps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# data codefresh_idps
```
data "codefresh_idps" "idp_azure" {
display_name = "codefresh-onprem-tst-2"
# client_name = "2222"
# _id = "5df234543"
client_type = "azure"
}
data "codefresh_idps" "local" {
display_name = "local"
}
resource "codefresh_account" "acc" {
name = "acc1"
features = var.accountFeatures
limits {
collaborators = 25
data_retention_weeks = 5
}
build {
parallel = 25
nodes = 7
}
}
resource "codefresh_user" "user1" {
email = "[email protected]"
user_name = "user1"
activate = true
roles = [
"Admin",
"User"
]
login {
idp_id = data.codefresh_idps.idp_azure.id
sso = true
}
login {
idp_id = data.codefresh_idps.local.id
//sso = false
}
personal {
first_name = "John"
last_name = "Smith"
}
accounts = [
codefresh_account.acc.id
]
}
resource "codefresh_idp_accounts" "acc_idp" {
idp_id = data.codefresh_idps.idp_azure.id
account_ids = [codefresh_account.acc.id]
}
```
20 changes: 20 additions & 0 deletions docs/data/team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# data codefresh_team

*Note*: Teams resources should be called with account specific access token

```
data "codefresh_team" "admin" {
provider = codefresh.acc1
name = "users"
}
resource "codefresh_permission" "permission2" {
provider = codefresh.acc1
team = data.codefresh_team.admin.id
action = "create"
resource = "pipeline"
tags = ["frontend"]
}
```

6 changes: 6 additions & 0 deletions docs/resources/permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# resource codefresh_permission

```
```
39 changes: 39 additions & 0 deletions tf_modules/change_account/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
data "codefresh_account" "acc" {
name = var.account_id
}

resource "random_string" "random" {
length = 16
special = false
}

resource "codefresh_api_key" "new" {
account_id = data.codefresh_account.acc.id
user_id = data.codefresh_account.acc.admins[0]
name = "tfkey_${random_string.random.result}"

scopes = [
"agent",
"agents",
"audit",
"build",
"cluster",
"clusters",
"environments-v2",
"github-action",
"helm",
"kubernetes",
"pipeline",
"project",
"repos",
"runner-installation",
"step-type",
"step-types",
"view",
"workflow",
]
}

output "token" {
value = codefresh_api_key.new.token
}
4 changes: 4 additions & 0 deletions tf_modules/change_account/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
provider "codefresh" {
api_url = var.api_url
token = var.token
}
13 changes: 13 additions & 0 deletions tf_modules/change_account/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
variable api_url {
type = string
}

#
variable token {
type = string
default = ""
}

variable account_id {
type = string
}

0 comments on commit 16485e9

Please sign in to comment.