
com.pulumi.gcp.developerconnect.kotlin.Connection.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.developerconnect.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.developerconnect.kotlin.outputs.ConnectionGithubConfig
import com.pulumi.gcp.developerconnect.kotlin.outputs.ConnectionInstallationState
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
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.developerconnect.kotlin.outputs.ConnectionGithubConfig.Companion.toKotlin as connectionGithubConfigToKotlin
import com.pulumi.gcp.developerconnect.kotlin.outputs.ConnectionInstallationState.Companion.toKotlin as connectionInstallationStateToKotlin
/**
* Builder for [Connection].
*/
@PulumiTagMarker
public class ConnectionResourceBuilder internal constructor() {
public var name: String? = null
public var args: ConnectionArgs = ConnectionArgs()
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 ConnectionArgsBuilder.() -> Unit) {
val builder = ConnectionArgsBuilder()
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(): Connection {
val builtJavaResource = com.pulumi.gcp.developerconnect.Connection(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Connection(builtJavaResource)
}
}
/**
* ## Example Usage
* ### Developer Connect Connection Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const my_connection = new gcp.developerconnect.Connection("my-connection", {
* location: "us-central1",
* connectionId: "tf-test-connection",
* githubConfig: {
* githubApp: "DEVELOPER_CONNECT",
* authorizerCredential: {
* oauthTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1",
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* my_connection = gcp.developerconnect.Connection("my-connection",
* location="us-central1",
* connection_id="tf-test-connection",
* github_config={
* "github_app": "DEVELOPER_CONNECT",
* "authorizer_credential": {
* "oauth_token_secret_version": "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1",
* },
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var my_connection = new Gcp.DeveloperConnect.Connection("my-connection", new()
* {
* Location = "us-central1",
* ConnectionId = "tf-test-connection",
* GithubConfig = new Gcp.DeveloperConnect.Inputs.ConnectionGithubConfigArgs
* {
* GithubApp = "DEVELOPER_CONNECT",
* AuthorizerCredential = new Gcp.DeveloperConnect.Inputs.ConnectionGithubConfigAuthorizerCredentialArgs
* {
* OauthTokenSecretVersion = "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1",
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/developerconnect"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := developerconnect.NewConnection(ctx, "my-connection", &developerconnect.ConnectionArgs{
* Location: pulumi.String("us-central1"),
* ConnectionId: pulumi.String("tf-test-connection"),
* GithubConfig: &developerconnect.ConnectionGithubConfigArgs{
* GithubApp: pulumi.String("DEVELOPER_CONNECT"),
* AuthorizerCredential: &developerconnect.ConnectionGithubConfigAuthorizerCredentialArgs{
* OauthTokenSecretVersion: pulumi.String("projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1"),
* },
* },
* })
* 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.gcp.developerconnect.Connection;
* import com.pulumi.gcp.developerconnect.ConnectionArgs;
* import com.pulumi.gcp.developerconnect.inputs.ConnectionGithubConfigArgs;
* import com.pulumi.gcp.developerconnect.inputs.ConnectionGithubConfigAuthorizerCredentialArgs;
* 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 my_connection = new Connection("my-connection", ConnectionArgs.builder()
* .location("us-central1")
* .connectionId("tf-test-connection")
* .githubConfig(ConnectionGithubConfigArgs.builder()
* .githubApp("DEVELOPER_CONNECT")
* .authorizerCredential(ConnectionGithubConfigAuthorizerCredentialArgs.builder()
* .oauthTokenSecretVersion("projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* my-connection:
* type: gcp:developerconnect:Connection
* properties:
* location: us-central1
* connectionId: tf-test-connection
* githubConfig:
* githubApp: DEVELOPER_CONNECT
* authorizerCredential:
* oauthTokenSecretVersion: projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1
* ```
*
* ### Developer Connect Connection Github Doc
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as std from "@pulumi/std";
* const github_token_secret = new gcp.secretmanager.Secret("github-token-secret", {
* secretId: "github-token-secret",
* replication: {
* auto: {},
* },
* });
* const github_token_secret_version = new gcp.secretmanager.SecretVersion("github-token-secret-version", {
* secret: github_token_secret.id,
* secretData: std.file({
* input: "my-github-token.txt",
* }).then(invoke => invoke.result),
* });
* const p4sa-secretAccessor = gcp.organizations.getIAMPolicy({
* bindings: [{
* role: "roles/secretmanager.secretAccessor",
* members: ["serviceAccount:service-123456789@gcp-sa-devconnect.iam.gserviceaccount.com"],
* }],
* });
* const policy = new gcp.secretmanager.SecretIamPolicy("policy", {
* secretId: github_token_secret.secretId,
* policyData: p4sa_secretAccessor.then(p4sa_secretAccessor => p4sa_secretAccessor.policyData),
* });
* const my_connection = new gcp.developerconnect.Connection("my-connection", {
* location: "us-central1",
* connectionId: "my-connection",
* githubConfig: {
* githubApp: "DEVELOPER_CONNECT",
* appInstallationId: "123123",
* authorizerCredential: {
* oauthTokenSecretVersion: github_token_secret_version.id,
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* import pulumi_std as std
* github_token_secret = gcp.secretmanager.Secret("github-token-secret",
* secret_id="github-token-secret",
* replication={
* "auto": {},
* })
* github_token_secret_version = gcp.secretmanager.SecretVersion("github-token-secret-version",
* secret=github_token_secret.id,
* secret_data=std.file(input="my-github-token.txt").result)
* p4sa_secret_accessor = gcp.organizations.get_iam_policy(bindings=[{
* "role": "roles/secretmanager.secretAccessor",
* "members": ["serviceAccount:service-123456789@gcp-sa-devconnect.iam.gserviceaccount.com"],
* }])
* policy = gcp.secretmanager.SecretIamPolicy("policy",
* secret_id=github_token_secret.secret_id,
* policy_data=p4sa_secret_accessor.policy_data)
* my_connection = gcp.developerconnect.Connection("my-connection",
* location="us-central1",
* connection_id="my-connection",
* github_config={
* "github_app": "DEVELOPER_CONNECT",
* "app_installation_id": "123123",
* "authorizer_credential": {
* "oauth_token_secret_version": github_token_secret_version.id,
* },
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* using Std = Pulumi.Std;
* return await Deployment.RunAsync(() =>
* {
* var github_token_secret = new Gcp.SecretManager.Secret("github-token-secret", new()
* {
* SecretId = "github-token-secret",
* Replication = new Gcp.SecretManager.Inputs.SecretReplicationArgs
* {
* Auto = null,
* },
* });
* var github_token_secret_version = new Gcp.SecretManager.SecretVersion("github-token-secret-version", new()
* {
* Secret = github_token_secret.Id,
* SecretData = Std.File.Invoke(new()
* {
* Input = "my-github-token.txt",
* }).Apply(invoke => invoke.Result),
* });
* var p4sa_secretAccessor = Gcp.Organizations.GetIAMPolicy.Invoke(new()
* {
* Bindings = new[]
* {
* new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
* {
* Role = "roles/secretmanager.secretAccessor",
* Members = new[]
* {
* "serviceAccount:[email protected]",
* },
* },
* },
* });
* var policy = new Gcp.SecretManager.SecretIamPolicy("policy", new()
* {
* SecretId = github_token_secret.SecretId,
* PolicyData = p4sa_secretAccessor.Apply(p4sa_secretAccessor => p4sa_secretAccessor.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData)),
* });
* var my_connection = new Gcp.DeveloperConnect.Connection("my-connection", new()
* {
* Location = "us-central1",
* ConnectionId = "my-connection",
* GithubConfig = new Gcp.DeveloperConnect.Inputs.ConnectionGithubConfigArgs
* {
* GithubApp = "DEVELOPER_CONNECT",
* AppInstallationId = "123123",
* AuthorizerCredential = new Gcp.DeveloperConnect.Inputs.ConnectionGithubConfigAuthorizerCredentialArgs
* {
* OauthTokenSecretVersion = github_token_secret_version.Id,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/developerconnect"
* "github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
* "github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/secretmanager"
* "github.com/pulumi/pulumi-std/sdk/go/std"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := secretmanager.NewSecret(ctx, "github-token-secret", &secretmanager.SecretArgs{
* SecretId: pulumi.String("github-token-secret"),
* Replication: &secretmanager.SecretReplicationArgs{
* Auto: &secretmanager.SecretReplicationAutoArgs{},
* },
* })
* if err != nil {
* return err
* }
* invokeFile, err := std.File(ctx, &std.FileArgs{
* Input: "my-github-token.txt",
* }, nil)
* if err != nil {
* return err
* }
* _, err = secretmanager.NewSecretVersion(ctx, "github-token-secret-version", &secretmanager.SecretVersionArgs{
* Secret: github_token_secret.ID(),
* SecretData: pulumi.String(invokeFile.Result),
* })
* if err != nil {
* return err
* }
* p4sa_secretAccessor, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
* Bindings: []organizations.GetIAMPolicyBinding{
* {
* Role: "roles/secretmanager.secretAccessor",
* Members: []string{
* "serviceAccount:[email protected]",
* },
* },
* },
* }, nil)
* if err != nil {
* return err
* }
* _, err = secretmanager.NewSecretIamPolicy(ctx, "policy", &secretmanager.SecretIamPolicyArgs{
* SecretId: github_token_secret.SecretId,
* PolicyData: pulumi.String(p4sa_secretAccessor.PolicyData),
* })
* if err != nil {
* return err
* }
* _, err = developerconnect.NewConnection(ctx, "my-connection", &developerconnect.ConnectionArgs{
* Location: pulumi.String("us-central1"),
* ConnectionId: pulumi.String("my-connection"),
* GithubConfig: &developerconnect.ConnectionGithubConfigArgs{
* GithubApp: pulumi.String("DEVELOPER_CONNECT"),
* AppInstallationId: pulumi.String("123123"),
* AuthorizerCredential: &developerconnect.ConnectionGithubConfigAuthorizerCredentialArgs{
* OauthTokenSecretVersion: github_token_secret_version.ID(),
* },
* },
* })
* 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.gcp.secretmanager.Secret;
* import com.pulumi.gcp.secretmanager.SecretArgs;
* import com.pulumi.gcp.secretmanager.inputs.SecretReplicationArgs;
* import com.pulumi.gcp.secretmanager.inputs.SecretReplicationAutoArgs;
* import com.pulumi.gcp.secretmanager.SecretVersion;
* import com.pulumi.gcp.secretmanager.SecretVersionArgs;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
* import com.pulumi.gcp.secretmanager.SecretIamPolicy;
* import com.pulumi.gcp.secretmanager.SecretIamPolicyArgs;
* import com.pulumi.gcp.developerconnect.Connection;
* import com.pulumi.gcp.developerconnect.ConnectionArgs;
* import com.pulumi.gcp.developerconnect.inputs.ConnectionGithubConfigArgs;
* import com.pulumi.gcp.developerconnect.inputs.ConnectionGithubConfigAuthorizerCredentialArgs;
* 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 github_token_secret = new Secret("github-token-secret", SecretArgs.builder()
* .secretId("github-token-secret")
* .replication(SecretReplicationArgs.builder()
* .auto()
* .build())
* .build());
* var github_token_secret_version = new SecretVersion("github-token-secret-version", SecretVersionArgs.builder()
* .secret(github_token_secret.id())
* .secretData(StdFunctions.file(FileArgs.builder()
* .input("my-github-token.txt")
* .build()).result())
* .build());
* final var p4sa-secretAccessor = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
* .bindings(GetIAMPolicyBindingArgs.builder()
* .role("roles/secretmanager.secretAccessor")
* .members("serviceAccount:[email protected]")
* .build())
* .build());
* var policy = new SecretIamPolicy("policy", SecretIamPolicyArgs.builder()
* .secretId(github_token_secret.secretId())
* .policyData(p4sa_secretAccessor.policyData())
* .build());
* var my_connection = new Connection("my-connection", ConnectionArgs.builder()
* .location("us-central1")
* .connectionId("my-connection")
* .githubConfig(ConnectionGithubConfigArgs.builder()
* .githubApp("DEVELOPER_CONNECT")
* .appInstallationId(123123)
* .authorizerCredential(ConnectionGithubConfigAuthorizerCredentialArgs.builder()
* .oauthTokenSecretVersion(github_token_secret_version.id())
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* github-token-secret:
* type: gcp:secretmanager:Secret
* properties:
* secretId: github-token-secret
* replication:
* auto: {}
* github-token-secret-version:
* type: gcp:secretmanager:SecretVersion
* properties:
* secret: ${["github-token-secret"].id}
* secretData:
* fn::invoke:
* function: std:file
* arguments:
* input: my-github-token.txt
* return: result
* policy:
* type: gcp:secretmanager:SecretIamPolicy
* properties:
* secretId: ${["github-token-secret"].secretId}
* policyData: ${["p4sa-secretAccessor"].policyData}
* my-connection:
* type: gcp:developerconnect:Connection
* properties:
* location: us-central1
* connectionId: my-connection
* githubConfig:
* githubApp: DEVELOPER_CONNECT
* appInstallationId: 123123
* authorizerCredential:
* oauthTokenSecretVersion: ${["github-token-secret-version"].id}
* variables:
* p4sa-secretAccessor:
* fn::invoke:
* function: gcp:organizations:getIAMPolicy
* arguments:
* bindings:
* - role: roles/secretmanager.secretAccessor
* members:
* - serviceAccount:[email protected]
* ```
*
* ## Import
* Connection can be imported using any of these accepted formats:
* * `projects/{{project}}/locations/{{location}}/connections/{{connection_id}}`
* * `{{project}}/{{location}}/{{connection_id}}`
* * `{{location}}/{{connection_id}}`
* When using the `pulumi import` command, Connection can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:developerconnect/connection:Connection default projects/{{project}}/locations/{{location}}/connections/{{connection_id}}
* ```
* ```sh
* $ pulumi import gcp:developerconnect/connection:Connection default {{project}}/{{location}}/{{connection_id}}
* ```
* ```sh
* $ pulumi import gcp:developerconnect/connection:Connection default {{location}}/{{connection_id}}
* ```
*/
public class Connection internal constructor(
override val javaResource: com.pulumi.gcp.developerconnect.Connection,
) : KotlinCustomResource(javaResource, ConnectionMapper) {
/**
* Optional. Allows clients to store small amounts of arbitrary data.
* **Note**: This field is non-authoritative, and will only manage the annotations present in your configuration.
* Please refer to the field `effective_annotations` for all of the annotations present on the resource.
*/
public val annotations: Output
© 2015 - 2025 Weber Informatics LLC | Privacy Policy