|
1 |
| -# Setup |
| 1 | +# Terraform provider for Codefresh |
2 | 2 |
|
3 |
| -Get an API key from [Codefresh](https://g.codefresh.io/user/settings) and set the following scopes: |
4 |
| -* Environments-V2 |
5 |
| -* Pipeline |
6 |
| -* Project |
7 |
| -* Repos |
8 |
| -* Step-Type |
9 |
| -* Step-Types |
10 |
| -* View |
11 |
| - |
12 |
| -Add the key to your `.zshrc` file: |
| 3 | +This provider was initialized by [LightStep](https://lightstep.com/) and will be maintained as the official Terraform provider for Codefresh. |
13 | 4 |
|
14 |
| -```bash |
15 |
| -export CODEFRESH_API_KEY='xyz' |
16 |
| -``` |
17 |
| - |
18 |
| -# Building |
19 |
| - |
20 |
| -```bash |
21 |
| -make build |
22 |
| -``` |
| 5 | +The provider is still under development, and can be used as a terraform [third-party plugin](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins) only. |
23 | 6 |
|
24 |
| -# Testing |
| 7 | +## Requirements |
25 | 8 |
|
26 |
| -Create a `main.tf` file in the root directory. Add or import resources there. |
| 9 | +- [Terraform](https://www.terraform.io/downloads.html) 0.11+ ; |
| 10 | +- [Go](https://golang.org/doc/install) 1.12+ (to build the provider plugin). |
27 | 11 |
|
28 |
| -## Example |
| 12 | +## Build |
29 | 13 |
|
30 |
| -```yaml |
31 |
| -resource "codefresh_project" "test" { |
32 |
| - name = "test" |
33 |
| -} |
| 14 | +```sh |
| 15 | +go build |
34 | 16 | ```
|
35 | 17 |
|
36 |
| -Run `terraform plan` or `terraform apply` as usual. Note this will modify the actual Codefresh configuration. |
| 18 | +## Usage |
37 | 19 |
|
38 |
| -# Syntax Examples |
| 20 | +Compile or take from the [Releases](https://github.com/codefresh-contrib/terraform-provider-codefresh/releases) `terraform-provider-codefresh` binary and place it locally according the Terraform plugins [documentation](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins). |
39 | 21 |
|
40 |
| -## Project |
| 22 | +For Linux OS it can be: |
41 | 23 |
|
42 |
| -```yaml |
43 |
| -resource "codefresh_project" "docker" { |
44 |
| - name = "docker" |
45 |
| -} |
46 |
| -``` |
| 24 | +- _~/.terraform.d/plugins/linux\_amd64_ |
| 25 | +- _./terraform.d/plugins/linux\_amd64_. The relative path in your Terraform project. |
47 | 26 |
|
48 |
| -## Pipeline |
49 |
| - |
50 |
| -```yaml |
51 |
| -resource "codefresh_pipeline" "docker_monorepo" { |
52 |
| - name = "docker/docker-monorepo" |
53 |
| - project = "docker" |
54 |
| - |
55 |
| - spec = { |
56 |
| - repo = "abcinc/monorepo" |
57 |
| - path = "./codefresh/docker/docker-monorepo.yaml" |
58 |
| - revision = "master" |
59 |
| - concurrency = 1 |
60 |
| - priority = 5 |
61 |
| - } |
62 |
| - |
63 |
| - tags = [ |
64 |
| - "docker", |
65 |
| - ] |
66 |
| - |
67 |
| - variables { |
68 |
| - TAG = "master" |
69 |
| - } |
70 |
| -} |
71 |
| -``` |
| 27 | +## Configuration |
72 | 28 |
|
73 |
| -## Cron Trigger |
| 29 | +There are two environment variables to configure Codefresh provider: |
74 | 30 |
|
75 |
| -```yaml |
76 |
| -resource "codefresh_cron_event" "docker_monorepo_cron" { |
77 |
| - expression = "40 0 * * *" |
78 |
| - message = "build monorepo docker" |
79 |
| -} |
| 31 | +- `CODEFRESH_API_URL`. Default value - https://g.codefresh.io/api ; |
| 32 | +- `CODEFRESH_API_KEY`. |
80 | 33 |
|
81 |
| -resource "codefresh_cron_trigger" "docker_monorepo_cron" { |
82 |
| - pipeline = "${codefresh_pipeline.docker_monorepo.id}" |
83 |
| - event = "${codefresh_cron_event.docker_monorepo_cron.id}" |
84 |
| -} |
85 |
| -``` |
| 34 | +Get an API key from [Codefresh](https://g.codefresh.io/user/settings) and set the following scopes: |
86 | 35 |
|
87 |
| -## Environment |
| 36 | +- Environments-V2 |
| 37 | +- Pipeline |
| 38 | +- Project |
| 39 | +- Repos |
| 40 | +- Step-Type |
| 41 | +- Step-Types |
| 42 | +- View |
88 | 43 |
|
89 |
| -```yaml |
90 |
| -resource "codefresh_environment" "staging" { |
91 |
| - account_id = "<redacted>" |
92 |
| - name = "staging" |
93 |
| - namespace = "staging" |
94 |
| - cluster = "abcinc-staging" |
95 |
| -} |
| 44 | +```bash |
| 45 | +export CODEFRESH_API_KEY='xyz' |
96 | 46 | ```
|
97 | 47 |
|
98 |
| -## User |
99 |
| -```yaml |
100 |
| -resource "codefresh_user" "john_doe" { |
101 |
| - |
102 |
| -} |
103 |
| -``` |
| 48 | +## Examples |
| 49 | + |
| 50 | +See the [examples](examples/). |
0 commit comments