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

com.pulumi.aws.resourcegroups.kotlin.Group.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.resourcegroups.kotlin

import com.pulumi.aws.resourcegroups.kotlin.outputs.GroupConfiguration
import com.pulumi.aws.resourcegroups.kotlin.outputs.GroupResourceQuery
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.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.aws.resourcegroups.kotlin.outputs.GroupConfiguration.Companion.toKotlin as groupConfigurationToKotlin
import com.pulumi.aws.resourcegroups.kotlin.outputs.GroupResourceQuery.Companion.toKotlin as groupResourceQueryToKotlin

/**
 * Builder for [Group].
 */
@PulumiTagMarker
public class GroupResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: GroupArgs = GroupArgs()

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

/**
 * Provides a Resource Group.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const test = new aws.resourcegroups.Group("test", {
 *     name: "test-group",
 *     resourceQuery: {
 *         query: `{
 *   "ResourceTypeFilters": [
 *     "AWS::EC2::Instance"
 *   ],
 *   "TagFilters": [
 *     {
 *       "Key": "Stage",
 *       "Values": ["Test"]
 *     }
 *   ]
 * }
 * `,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * test = aws.resourcegroups.Group("test",
 *     name="test-group",
 *     resource_query={
 *         "query": """{
 *   "ResourceTypeFilters": [
 *     "AWS::EC2::Instance"
 *   ],
 *   "TagFilters": [
 *     {
 *       "Key": "Stage",
 *       "Values": ["Test"]
 *     }
 *   ]
 * }
 * """,
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var test = new Aws.ResourceGroups.Group("test", new()
 *     {
 *         Name = "test-group",
 *         ResourceQuery = new Aws.ResourceGroups.Inputs.GroupResourceQueryArgs
 *         {
 *             Query = @"{
 *   ""ResourceTypeFilters"": [
 *     ""AWS::EC2::Instance""
 *   ],
 *   ""TagFilters"": [
 *     {
 *       ""Key"": ""Stage"",
 *       ""Values"": [""Test""]
 *     }
 *   ]
 * }
 * ",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/resourcegroups"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := resourcegroups.NewGroup(ctx, "test", &resourcegroups.GroupArgs{
 * 			Name: pulumi.String("test-group"),
 * 			ResourceQuery: &resourcegroups.GroupResourceQueryArgs{
 * 				Query: pulumi.String(`{
 *   "ResourceTypeFilters": [
 *     "AWS::EC2::Instance"
 *   ],
 *   "TagFilters": [
 *     {
 *       "Key": "Stage",
 *       "Values": ["Test"]
 *     }
 *   ]
 * }
 * `),
 * 			},
 * 		})
 * 		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.resourcegroups.Group;
 * import com.pulumi.aws.resourcegroups.GroupArgs;
 * import com.pulumi.aws.resourcegroups.inputs.GroupResourceQueryArgs;
 * 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 test = new Group("test", GroupArgs.builder()
 *             .name("test-group")
 *             .resourceQuery(GroupResourceQueryArgs.builder()
 *                 .query("""
 * {
 *   "ResourceTypeFilters": [
 *     "AWS::EC2::Instance"
 *   ],
 *   "TagFilters": [
 *     {
 *       "Key": "Stage",
 *       "Values": ["Test"]
 *     }
 *   ]
 * }
 *                 """)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   test:
 *     type: aws:resourcegroups:Group
 *     properties:
 *       name: test-group
 *       resourceQuery:
 *         query: |
 *           {
 *             "ResourceTypeFilters": [
 *               "AWS::EC2::Instance"
 *             ],
 *             "TagFilters": [
 *               {
 *                 "Key": "Stage",
 *                 "Values": ["Test"]
 *               }
 *             ]
 *           }
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import resource groups using the `name`. For example:
 * ```sh
 * $ pulumi import aws:resourcegroups/group:Group foo resource-group-name
 * ```
 */
public class Group internal constructor(
    override val javaResource: com.pulumi.aws.resourcegroups.Group,
) : KotlinCustomResource(javaResource, GroupMapper) {
    /**
     * The ARN assigned by AWS for this resource group.
     */
    public val arn: Output
        get() = javaResource.arn().applyValue({ args0 -> args0 })

    /**
     * A configuration associates the resource group with an AWS service and specifies how the service can interact with the resources in the group. See below for details.
     */
    public val configurations: Output>?
        get() = javaResource.configurations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        groupConfigurationToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * A description of the resource group.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The resource group's name. A resource group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * A `resource_query` block. Resource queries are documented below.
     */
    public val resourceQuery: Output?
        get() = javaResource.resourceQuery().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> groupResourceQueryToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Key-value map of resource tags. .If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block.
     */
    @Deprecated(
        message = """
  Please use `tags` instead.
  """,
    )
    public val tagsAll: Output>
        get() = javaResource.tagsAll().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })
}

public object GroupMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.resourcegroups.Group::class == javaResource::class

    override fun map(javaResource: Resource): Group = Group(
        javaResource as
            com.pulumi.aws.resourcegroups.Group,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy