1. Registry
  2. Packages
  3. AWS Cloud Control
  4. API Docs
  5. lambda
  6. getResourcePolicy

We recommend new projects start with resources from the AWS provider.

Viewing docs for AWS Cloud Control v1.79.0
published on Monday, Sep 14, 2026 by Pulumi
aws-native logo aws-native logo

We recommend new projects start with resources from the AWS provider.

Viewing docs for AWS Cloud Control v1.79.0
published on Monday, Sep 14, 2026 by Pulumi

    Use the AWS::Lambda::ResourcePolicy resource to attach a resource-based policy to a LAM resource. A resource-based policy applies to a single LAM resource, for example, a function, function version, or function alias. To learn more about using resource-based policies with LAM, see Working with resource-based policies in in the Developer Guide. You can use resource-based policies to grant permissions to other AWS services, AWS accounts and organizations, and IAM users and roles to access your LAM resource. You can also deny access to specific entities, and use the full range of IAM global condition keys to further restrict who has access to your LAM resource. For example, you can limit access to calls originating from a specified IP address or VPC. A resource-based policy is a JSON document containing a number of statements. Each statement defines the entities you want to grant permission to, the API actions you want to allow or deny, and the LAM resource you want the statement to apply to. A statement can also optionally include an array of logical conditions using the IAM global condition keys. To use the AWS::Lambda::ResourcePolicy resource, make sure that you have the resource-based policy permissions for Lambda. To learn more about creating resource-based policies, see Policies and permissions in in the User Guide. For more information about example policies for providing permissions to AWS services, other AWS accounts, and IAM users and roles, see Example resource-based policies for functions in the Developer Guide. Avoid mixing permission resource types To grant permissions to access your function, we recommend using the AWS::Lambda::ResourcePolicy resource to set access permissions. With this resource, you have more flexibility and fine-grained control than AWS::Lambda::Permission. This resource grants an AWS service or another account permission to call a particular API action on a function. You can also use the AWS::Lambda::Permission resource, however using both AWS::Lambda::Permission and AWS::Lambda::ResourcePolicy to set permissions on a function can result in errors. Permissions defined in AWS::Lambda::Permission can be unintentionally overwritten, whether in a single CFN stack or across multiple stacks. Don’t use both resource types to set permissions on a function. To migrate existing permissions for a function from AWS::Lambda::Permission to AWS::Lambda::ResourcePolicy, do the following:

    1. Set a Retaindeletion policy on the AWS::Lambda::Permission resources you want to migrate. This is necessary so that Lambda does not delete statements with the same statement ID when you delete these resources.
    2. Use the GetResourcePolicyLAM API to retrieve the resource-based policy currently attached to the function.
    3. Use this policy to create a new AWS::Lambda::ResourcePolicy resource.
    4. Delete all the existing AWS::Lambda::Permission resources for the function.

    Using getResourcePolicy

    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 getResourcePolicy(args: GetResourcePolicyArgs, opts?: InvokeOptions): Promise<GetResourcePolicyResult>
    function getResourcePolicyOutput(args: GetResourcePolicyOutputArgs, opts?: InvokeOutputOptions): Output<GetResourcePolicyResult>
    def get_resource_policy(resource_arn: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetResourcePolicyResult
    def get_resource_policy_output(resource_arn: pulumi.Input[Optional[str]] = None,
                            opts: Optional[InvokeOutputOptions] = None) -> Output[GetResourcePolicyResult]
    func LookupResourcePolicy(ctx *Context, args *LookupResourcePolicyArgs, opts ...InvokeOption) (*LookupResourcePolicyResult, error)
    func LookupResourcePolicyOutput(ctx *Context, args *LookupResourcePolicyOutputArgs, opts ...InvokeOption) LookupResourcePolicyResultOutput

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

    public static class GetResourcePolicy 
    {
        public static Task<GetResourcePolicyResult> InvokeAsync(GetResourcePolicyArgs args, InvokeOptions? opts = null)
        public static Output<GetResourcePolicyResult> Invoke(GetResourcePolicyInvokeArgs args, InvokeOptions? opts = null)
        public static Output<GetResourcePolicyResult> Invoke(GetResourcePolicyInvokeArgs args, InvokeOutputOptions opts)
    }
    public static CompletableFuture<GetResourcePolicyResult> getResourcePolicy(GetResourcePolicyArgs args, InvokeOptions options)
    public static Output<GetResourcePolicyResult> getResourcePolicy(GetResourcePolicyArgs args, InvokeOptions options)
    public static Output<GetResourcePolicyResult> getResourcePolicy(GetResourcePolicyArgs args, InvokeOutputOptions options)
    
    fn::invoke:
      function: aws-native:lambda:getResourcePolicy
      arguments:
        # arguments dictionary
    data "aws-native_lambda_get_resource_policy" "name" {
        # arguments
    }

    The following arguments are supported:

    ResourceArn string
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.
    ResourceArn string
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.
    resource_arn string
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.
    resourceArn String
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.
    resourceArn string
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.
    resource_arn str
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.
    resourceArn String
    The Amazon Resource Name (ARN) of the LAM resource you want to add the policy to. For a function, you can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.

    getResourcePolicy Result

    The following output properties are available:

    PolicyDocument object

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    PolicyDocument interface{}

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    policy_document any

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    policyDocument Object

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    policyDocument any

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    policy_document Any

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    policyDocument Any

    The policy document you want to add to your LAM resource. This is formatted as a JSON string. For more information, see Working with resource-based policies in in the Developer Guide.

    Search the CloudFormation User Guide for AWS::Lambda::ResourcePolicy for more information about the expected schema for this property.

    Package Details

    Repository
    AWS Native pulumi/pulumi-aws-native
    License
    Apache-2.0
    aws-native logo aws-native logo

    We recommend new projects start with resources from the AWS provider.

    Viewing docs for AWS Cloud Control v1.79.0
    published on Monday, Sep 14, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial