getPolicy

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

Example Usage

By ARN

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var example = Output.Create(Aws.Iam.GetPolicy.InvokeAsync(new Aws.Iam.GetPolicyArgs
        {
            Arn = "arn:aws:iam::123456789012:policy/UsersManageOwnCredentials",
        }));
    }

}
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		opt0 := "arn:aws:iam::123456789012:policy/UsersManageOwnCredentials"
		_, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Arn: &opt0,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
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",
}, { async: true }));

By Name

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var example = Output.Create(Aws.Iam.GetPolicy.InvokeAsync(new Aws.Iam.GetPolicyArgs
        {
            Name = "test_policy",
        }));
    }

}
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		opt0 := "test_policy"
		_, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Name: &opt0,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
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",
}, { async: true }));

Using getPolicy

function getPolicy(args: GetPolicyArgs, opts?: InvokeOptions): Promise<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
func LookupPolicy(ctx *Context, args *LookupPolicyArgs, opts ...InvokeOption) (*LookupPolicyResult, error)

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

public static class GetPolicy {
    public static Task<GetPolicyResult> InvokeAsync(GetPolicyArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Arn string
The ARN of the IAM policy.
Name string
The name of the IAM policy.
PathPrefix string
The prefix of the path to the IAM policy. Defaults to a slash (/).
Tags Dictionary<string, string>
Key-value mapping of tags for the IAM Policy.
Arn string
The ARN of the IAM policy.
Name string
The name of the IAM policy.
PathPrefix string
The prefix of the path to the IAM policy. Defaults to a slash (/).
Tags map[string]string
Key-value mapping of tags for the IAM Policy.
arn string
The ARN of the IAM policy.
name string
The name of the IAM policy.
pathPrefix string
The prefix of the path to the IAM policy. Defaults to a slash (/).
tags {[key: string]: string}
Key-value mapping of tags for the IAM Policy.
arn str
The ARN of the IAM policy.
name str
The name of the IAM policy.
path_prefix str
The prefix of the path to the IAM policy. Defaults to a slash (/).
tags Mapping[str, str]
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 {[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

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.