The gitlab_cluster_agent
resource allows to manage the lifecycle of a GitLab Agent for Kubernetes.
Upstream API: GitLab REST API docs
resource "gitlab_cluster_agent" "example" {
project = "12345"
name = "agent-1"
}
// Optionally, configure the agent as described in
// https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file
resource "gitlab_repository_file" "example_agent_config" {
project = gitlab_cluster_agent.example.project
branch = "main" // or use the `default_branch` attribute from a project data source / resource
file_path = ".gitlab/agents/${gitlab_cluster_agent.example.name}/config.yaml"
content = base64encode(<<CONTENT
# the GitLab Agent for Kubernetes configuration goes here ...
CONTENT
)
author_email = "terraform@example.com"
author_name = "Terraform"
commit_message = "feature: add agent config for ${gitlab_cluster_agent.example.name} [skip ci]"
}
# the GitLab Agent for Kubernetes configuration goes here ...
CONTENT
)
author_email = "terraform@example.com"
author_name = "Terraform"
commit_message = "feature: add agent config for ${gitlab_cluster_agent.example.name} [skip ci]"
}
name
(String) The Name of the agent.project
(String) ID or full path of the project maintained by the authenticated user.agent_id
(Number) The ID of the agent.created_at
(String) The ISO8601 datetime when the agent was created.created_by_user_id
(Number) The ID of the user who created the agent.id
(String) The ID of this resource.Import is supported using the following syntax:
# GitLab Agent for Kubernetes can be imported with the following command and the id pattern `<project>:<agent-id>`
terraform import gitlab_cluster_agent.example '12345:42'