gitlab.ClusterAgent
Explore with Pulumi AI
The gitlab.ClusterAgent
resource allows to manage the lifecycle of a GitLab Agent for Kubernetes.
Note that this resource only registers the agent, but doesn’t configure it. The configuration needs to be manually added as described in the docs. However, a
gitlab.RepositoryFile
resource may be used to achieve that.
Requires at least maintainer permissions on the project.
Requires at least GitLab 14.10
Upstream API: GitLab REST API docs
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
var example = new GitLab.ClusterAgent("example", new()
{
Project = "12345",
});
// Optionally, configure the agent as described in
// https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file
var exampleAgentConfig = new GitLab.RepositoryFile("exampleAgentConfig", new()
{
Project = example.Project,
Branch = "main",
FilePath = example.Name.Apply(name => $".gitlab/agents/{name}"),
Content = @" gitops:
...
",
AuthorEmail = "terraform@example.com",
AuthorName = "Terraform",
CommitMessage = example.Name.Apply(name => $"feature: add agent config for {name}"),
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-gitlab/sdk/v6/go/gitlab"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := gitlab.NewClusterAgent(ctx, "example", &gitlab.ClusterAgentArgs{
Project: pulumi.String("12345"),
})
if err != nil {
return err
}
_, err = gitlab.NewRepositoryFile(ctx, "exampleAgentConfig", &gitlab.RepositoryFileArgs{
Project: example.Project,
Branch: pulumi.String("main"),
FilePath: example.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf(".gitlab/agents/%v", name), nil
}).(pulumi.StringOutput),
Content: pulumi.String(" gitops:\n ...\n"),
AuthorEmail: pulumi.String("terraform@example.com"),
AuthorName: pulumi.String("Terraform"),
CommitMessage: example.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("feature: add agent config for %v", name), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.ClusterAgent;
import com.pulumi.gitlab.ClusterAgentArgs;
import com.pulumi.gitlab.RepositoryFile;
import com.pulumi.gitlab.RepositoryFileArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ClusterAgent("example", ClusterAgentArgs.builder()
.project("12345")
.build());
var exampleAgentConfig = new RepositoryFile("exampleAgentConfig", RepositoryFileArgs.builder()
.project(example.project())
.branch("main")
.filePath(example.name().applyValue(name -> String.format(".gitlab/agents/%s", name)))
.content("""
gitops:
...
""")
.authorEmail("terraform@example.com")
.authorName("Terraform")
.commitMessage(example.name().applyValue(name -> String.format("feature: add agent config for %s", name)))
.build());
}
}
import pulumi
import pulumi_gitlab as gitlab
example = gitlab.ClusterAgent("example", project="12345")
# Optionally, configure the agent as described in
# https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file
example_agent_config = gitlab.RepositoryFile("exampleAgentConfig",
project=example.project,
branch="main",
file_path=example.name.apply(lambda name: f".gitlab/agents/{name}"),
content=""" gitops:
...
""",
author_email="terraform@example.com",
author_name="Terraform",
commit_message=example.name.apply(lambda name: f"feature: add agent config for {name}"))
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const example = new gitlab.ClusterAgent("example", {project: "12345"});
// Optionally, configure the agent as described in
// https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file
const exampleAgentConfig = new gitlab.RepositoryFile("exampleAgentConfig", {
project: example.project,
branch: "main",
filePath: pulumi.interpolate`.gitlab/agents/${example.name}`,
content: ` gitops:
...
`,
authorEmail: "terraform@example.com",
authorName: "Terraform",
commitMessage: pulumi.interpolate`feature: add agent config for ${example.name}`,
});
resources:
example:
type: gitlab:ClusterAgent
properties:
project: '12345'
# Optionally, configure the agent as described in
# // https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#create-an-agent-configuration-file
exampleAgentConfig:
type: gitlab:RepositoryFile
properties:
project: ${example.project}
branch: main
# or use the `default_branch` attribute from a project data source / resource
filePath: .gitlab/agents/${example.name}
content: |2
gitops:
...
authorEmail: terraform@example.com
authorName: Terraform
commitMessage: 'feature: add agent config for ${example.name}'
Create ClusterAgent Resource
new ClusterAgent(name: string, args: ClusterAgentArgs, opts?: CustomResourceOptions);
@overload
def ClusterAgent(resource_name: str,
opts: Optional[ResourceOptions] = None,
name: Optional[str] = None,
project: Optional[str] = None)
@overload
def ClusterAgent(resource_name: str,
args: ClusterAgentArgs,
opts: Optional[ResourceOptions] = None)
func NewClusterAgent(ctx *Context, name string, args ClusterAgentArgs, opts ...ResourceOption) (*ClusterAgent, error)
public ClusterAgent(string name, ClusterAgentArgs args, CustomResourceOptions? opts = null)
public ClusterAgent(String name, ClusterAgentArgs args)
public ClusterAgent(String name, ClusterAgentArgs args, CustomResourceOptions options)
type: gitlab:ClusterAgent
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ClusterAgentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args ClusterAgentArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ClusterAgentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ClusterAgentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ClusterAgentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ClusterAgent Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The ClusterAgent resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the ClusterAgent resource produces the following output properties:
- Agent
Id int The ID of the agent.
- Created
At string The ISO8601 datetime when the agent was created.
- Created
By intUser Id The ID of the user who created the agent.
- Id string
The provider-assigned unique ID for this managed resource.
- Agent
Id int The ID of the agent.
- Created
At string The ISO8601 datetime when the agent was created.
- Created
By intUser Id The ID of the user who created the agent.
- Id string
The provider-assigned unique ID for this managed resource.
- agent
Id Integer The ID of the agent.
- created
At String The ISO8601 datetime when the agent was created.
- created
By IntegerUser Id The ID of the user who created the agent.
- id String
The provider-assigned unique ID for this managed resource.
- agent
Id number The ID of the agent.
- created
At string The ISO8601 datetime when the agent was created.
- created
By numberUser Id The ID of the user who created the agent.
- id string
The provider-assigned unique ID for this managed resource.
- agent_
id int The ID of the agent.
- created_
at str The ISO8601 datetime when the agent was created.
- created_
by_ intuser_ id The ID of the user who created the agent.
- id str
The provider-assigned unique ID for this managed resource.
- agent
Id Number The ID of the agent.
- created
At String The ISO8601 datetime when the agent was created.
- created
By NumberUser Id The ID of the user who created the agent.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing ClusterAgent Resource
Get an existing ClusterAgent resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: ClusterAgentState, opts?: CustomResourceOptions): ClusterAgent
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
agent_id: Optional[int] = None,
created_at: Optional[str] = None,
created_by_user_id: Optional[int] = None,
name: Optional[str] = None,
project: Optional[str] = None) -> ClusterAgent
func GetClusterAgent(ctx *Context, name string, id IDInput, state *ClusterAgentState, opts ...ResourceOption) (*ClusterAgent, error)
public static ClusterAgent Get(string name, Input<string> id, ClusterAgentState? state, CustomResourceOptions? opts = null)
public static ClusterAgent get(String name, Output<String> id, ClusterAgentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Agent
Id int The ID of the agent.
- Created
At string The ISO8601 datetime when the agent was created.
- Created
By intUser Id The ID of the user who created the agent.
- Name string
The Name of the agent.
- Project string
ID or full path of the project maintained by the authenticated user.
- Agent
Id int The ID of the agent.
- Created
At string The ISO8601 datetime when the agent was created.
- Created
By intUser Id The ID of the user who created the agent.
- Name string
The Name of the agent.
- Project string
ID or full path of the project maintained by the authenticated user.
- agent
Id Integer The ID of the agent.
- created
At String The ISO8601 datetime when the agent was created.
- created
By IntegerUser Id The ID of the user who created the agent.
- 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 numberUser Id The ID of the user who created the agent.
- name string
The Name of the agent.
- project string
ID or full path of the project maintained by the authenticated user.
- agent_
id int The ID of the agent.
- created_
at str The ISO8601 datetime when the agent was created.
- created_
by_ intuser_ id The ID of the user who created the agent.
- name str
The Name of the agent.
- project str
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 NumberUser Id The ID of the user who created the agent.
- name String
The Name of the agent.
- project String
ID or full path of the project maintained by the authenticated user.
Import
GitLab Agent for Kubernetes can be imported with the following command and the id pattern <project>:<agent-id>
$ pulumi import gitlab:index/clusterAgent:ClusterAgent example '12345:42'
Package Details
- Repository
- GitLab pulumi/pulumi-gitlab
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
gitlab
Terraform Provider.