All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.aws.iam.kotlin.GroupPolicyAttachment.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.57.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.aws.iam.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 [GroupPolicyAttachment].
 */
@PulumiTagMarker
public class GroupPolicyAttachmentResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: GroupPolicyAttachmentArgs = GroupPolicyAttachmentArgs()

    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 GroupPolicyAttachmentArgsBuilder.() -> Unit) {
        val builder = GroupPolicyAttachmentArgsBuilder()
        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(): GroupPolicyAttachment {
        val builtJavaResource = com.pulumi.aws.iam.GroupPolicyAttachment(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return GroupPolicyAttachment(builtJavaResource)
    }
}

/**
 * Attaches a Managed IAM Policy to an IAM group
 * > **NOTE:** The usage of this resource conflicts with the `aws.iam.PolicyAttachment` resource and will permanently show a difference if both are defined.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const group = new aws.iam.Group("group", {name: "test-group"});
 * const policy = new aws.iam.Policy("policy", {
 *     name: "test-policy",
 *     description: "A test policy",
 *     policy: "{ ... policy JSON ... }",
 * });
 * const test_attach = new aws.iam.GroupPolicyAttachment("test-attach", {
 *     group: group.name,
 *     policyArn: policy.arn,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * group = aws.iam.Group("group", name="test-group")
 * policy = aws.iam.Policy("policy",
 *     name="test-policy",
 *     description="A test policy",
 *     policy="{ ... policy JSON ... }")
 * test_attach = aws.iam.GroupPolicyAttachment("test-attach",
 *     group=group.name,
 *     policy_arn=policy.arn)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @group = new Aws.Iam.Group("group", new()
 *     {
 *         Name = "test-group",
 *     });
 *     var policy = new Aws.Iam.Policy("policy", new()
 *     {
 *         Name = "test-policy",
 *         Description = "A test policy",
 *         PolicyDocument = "{ ... policy JSON ... }",
 *     });
 *     var test_attach = new Aws.Iam.GroupPolicyAttachment("test-attach", new()
 *     {
 *         Group = @group.Name,
 *         PolicyArn = policy.Arn,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		group, err := iam.NewGroup(ctx, "group", &iam.GroupArgs{
 * 			Name: pulumi.String("test-group"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		policy, err := iam.NewPolicy(ctx, "policy", &iam.PolicyArgs{
 * 			Name:        pulumi.String("test-policy"),
 * 			Description: pulumi.String("A test policy"),
 * 			Policy:      pulumi.Any("{ ... policy JSON ... }"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = iam.NewGroupPolicyAttachment(ctx, "test-attach", &iam.GroupPolicyAttachmentArgs{
 * 			Group:     group.Name,
 * 			PolicyArn: policy.Arn,
 * 		})
 * 		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.iam.Group;
 * import com.pulumi.aws.iam.GroupArgs;
 * import com.pulumi.aws.iam.Policy;
 * import com.pulumi.aws.iam.PolicyArgs;
 * import com.pulumi.aws.iam.GroupPolicyAttachment;
 * import com.pulumi.aws.iam.GroupPolicyAttachmentArgs;
 * 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 group = new Group("group", GroupArgs.builder()
 *             .name("test-group")
 *             .build());
 *         var policy = new Policy("policy", PolicyArgs.builder()
 *             .name("test-policy")
 *             .description("A test policy")
 *             .policy("{ ... policy JSON ... }")
 *             .build());
 *         var test_attach = new GroupPolicyAttachment("test-attach", GroupPolicyAttachmentArgs.builder()
 *             .group(group.name())
 *             .policyArn(policy.arn())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   group:
 *     type: aws:iam:Group
 *     properties:
 *       name: test-group
 *   policy:
 *     type: aws:iam:Policy
 *     properties:
 *       name: test-policy
 *       description: A test policy
 *       policy: '{ ... policy JSON ... }'
 *   test-attach:
 *     type: aws:iam:GroupPolicyAttachment
 *     properties:
 *       group: ${group.name}
 *       policyArn: ${policy.arn}
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import IAM group policy attachments using the group name and policy arn separated by `/`. For example:
 * ```sh
 * $ pulumi import aws:iam/groupPolicyAttachment:GroupPolicyAttachment test-attach test-group/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy
 * ```
 */
public class GroupPolicyAttachment internal constructor(
    override val javaResource: com.pulumi.aws.iam.GroupPolicyAttachment,
) : KotlinCustomResource(javaResource, GroupPolicyAttachmentMapper) {
    /**
     * The group the policy should be applied to
     */
    public val group: Output
        get() = javaResource.group().applyValue({ args0 -> args0 })

    /**
     * The ARN of the policy you want to apply
     */
    public val policyArn: Output
        get() = javaResource.policyArn().applyValue({ args0 -> args0 })
}

public object GroupPolicyAttachmentMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.iam.GroupPolicyAttachment::class == javaResource::class

    override fun map(javaResource: Resource): GroupPolicyAttachment =
        GroupPolicyAttachment(javaResource as com.pulumi.aws.iam.GroupPolicyAttachment)
}

/**
 * @see [GroupPolicyAttachment].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [GroupPolicyAttachment].
 */
public suspend fun groupPolicyAttachment(
    name: String,
    block: suspend GroupPolicyAttachmentResourceBuilder.() -> Unit,
): GroupPolicyAttachment {
    val builder = GroupPolicyAttachmentResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [GroupPolicyAttachment].
 * @param name The _unique_ name of the resulting resource.
 */
public fun groupPolicyAttachment(name: String): GroupPolicyAttachment {
    val builder = GroupPolicyAttachmentResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy