1. Registry
  2. Packages
  3. AWS
  4. API Docs
  5. lambda
  6. ResourcePolicy
Viewing docs for AWS v7.48.0
published on Tuesday, Sep 22, 2026 by Pulumi
aws logo aws logo
Viewing docs for AWS v7.48.0
published on Tuesday, Sep 22, 2026 by Pulumi

    Manages the complete IAM resource-based policy document for an AWS Lambda function, function version, or alias.

    Note: PutResourcePolicy (used by this resource) replaces the entire resource-based policy on the Lambda resource, including any statements added with aws.lambda.Permission. Do not use aws.lambda.ResourcePolicy and aws.lambda.Permission on the same Lambda function, version, or alias — every apply of one will overwrite statements managed by the other.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.getCallerIdentity({});
    const example = current.then(current => aws.iam.getPolicyDocument({
        statements: [{
            conditions: [{
                test: "StringEquals",
                variable: "aws:SourceAccount",
                values: [current.accountId],
            }],
            principals: [{
                type: "Service",
                identifiers: ["s3.amazonaws.com"],
            }],
            sid: "AllowInvokeFromS3",
            effect: "Allow",
            actions: ["lambda:InvokeFunction"],
            resources: [exampleAwsLambdaFunction.arn],
        }],
    }));
    const exampleResourcePolicy = new aws.lambda.ResourcePolicy("example", {
        resourceArn: exampleAwsLambdaFunction.arn,
        policy: example.then(example => example.json),
    });
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.get_caller_identity()
    example = aws.iam.get_policy_document(statements=[{
        "conditions": [{
            "test": "StringEquals",
            "variable": "aws:SourceAccount",
            "values": [current.account_id],
        }],
        "principals": [{
            "type": "Service",
            "identifiers": ["s3.amazonaws.com"],
        }],
        "sid": "AllowInvokeFromS3",
        "effect": "Allow",
        "actions": ["lambda:InvokeFunction"],
        "resources": [example_aws_lambda_function["arn"]],
    }])
    example_resource_policy = aws.lambda_.ResourcePolicy("example",
        resource_arn=example_aws_lambda_function["arn"],
        policy=example.json)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		current, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    			Statements: []iam.GetPolicyDocumentStatement{
    				{
    					Conditions: []iam.GetPolicyDocumentStatementCondition{
    						{
    							Test:     "StringEquals",
    							Variable: "aws:SourceAccount",
    							Values: pulumi.StringArray{
    								current.AccountId,
    							},
    						},
    					},
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Type: "Service",
    							Identifiers: []string{
    								"s3.amazonaws.com",
    							},
    						},
    					},
    					Sid:    pulumi.StringRef("AllowInvokeFromS3"),
    					Effect: pulumi.StringRef("Allow"),
    					Actions: []string{
    						"lambda:InvokeFunction",
    					},
    					Resources: pulumi.StringArray{
    						exampleAwsLambdaFunction.Arn,
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = lambda.NewResourcePolicy(ctx, "example", &lambda.ResourcePolicyArgs{
    			ResourceArn: pulumi.Any(exampleAwsLambdaFunction.Arn),
    			Policy:      pulumi.String(example.Json),
    		})
    		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 current = Aws.GetCallerIdentity.Invoke();
    
        var example = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "StringEquals",
                            Variable = "aws:SourceAccount",
                            Values = new[]
                            {
                                current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
                            },
                        },
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "Service",
                            Identifiers = new[]
                            {
                                "s3.amazonaws.com",
                            },
                        },
                    },
                    Sid = "AllowInvokeFromS3",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "lambda:InvokeFunction",
                    },
                    Resources = new[]
                    {
                        exampleAwsLambdaFunction.Arn,
                    },
                },
            },
        });
    
        var exampleResourcePolicy = new Aws.Lambda.ResourcePolicy("example", new()
        {
            ResourceArn = exampleAwsLambdaFunction.Arn,
            Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.inputs.GetCallerIdentityArgs;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
    import com.pulumi.aws.lambda.ResourcePolicy;
    import com.pulumi.aws.lambda.ResourcePolicyArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
                .build());
    
            final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(GetPolicyDocumentStatementArgs.builder()
                    .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                        .test("StringEquals")
                        .variable("aws:SourceAccount")
                        .values(current.accountId())
                        .build())
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("Service")
                        .identifiers("s3.amazonaws.com")
                        .build())
                    .sid("AllowInvokeFromS3")
                    .effect("Allow")
                    .actions("lambda:InvokeFunction")
                    .resources(exampleAwsLambdaFunction.arn())
                    .build())
                .build());
    
            var exampleResourcePolicy = new ResourcePolicy("exampleResourcePolicy", ResourcePolicyArgs.builder()
                .resourceArn(exampleAwsLambdaFunction.arn())
                .policy(example.json())
                .build());
    
        }
    }
    
    resources:
      exampleResourcePolicy:
        type: aws:lambda:ResourcePolicy
        name: example
        properties:
          resourceArn: ${exampleAwsLambdaFunction.arn}
          policy: ${example.json}
    variables:
      example:
        fn::invoke:
          function: aws:iam:getPolicyDocument
          arguments:
            statements:
              - conditions:
                  - test: StringEquals
                    variable: aws:SourceAccount
                    values:
                      - ${current.accountId}
                principals:
                  - type: Service
                    identifiers:
                      - s3.amazonaws.com
                sid: AllowInvokeFromS3
                effect: Allow
                actions:
                  - lambda:InvokeFunction
                resources:
                  - ${exampleAwsLambdaFunction.arn}
      current:
        fn::invoke:
          function: aws:getCallerIdentity
          arguments: {}
    
    pulumi {
      required_providers {
        aws = {
          source = "pulumi/aws"
        }
      }
    }
    
    data "aws_iam_getpolicydocument" "example" {
      statements {
        conditions {
          test     = "StringEquals"
          variable = "aws:SourceAccount"
          values   = [data.aws_getcalleridentity.current.account_id]
        }
        principals {
          type        = "Service"
          identifiers = ["s3.amazonaws.com"]
        }
        sid       = "AllowInvokeFromS3"
        effect    = "Allow"
        actions   = ["lambda:InvokeFunction"]
        resources = [exampleAwsLambdaFunction.arn]
      }
    }
    data "aws_getcalleridentity" "current" {
    }
    
    resource "aws_lambda_resourcepolicy" "example" {
      resource_arn = exampleAwsLambdaFunction.arn
      policy       = data.aws_iam_getpolicydocument.example.json
    }
    

    Multiple Principals

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.iam.getPolicyDocument({
        statements: [
            {
                principals: [{
                    type: "AWS",
                    identifiers: [
                        "123456789012",
                        "210987654321",
                    ],
                }],
                sid: "AllowCrossAccountInvoke",
                effect: "Allow",
                actions: ["lambda:InvokeFunction"],
                resources: [exampleAwsLambdaFunction.arn],
            },
            {
                conditions: [{
                    test: "StringEquals",
                    variable: "aws:PrincipalOrgID",
                    values: ["o-1234567890"],
                }],
                principals: [{
                    type: "AWS",
                    identifiers: ["*"],
                }],
                sid: "AllowOrganizationInvoke",
                effect: "Allow",
                actions: ["lambda:InvokeFunction"],
                resources: [exampleAwsLambdaFunction.arn],
            },
        ],
    });
    const exampleResourcePolicy = new aws.lambda.ResourcePolicy("example", {
        resourceArn: exampleAwsLambdaFunction.arn,
        policy: example.then(example => example.json),
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.iam.get_policy_document(statements=[
        {
            "principals": [{
                "type": "AWS",
                "identifiers": [
                    "123456789012",
                    "210987654321",
                ],
            }],
            "sid": "AllowCrossAccountInvoke",
            "effect": "Allow",
            "actions": ["lambda:InvokeFunction"],
            "resources": [example_aws_lambda_function["arn"]],
        },
        {
            "conditions": [{
                "test": "StringEquals",
                "variable": "aws:PrincipalOrgID",
                "values": ["o-1234567890"],
            }],
            "principals": [{
                "type": "AWS",
                "identifiers": ["*"],
            }],
            "sid": "AllowOrganizationInvoke",
            "effect": "Allow",
            "actions": ["lambda:InvokeFunction"],
            "resources": [example_aws_lambda_function["arn"]],
        },
    ])
    example_resource_policy = aws.lambda_.ResourcePolicy("example",
        resource_arn=example_aws_lambda_function["arn"],
        policy=example.json)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    			Statements: []iam.GetPolicyDocumentStatement{
    				{
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Type: "AWS",
    							Identifiers: []string{
    								"123456789012",
    								"210987654321",
    							},
    						},
    					},
    					Sid:    pulumi.StringRef("AllowCrossAccountInvoke"),
    					Effect: pulumi.StringRef("Allow"),
    					Actions: []string{
    						"lambda:InvokeFunction",
    					},
    					Resources: pulumi.StringArray{
    						exampleAwsLambdaFunction.Arn,
    					},
    				},
    				{
    					Conditions: []iam.GetPolicyDocumentStatementCondition{
    						{
    							Test:     "StringEquals",
    							Variable: "aws:PrincipalOrgID",
    							Values: []string{
    								"o-1234567890",
    							},
    						},
    					},
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Type: "AWS",
    							Identifiers: []string{
    								"*",
    							},
    						},
    					},
    					Sid:    pulumi.StringRef("AllowOrganizationInvoke"),
    					Effect: pulumi.StringRef("Allow"),
    					Actions: []string{
    						"lambda:InvokeFunction",
    					},
    					Resources: pulumi.StringArray{
    						exampleAwsLambdaFunction.Arn,
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = lambda.NewResourcePolicy(ctx, "example", &lambda.ResourcePolicyArgs{
    			ResourceArn: pulumi.Any(exampleAwsLambdaFunction.Arn),
    			Policy:      pulumi.String(example.Json),
    		})
    		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.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "123456789012",
                                "210987654321",
                            },
                        },
                    },
                    Sid = "AllowCrossAccountInvoke",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "lambda:InvokeFunction",
                    },
                    Resources = new[]
                    {
                        exampleAwsLambdaFunction.Arn,
                    },
                },
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "StringEquals",
                            Variable = "aws:PrincipalOrgID",
                            Values = new[]
                            {
                                "o-1234567890",
                            },
                        },
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "*",
                            },
                        },
                    },
                    Sid = "AllowOrganizationInvoke",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "lambda:InvokeFunction",
                    },
                    Resources = new[]
                    {
                        exampleAwsLambdaFunction.Arn,
                    },
                },
            },
        });
    
        var exampleResourcePolicy = new Aws.Lambda.ResourcePolicy("example", new()
        {
            ResourceArn = exampleAwsLambdaFunction.Arn,
            Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
    });
    
    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.GetPolicyDocumentArgs;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
    import com.pulumi.aws.lambda.ResourcePolicy;
    import com.pulumi.aws.lambda.ResourcePolicyArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(            
                    GetPolicyDocumentStatementArgs.builder()
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers(                        
                                "123456789012",
                                "210987654321")
                            .build())
                        .sid("AllowCrossAccountInvoke")
                        .effect("Allow")
                        .actions("lambda:InvokeFunction")
                        .resources(exampleAwsLambdaFunction.arn())
                        .build(),
                    GetPolicyDocumentStatementArgs.builder()
                        .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                            .test("StringEquals")
                            .variable("aws:PrincipalOrgID")
                            .values("o-1234567890")
                            .build())
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers("*")
                            .build())
                        .sid("AllowOrganizationInvoke")
                        .effect("Allow")
                        .actions("lambda:InvokeFunction")
                        .resources(exampleAwsLambdaFunction.arn())
                        .build())
                .build());
    
            var exampleResourcePolicy = new ResourcePolicy("exampleResourcePolicy", ResourcePolicyArgs.builder()
                .resourceArn(exampleAwsLambdaFunction.arn())
                .policy(example.json())
                .build());
    
        }
    }
    
    resources:
      exampleResourcePolicy:
        type: aws:lambda:ResourcePolicy
        name: example
        properties:
          resourceArn: ${exampleAwsLambdaFunction.arn}
          policy: ${example.json}
    variables:
      example:
        fn::invoke:
          function: aws:iam:getPolicyDocument
          arguments:
            statements:
              - principals:
                  - type: AWS
                    identifiers:
                      - '123456789012'
                      - '210987654321'
                sid: AllowCrossAccountInvoke
                effect: Allow
                actions:
                  - lambda:InvokeFunction
                resources:
                  - ${exampleAwsLambdaFunction.arn}
              - conditions:
                  - test: StringEquals
                    variable: aws:PrincipalOrgID
                    values:
                      - o-1234567890
                principals:
                  - type: AWS
                    identifiers:
                      - '*'
                sid: AllowOrganizationInvoke
                effect: Allow
                actions:
                  - lambda:InvokeFunction
                resources:
                  - ${exampleAwsLambdaFunction.arn}
    
    pulumi {
      required_providers {
        aws = {
          source = "pulumi/aws"
        }
      }
    }
    
    data "aws_iam_getpolicydocument" "example" {
      statements {
        principals {
          type        = "AWS"
          identifiers = ["123456789012", "210987654321"]
        }
        sid       = "AllowCrossAccountInvoke"
        effect    = "Allow"
        actions   = ["lambda:InvokeFunction"]
        resources = [exampleAwsLambdaFunction.arn]
      }
      statements {
        conditions {
          test     = "StringEquals"
          variable = "aws:PrincipalOrgID"
          values   = ["o-1234567890"]
        }
        principals {
          type        = "AWS"
          identifiers = ["*"]
        }
        sid       = "AllowOrganizationInvoke"
        effect    = "Allow"
        actions   = ["lambda:InvokeFunction"]
        resources = [exampleAwsLambdaFunction.arn]
      }
    }
    
    resource "aws_lambda_resourcepolicy" "example" {
      resource_arn = exampleAwsLambdaFunction.arn
      policy       = data.aws_iam_getpolicydocument.example.json
    }
    

    Create ResourcePolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ResourcePolicy(name: string, args: ResourcePolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ResourcePolicy(resource_name: str,
                       args: ResourcePolicyArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def ResourcePolicy(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       policy: Optional[str] = None,
                       resource_arn: Optional[str] = None,
                       region: Optional[str] = None)
    func NewResourcePolicy(ctx *Context, name string, args ResourcePolicyArgs, opts ...ResourceOption) (*ResourcePolicy, error)
    public ResourcePolicy(string name, ResourcePolicyArgs args, CustomResourceOptions? opts = null)
    public ResourcePolicy(String name, ResourcePolicyArgs args)
    public ResourcePolicy(String name, ResourcePolicyArgs args, CustomResourceOptions options)
    
    type: aws:lambda:ResourcePolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "aws_lambda_resource_policy" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args ResourcePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ResourcePolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ResourcePolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ResourcePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ResourcePolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var exampleresourcePolicyResourceResourceFromLambdaresourcePolicy = new Aws.Lambda.ResourcePolicy("exampleresourcePolicyResourceResourceFromLambdaresourcePolicy", new()
    {
        Policy = "string",
        ResourceArn = "string",
        Region = "string",
    });
    
    example, err := lambda.NewResourcePolicy(ctx, "exampleresourcePolicyResourceResourceFromLambdaresourcePolicy", &lambda.ResourcePolicyArgs{
    	Policy:      pulumi.String("string"),
    	ResourceArn: pulumi.String("string"),
    	Region:      pulumi.String("string"),
    })
    
    resource "aws_lambda_resource_policy" "exampleresourcePolicyResourceResourceFromLambdaresourcePolicy" {
      lifecycle {
        create_before_destroy = true
      }
      policy       = "string"
      resource_arn = "string"
      region       = "string"
    }
    
    var exampleresourcePolicyResourceResourceFromLambdaresourcePolicy = new com.pulumi.aws.lambda.ResourcePolicy("exampleresourcePolicyResourceResourceFromLambdaresourcePolicy", com.pulumi.aws.lambda.ResourcePolicyArgs.builder()
        .policy("string")
        .resourceArn("string")
        .region("string")
        .build());
    
    exampleresource_policy_resource_resource_from_lambdaresource_policy = aws.lambda_.ResourcePolicy("exampleresourcePolicyResourceResourceFromLambdaresourcePolicy",
        policy="string",
        resource_arn="string",
        region="string")
    
    const exampleresourcePolicyResourceResourceFromLambdaresourcePolicy = new aws.lambda.ResourcePolicy("exampleresourcePolicyResourceResourceFromLambdaresourcePolicy", {
        policy: "string",
        resourceArn: "string",
        region: "string",
    });
    
    type: aws:lambda:ResourcePolicy
    properties:
        policy: string
        region: string
        resourceArn: string
    

    ResourcePolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ResourcePolicy resource accepts the following input properties:

    Policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    ResourceArn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    Policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    ResourceArn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    resource_arn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    policy String
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    resourceArn String
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    resourceArn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    policy str
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    resource_arn str
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    policy String
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    resourceArn String
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ResourcePolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    RevisionId string
    Unique identifier for the current revision of the policy.
    Id string
    The provider-assigned unique ID for this managed resource.
    RevisionId string
    Unique identifier for the current revision of the policy.
    id string
    The provider-assigned unique ID for this managed resource.
    revision_id string
    Unique identifier for the current revision of the policy.
    id String
    The provider-assigned unique ID for this managed resource.
    revisionId String
    Unique identifier for the current revision of the policy.
    id string
    The provider-assigned unique ID for this managed resource.
    revisionId string
    Unique identifier for the current revision of the policy.
    id str
    The provider-assigned unique ID for this managed resource.
    revision_id str
    Unique identifier for the current revision of the policy.
    id String
    The provider-assigned unique ID for this managed resource.
    revisionId String
    Unique identifier for the current revision of the policy.

    Look up Existing ResourcePolicy Resource

    Get an existing ResourcePolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ResourcePolicyState, opts?: CustomResourceOptions): ResourcePolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy: Optional[str] = None,
            region: Optional[str] = None,
            resource_arn: Optional[str] = None,
            revision_id: Optional[str] = None) -> ResourcePolicy
    func GetResourcePolicy(ctx *Context, name string, id IDInput, state *ResourcePolicyState, opts ...ResourceOption) (*ResourcePolicy, error)
    public static ResourcePolicy Get(string name, Input<string> id, ResourcePolicyState? state, CustomResourceOptions? opts = null)
    public static ResourcePolicy get(String name, Output<String> id, ResourcePolicyState state, CustomResourceOptions options)
    resources:  _:    type: aws:lambda:ResourcePolicy    get:      id: ${id}
    import {
      to = aws_lambda_resource_policy.example
      id = "${id}"
    }
    
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    ResourceArn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    RevisionId string
    Unique identifier for the current revision of the policy.
    Policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    ResourceArn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    RevisionId string
    Unique identifier for the current revision of the policy.
    policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    resource_arn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    revision_id string
    Unique identifier for the current revision of the policy.
    policy String
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    resourceArn String
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    revisionId String
    Unique identifier for the current revision of the policy.
    policy string
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    resourceArn string
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    revisionId string
    Unique identifier for the current revision of the policy.
    policy str
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    resource_arn str
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    revision_id str
    Unique identifier for the current revision of the policy.
    policy String
    JSON-formatted resource-based policy document to attach to the Lambda resource. This replaces the entire policy on the resource. Maximum 20,480 characters.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    resourceArn String
    ARN of the Lambda function, function version, or function alias to attach the policy to. Can be a qualified or unqualified ARN.
    revisionId String
    Unique identifier for the current revision of the policy.

    Import

    Identity Schema

    Required

    • resourceArn (String) ARN of the Lambda function, function version, or function alias.

    Using pulumi import, import Lambda policies using the resourceArn. For example:

    $ pulumi import aws:lambda/resourcePolicy:ResourcePolicy example arn:aws:lambda:us-east-1:123456789012:function:example
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo aws logo
    Viewing docs for AWS v7.48.0
    published on Tuesday, Sep 22, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial