|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "gitlab_cluster_agent Resource - terraform-provider-gitlab" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + The gitlab_cluster_agent resource allows to manage the lifecycle of a GitLab Agent for Kubernetes. |
| 7 | + -> Note that this resource only registers the agent, but doesn't configure it. |
| 8 | + The configuration needs to be manually added as described in |
| 9 | + the docs https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file. |
| 10 | + However, a gitlab_repository_file resource may be used to achieve that. |
| 11 | + -> Requires at least maintainer permissions on the project. |
| 12 | + -> Requires at least GitLab 14.10 |
| 13 | + Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/cluster_agents.html |
| 14 | +--- |
| 15 | + |
| 16 | +# gitlab_cluster_agent (Resource) |
| 17 | + |
| 18 | +The `gitlab_cluster_agent` resource allows to manage the lifecycle of a GitLab Agent for Kubernetes. |
| 19 | + |
| 20 | +-> Note that this resource only registers the agent, but doesn't configure it. |
| 21 | + The configuration needs to be manually added as described in |
| 22 | + [the docs](https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file). |
| 23 | + However, a `gitlab_repository_file` resource may be used to achieve that. |
| 24 | + |
| 25 | +-> Requires at least maintainer permissions on the project. |
| 26 | + |
| 27 | +-> Requires at least GitLab 14.10 |
| 28 | + |
| 29 | +**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/cluster_agents.html) |
| 30 | + |
| 31 | +## Example Usage |
| 32 | + |
| 33 | +```terraform |
| 34 | +resource "gitlab_cluster_agent" "example" { |
| 35 | + project = "12345" |
| 36 | + name = "agent-1" |
| 37 | +} |
| 38 | +
|
| 39 | +// Optionally, configure the agent as described in |
| 40 | +// https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file |
| 41 | +resource "gitlab_repository_file" "example_agent_config" { |
| 42 | + project = gitlab_cluster_agent.example.project |
| 43 | + branch = "main" // or use the `default_branch` attribute from a project data source / resource |
| 44 | + file_path = ".gitlab/agents/${gitlab_cluster_agent.example.name}" |
| 45 | + content = <<CONTENT |
| 46 | + gitops: |
| 47 | + ... |
| 48 | + CONTENT |
| 49 | + author_email = "[email protected]" |
| 50 | + author_name = "Terraform" |
| 51 | + commit_message = "feature: add agent config for ${gitlab_cluster_agent.example.name}" |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +<!-- schema generated by tfplugindocs --> |
| 56 | +## Schema |
| 57 | + |
| 58 | +### Required |
| 59 | + |
| 60 | +- `name` (String) The Name of the agent. |
| 61 | +- `project` (String) ID or full path of the project maintained by the authenticated user. |
| 62 | + |
| 63 | +### Read-Only |
| 64 | + |
| 65 | +- `agent_id` (Number) The ID of the agent. |
| 66 | +- `created_at` (String) The ISO8601 datetime when the agent was created. |
| 67 | +- `created_by_user_id` (Number) The ID of the user who created the agent. |
| 68 | +- `id` (String) The ID of this resource. |
| 69 | + |
| 70 | +## Import |
| 71 | + |
| 72 | +Import is supported using the following syntax: |
| 73 | + |
| 74 | +```shell |
| 75 | +# GitLab Agent for Kubernetes can be imported with the following command and the id pattern `<project>:<agent-id>` |
| 76 | +terraform import gitlab_cluster_agent.example '12345:42' |
| 77 | +``` |
0 commit comments