AWS v6.71.0 published on Friday, Mar 7, 2025 by Pulumi
aws.iam.getPolicy
Explore with Pulumi AI
This data source can be used to fetch information about a specific IAM policy.
Example Usage
By ARN
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.iam.getPolicy({
    arn: "arn:aws:iam::123456789012:policy/UsersManageOwnCredentials",
});
import pulumi
import pulumi_aws as aws
example = aws.iam.get_policy(arn="arn:aws:iam::123456789012:policy/UsersManageOwnCredentials")
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 {
		_, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Arn: pulumi.StringRef("arn:aws:iam::123456789012:policy/UsersManageOwnCredentials"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
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 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());
    }
}
variables:
  example:
    fn::invoke:
      function: aws:iam:getPolicy
      arguments:
        arn: arn:aws:iam::123456789012:policy/UsersManageOwnCredentials
By Name
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.iam.getPolicy({
    name: "test_policy",
});
import pulumi
import pulumi_aws as aws
example = aws.iam.get_policy(name="test_policy")
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 {
		_, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Name: pulumi.StringRef("test_policy"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() => 
{
    var example = Aws.Iam.GetPolicy.Invoke(new()
    {
        Name = "test_policy",
    });
});
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());
    }
}
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)
public static Output<GetPolicyResult> getPolicy(GetPolicyArgs args, InvokeOptions options)
fn::invoke:
  function: aws:iam/getPolicy:getPolicy
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Arn string
- ARN of the IAM policy.
Conflicts with nameandpath_prefix.
- Name string
- Name of the IAM policy.
Conflicts with arn.
- PathPrefix string
- Prefix of the path to the IAM policy.
Defaults to a slash (/). Conflicts witharn.
- Dictionary<string, string>
- Key-value mapping of tags for the IAM Policy.
- Arn string
- ARN of the IAM policy.
Conflicts with nameandpath_prefix.
- Name string
- Name of the IAM policy.
Conflicts with arn.
- PathPrefix string
- Prefix of the path to the IAM policy.
Defaults to a slash (/). Conflicts witharn.
- map[string]string
- Key-value mapping of tags for the IAM Policy.
- arn String
- ARN of the IAM policy.
Conflicts with nameandpath_prefix.
- name String
- Name of the IAM policy.
Conflicts with arn.
- pathPrefix String
- Prefix of the path to the IAM policy.
Defaults to a slash (/). Conflicts witharn.
- Map<String,String>
- Key-value mapping of tags for the IAM Policy.
- arn string
- ARN of the IAM policy.
Conflicts with nameandpath_prefix.
- name string
- Name of the IAM policy.
Conflicts with arn.
- pathPrefix string
- Prefix of the path to the IAM policy.
Defaults to a slash (/). Conflicts witharn.
- {[key: string]: string}
- Key-value mapping of tags for the IAM Policy.
- arn str
- ARN of the IAM policy.
Conflicts with nameandpath_prefix.
- name str
- Name of the IAM policy.
Conflicts with arn.
- path_prefix str
- Prefix of the path to the IAM policy.
Defaults to a slash (/). Conflicts witharn.
- Mapping[str, str]
- Key-value mapping of tags for the IAM Policy.
- arn String
- ARN of the IAM policy.
Conflicts with nameandpath_prefix.
- name String
- Name of the IAM policy.
Conflicts with arn.
- pathPrefix String
- Prefix of the path to the IAM policy.
Defaults to a slash (/). Conflicts witharn.
- Map<String>
- Key-value mapping of tags for the IAM Policy.
getPolicy Result
The following output properties are available:
- Arn string
- ARN of the policy.
- AttachmentCount int
- Number of entities (users, groups, and roles) that the policy is attached to.
- Description string
- Description of the policy.
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- Path string
- Path to the policy.
- Policy string
- Policy document of the policy.
- PolicyId string
- Policy's ID.
- Dictionary<string, string>
- Key-value mapping of tags for the IAM Policy.
- PathPrefix string
- Arn string
- ARN of the policy.
- AttachmentCount int
- Number of entities (users, groups, and roles) that the policy is attached to.
- Description string
- Description of the policy.
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- Path string
- Path to the policy.
- Policy string
- Policy document of the policy.
- PolicyId string
- Policy's ID.
- map[string]string
- Key-value mapping of tags for the IAM Policy.
- PathPrefix string
- arn String
- ARN of the policy.
- attachmentCount Integer
- Number of entities (users, groups, and roles) that the policy is attached to.
- description String
- Description of the policy.
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- path String
- Path to the policy.
- policy String
- Policy document of the policy.
- policyId String
- Policy's ID.
- Map<String,String>
- Key-value mapping of tags for the IAM Policy.
- pathPrefix String
- arn string
- ARN of the policy.
- attachmentCount number
- Number of entities (users, groups, and roles) that the policy is attached to.
- description string
- Description of the policy.
- id string
- The provider-assigned unique ID for this managed resource.
- name string
- path string
- Path to the policy.
- policy string
- Policy document of the policy.
- policyId string
- Policy's ID.
- {[key: string]: string}
- Key-value mapping of tags for the IAM Policy.
- pathPrefix string
- arn str
- ARN of the policy.
- attachment_count int
- Number of entities (users, groups, and roles) that the policy is attached to.
- description str
- Description of the policy.
- id str
- The provider-assigned unique ID for this managed resource.
- name str
- path str
- Path to the policy.
- policy str
- Policy document of the policy.
- policy_id str
- Policy's ID.
- Mapping[str, str]
- Key-value mapping of tags for the IAM Policy.
- path_prefix str
- arn String
- ARN of the policy.
- attachmentCount Number
- Number of entities (users, groups, and roles) that the policy is attached to.
- description String
- Description of the policy.
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- path String
- Path to the policy.
- policy String
- Policy document of the policy.
- policyId String
- Policy's ID.
- Map<String>
- Key-value mapping of tags for the IAM Policy.
- pathPrefix String
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the awsTerraform Provider.