com.pulumi.aws.iam.kotlin.PolicyArgs.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.iam.kotlin
import com.pulumi.aws.iam.PolicyArgs.builder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.collections.Map
import kotlin.jvm.JvmName
/**
* Provides an IAM policy.
* > **NOTE:** We suggest using explicit JSON encoding or `aws.iam.getPolicyDocument` when assigning a value to `policy`. They seamlessly translate configuration to JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* const policy = new aws.iam.Policy("policy", {
* name: "test_policy",
* path: "/",
* description: "My test policy",
* policy: JSON.stringify({
* Version: "2012-10-17",
* Statement: [{
* Action: ["ec2:Describe*"],
* Effect: "Allow",
* Resource: "*",
* }],
* }),
* });
* ```
* ```python
* import pulumi
* import json
* import pulumi_aws as aws
* policy = aws.iam.Policy("policy",
* name="test_policy",
* path="/",
* description="My test policy",
* policy=json.dumps({
* "Version": "2012-10-17",
* "Statement": [{
* "Action": ["ec2:Describe*"],
* "Effect": "Allow",
* "Resource": "*",
* }],
* }))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using System.Text.Json;
* using Pulumi;
* using Aws = Pulumi.Aws;
* return await Deployment.RunAsync(() =>
* {
* var policy = new Aws.Iam.Policy("policy", new()
* {
* Name = "test_policy",
* Path = "/",
* Description = "My test policy",
* PolicyDocument = JsonSerializer.Serialize(new Dictionary
* {
* ["Version"] = "2012-10-17",
* ["Statement"] = new[]
* {
* new Dictionary
* {
* ["Action"] = new[]
* {
* "ec2:Describe*",
* },
* ["Effect"] = "Allow",
* ["Resource"] = "*",
* },
* },
* }),
* });
* });
* ```
* ```go
* package main
* import (
* "encoding/json"
* "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 {
* tmpJSON0, err := json.Marshal(map[string]interface{}{
* "Version": "2012-10-17",
* "Statement": []map[string]interface{}{
* map[string]interface{}{
* "Action": []string{
* "ec2:Describe*",
* },
* "Effect": "Allow",
* "Resource": "*",
* },
* },
* })
* if err != nil {
* return err
* }
* json0 := string(tmpJSON0)
* _, err = iam.NewPolicy(ctx, "policy", &iam.PolicyArgs{
* Name: pulumi.String("test_policy"),
* Path: pulumi.String("/"),
* Description: pulumi.String("My test policy"),
* Policy: pulumi.String(json0),
* })
* 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.Policy;
* import com.pulumi.aws.iam.PolicyArgs;
* import static com.pulumi.codegen.internal.Serialization.*;
* 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 policy = new Policy("policy", PolicyArgs.builder()
* .name("test_policy")
* .path("/")
* .description("My test policy")
* .policy(serializeJson(
* jsonObject(
* jsonProperty("Version", "2012-10-17"),
* jsonProperty("Statement", jsonArray(jsonObject(
* jsonProperty("Action", jsonArray("ec2:Describe*")),
* jsonProperty("Effect", "Allow"),
* jsonProperty("Resource", "*")
* )))
* )))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* policy:
* type: aws:iam:Policy
* properties:
* name: test_policy
* path: /
* description: My test policy
* policy:
* fn::toJSON:
* Version: 2012-10-17
* Statement:
* - Action:
* - ec2:Describe*
* Effect: Allow
* Resource: '*'
* ```
*
* ## Import
* Using `pulumi import`, import IAM Policies using the `arn`. For example:
* ```sh
* $ pulumi import aws:iam/policy:Policy administrator arn:aws:iam::123456789012:policy/UsersManageOwnCredentials
* ```
* @property description Description of the IAM policy.
* @property name Name of the policy. If omitted, the provider will assign a random, unique name.
* @property namePrefix Creates a unique name beginning with the specified prefix. Conflicts with `name`.
* @property path Path in which to create the policy. See [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) for more information.
* @property policy Policy document. This is a JSON formatted string. For more information about building AWS IAM policy documents, see the AWS IAM Policy Document Guide
* @property tags Map of resource tags for the IAM Policy. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
*/
public data class PolicyArgs(
public val description: Output? = null,
public val name: Output? = null,
public val namePrefix: Output? = null,
public val path: Output? = null,
public val policy: Output? = null,
public val tags: Output