AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.11.0 published on Wednesday, Aug 17, 2022 by Pulumi

getPolicy

This data source can be used to fetch information about a specific IAM policy.

Example Usage

By ARN

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = Aws.Iam.GetPolicy.Invoke(new()
    {
        Arn = "arn:aws:iam::123456789012:policy/UsersManageOwnCredentials",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Arn: pulumi.StringRef("arn:aws:iam::123456789012:policy/UsersManageOwnCredentials"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyArgs;
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) {
        final var example = IamFunctions.getPolicy(GetPolicyArgs.builder()
            .arn("arn:aws:iam::123456789012:policy/UsersManageOwnCredentials")
            .build());

    }
}
import pulumi
import pulumi_aws as aws

example = aws.iam.get_policy(arn="arn:aws:iam::123456789012:policy/UsersManageOwnCredentials")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = pulumi.output(aws.iam.getPolicy({
    arn: "arn:aws:iam::123456789012:policy/UsersManageOwnCredentials",
}));
variables:
  example:
    Fn::Invoke:
      Function: aws:iam:getPolicy
      Arguments:
        arn: arn:aws:iam::123456789012:policy/UsersManageOwnCredentials

By Name

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = Aws.Iam.GetPolicy.Invoke(new()
    {
        Name = "test_policy",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Name: pulumi.StringRef("test_policy"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyArgs;
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) {
        final var example = IamFunctions.getPolicy(GetPolicyArgs.builder()
            .name("test_policy")
            .build());

    }
}
import pulumi
import pulumi_aws as aws

example = aws.iam.get_policy(name="test_policy")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = pulumi.output(aws.iam.getPolicy({
    name: "test_policy",
}));
variables:
  example:
    Fn::Invoke:
      Function: aws:iam:getPolicy
      Arguments:
        name: test_policy

Using getPolicy

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getPolicy(args: GetPolicyArgs, opts?: InvokeOptions): Promise<GetPolicyResult>
function getPolicyOutput(args: GetPolicyOutputArgs, opts?: InvokeOptions): Output<GetPolicyResult>
def get_policy(arn: Optional[str] = None,
               name: Optional[str] = None,
               path_prefix: Optional[str] = None,
               tags: Optional[Mapping[str, str]] = None,
               opts: Optional[InvokeOptions] = None) -> GetPolicyResult
def get_policy_output(arn: Optional[pulumi.Input[str]] = None,
               name: Optional[pulumi.Input[str]] = None,
               path_prefix: Optional[pulumi.Input[str]] = None,
               tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetPolicyResult]
func LookupPolicy(ctx *Context, args *LookupPolicyArgs, opts ...InvokeOption) (*LookupPolicyResult, error)
func LookupPolicyOutput(ctx *Context, args *LookupPolicyOutputArgs, opts ...InvokeOption) LookupPolicyResultOutput

> Note: This function is named LookupPolicy in the Go SDK.

public static class GetPolicy 
{
    public static Task<GetPolicyResult> InvokeAsync(GetPolicyArgs args, InvokeOptions? opts = null)
    public static Output<GetPolicyResult> Invoke(GetPolicyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetPolicyResult> getPolicy(GetPolicyArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:iam/getPolicy:getPolicy
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Arn string

The ARN of the IAM policy. Conflicts with name and path_prefix.

Name string

The name of the IAM policy. Conflicts with arn.

PathPrefix string

The prefix of the path to the IAM policy. Defaults to a slash (/). Conflicts with arn.

Tags Dictionary<string, string>

Key-value mapping of tags for the IAM Policy.

Arn string

The ARN of the IAM policy. Conflicts with name and path_prefix.

Name string

The name of the IAM policy. Conflicts with arn.

PathPrefix string

The prefix of the path to the IAM policy. Defaults to a slash (/). Conflicts with arn.

Tags map[string]string

Key-value mapping of tags for the IAM Policy.

arn String

The ARN of the IAM policy. Conflicts with name and path_prefix.

name String

The name of the IAM policy. Conflicts with arn.

pathPrefix String

The prefix of the path to the IAM policy. Defaults to a slash (/). Conflicts with arn.

tags Map<String,String>

Key-value mapping of tags for the IAM Policy.

arn string

The ARN of the IAM policy. Conflicts with name and path_prefix.

name string

The name of the IAM policy. Conflicts with arn.

pathPrefix string

The prefix of the path to the IAM policy. Defaults to a slash (/). Conflicts with arn.

tags {[key: string]: string}

Key-value mapping of tags for the IAM Policy.

arn str

The ARN of the IAM policy. Conflicts with name and path_prefix.

name str

The name of the IAM policy. Conflicts with arn.

path_prefix str

The prefix of the path to the IAM policy. Defaults to a slash (/). Conflicts with arn.

tags Mapping[str, str]

Key-value mapping of tags for the IAM Policy.

arn String

The ARN of the IAM policy. Conflicts with name and path_prefix.

name String

The name of the IAM policy. Conflicts with arn.

pathPrefix String

The prefix of the path to the IAM policy. Defaults to a slash (/). Conflicts with arn.

tags Map<String>

Key-value mapping of tags for the IAM Policy.

getPolicy Result

The following output properties are available:

Arn string
Description string

The description of the policy.

Id string

The provider-assigned unique ID for this managed resource.

Name string
Path string

The path to the policy.

Policy string

The policy document of the policy.

PolicyId string

The policy's ID.

Tags Dictionary<string, string>

Key-value mapping of tags for the IAM Policy.

PathPrefix string
Arn string
Description string

The description of the policy.

Id string

The provider-assigned unique ID for this managed resource.

Name string
Path string

The path to the policy.

Policy string

The policy document of the policy.

PolicyId string

The policy's ID.

Tags map[string]string

Key-value mapping of tags for the IAM Policy.

PathPrefix string
arn String
description String

The description of the policy.

id String

The provider-assigned unique ID for this managed resource.

name String
path String

The path to the policy.

policy String

The policy document of the policy.

policyId String

The policy's ID.

tags Map<String,String>

Key-value mapping of tags for the IAM Policy.

pathPrefix String
arn string
description string

The description of the policy.

id string

The provider-assigned unique ID for this managed resource.

name string
path string

The path to the policy.

policy string

The policy document of the policy.

policyId string

The policy's ID.

tags {[key: string]: string}

Key-value mapping of tags for the IAM Policy.

pathPrefix string
arn str
description str

The description of the policy.

id str

The provider-assigned unique ID for this managed resource.

name str
path str

The path to the policy.

policy str

The policy document of the policy.

policy_id str

The policy's ID.

tags Mapping[str, str]

Key-value mapping of tags for the IAM Policy.

path_prefix str
arn String
description String

The description of the policy.

id String

The provider-assigned unique ID for this managed resource.

name String
path String

The path to the policy.

policy String

The policy document of the policy.

policyId String

The policy's ID.

tags Map<String>

Key-value mapping of tags for the IAM Policy.

pathPrefix String

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.