com.pulumi.aws.codebuild.kotlin.SourceCredential.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-aws-kotlin Show documentation
Show all versions of pulumi-aws-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.aws.codebuild.kotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [SourceCredential].
*/
@PulumiTagMarker
public class SourceCredentialResourceBuilder internal constructor() {
public var name: String? = null
public var args: SourceCredentialArgs = SourceCredentialArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend SourceCredentialArgsBuilder.() -> Unit) {
val builder = SourceCredentialArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): SourceCredential {
val builtJavaResource = com.pulumi.aws.codebuild.SourceCredential(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return SourceCredential(builtJavaResource)
}
}
/**
* Provides a CodeBuild Source Credentials Resource.
* > **NOTE:** [Codebuild only allows a single credential per given server type in a given region](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubSourceCredentials.html). Therefore, when you define `aws.codebuild.SourceCredential`, `aws.codebuild.Project` resource defined in the same module will use it.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* const example = new aws.codebuild.SourceCredential("example", {
* authType: "PERSONAL_ACCESS_TOKEN",
* serverType: "GITHUB",
* token: "example",
* });
* ```
* ```python
* import pulumi
* import pulumi_aws as aws
* example = aws.codebuild.SourceCredential("example",
* auth_type="PERSONAL_ACCESS_TOKEN",
* server_type="GITHUB",
* token="example")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Aws = Pulumi.Aws;
* return await Deployment.RunAsync(() =>
* {
* var example = new Aws.CodeBuild.SourceCredential("example", new()
* {
* AuthType = "PERSONAL_ACCESS_TOKEN",
* ServerType = "GITHUB",
* Token = "example",
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codebuild"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := codebuild.NewSourceCredential(ctx, "example", &codebuild.SourceCredentialArgs{
* AuthType: pulumi.String("PERSONAL_ACCESS_TOKEN"),
* ServerType: pulumi.String("GITHUB"),
* Token: pulumi.String("example"),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.aws.codebuild.SourceCredential;
* import com.pulumi.aws.codebuild.SourceCredentialArgs;
* 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 SourceCredential("example", SourceCredentialArgs.builder()
* .authType("PERSONAL_ACCESS_TOKEN")
* .serverType("GITHUB")
* .token("example")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: aws:codebuild:SourceCredential
* properties:
* authType: PERSONAL_ACCESS_TOKEN
* serverType: GITHUB
* token: example
* ```
*
* ### Bitbucket Server Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* const example = new aws.codebuild.SourceCredential("example", {
* authType: "BASIC_AUTH",
* serverType: "BITBUCKET",
* token: "example",
* userName: "test-user",
* });
* ```
* ```python
* import pulumi
* import pulumi_aws as aws
* example = aws.codebuild.SourceCredential("example",
* auth_type="BASIC_AUTH",
* server_type="BITBUCKET",
* token="example",
* user_name="test-user")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Aws = Pulumi.Aws;
* return await Deployment.RunAsync(() =>
* {
* var example = new Aws.CodeBuild.SourceCredential("example", new()
* {
* AuthType = "BASIC_AUTH",
* ServerType = "BITBUCKET",
* Token = "example",
* UserName = "test-user",
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codebuild"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := codebuild.NewSourceCredential(ctx, "example", &codebuild.SourceCredentialArgs{
* AuthType: pulumi.String("BASIC_AUTH"),
* ServerType: pulumi.String("BITBUCKET"),
* Token: pulumi.String("example"),
* UserName: pulumi.String("test-user"),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.aws.codebuild.SourceCredential;
* import com.pulumi.aws.codebuild.SourceCredentialArgs;
* 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 SourceCredential("example", SourceCredentialArgs.builder()
* .authType("BASIC_AUTH")
* .serverType("BITBUCKET")
* .token("example")
* .userName("test-user")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: aws:codebuild:SourceCredential
* properties:
* authType: BASIC_AUTH
* serverType: BITBUCKET
* token: example
* userName: test-user
* ```
*
* ## Import
* Using `pulumi import`, import CodeBuild Source Credential using the CodeBuild Source Credential arn. For example:
* ```sh
* $ pulumi import aws:codebuild/sourceCredential:SourceCredential example arn:aws:codebuild:us-west-2:123456789:token:github
* ```
*/
public class SourceCredential internal constructor(
override val javaResource: com.pulumi.aws.codebuild.SourceCredential,
) : KotlinCustomResource(javaResource, SourceCredentialMapper) {
/**
* The ARN of Source Credential.
*/
public val arn: Output
get() = javaResource.arn().applyValue({ args0 -> args0 })
/**
* The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API.
*/
public val authType: Output
get() = javaResource.authType().applyValue({ args0 -> args0 })
/**
* The source provider used for this project.
*/
public val serverType: Output
get() = javaResource.serverType().applyValue({ args0 -> args0 })
/**
* For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password.
*/
public val token: Output
get() = javaResource.token().applyValue({ args0 -> args0 })
/**
* The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections.
*/
public val userName: Output?
get() = javaResource.userName().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}
public object SourceCredentialMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.aws.codebuild.SourceCredential::class == javaResource::class
override fun map(javaResource: Resource): SourceCredential = SourceCredential(
javaResource as
com.pulumi.aws.codebuild.SourceCredential,
)
}
/**
* @see [SourceCredential].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [SourceCredential].
*/
public suspend fun sourceCredential(
name: String,
block: suspend SourceCredentialResourceBuilder.() -> Unit,
): SourceCredential {
val builder = SourceCredentialResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [SourceCredential].
* @param name The _unique_ name of the resulting resource.
*/
public fun sourceCredential(name: String): SourceCredential {
val builder = SourceCredentialResourceBuilder()
builder.name(name)
return builder.build()
}