We recommend new projects start with resources from the AWS provider.
published on Monday, Sep 14, 2026 by Pulumi
We recommend new projects start with resources from the AWS provider.
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:
- Set a
Retaindeletion policy on theAWS::Lambda::Permissionresources you want to migrate. This is necessary so that Lambda does not delete statements with the same statement ID when you delete these resources. - Use the GetResourcePolicyLAM API to retrieve the resource-based policy currently attached to the function.
- Use this policy to create a new
AWS::Lambda::ResourcePolicyresource. - Delete all the existing
AWS::Lambda::Permissionresources for the function.
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_document: Optional[Any] = None,
resource_arn: 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-native:lambda:ResourcePolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "aws-native_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.
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
Document 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
- Policy
Document 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
- 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
- policy
Document 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
- 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
- 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
- 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::ResourcePolicyfor more information about the expected schema for this property.- 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.
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.
- Id string
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Package Details
- Repository
- AWS Native pulumi/pulumi-aws-native
- License
- Apache-2.0
We recommend new projects start with resources from the AWS provider.
published on Monday, Sep 14, 2026 by Pulumi