CfnResourcePolicyPropsMixin
- class aws_cdk.cfn_property_mixins.aws_lambda.CfnResourcePolicyPropsMixin(props, *, strategy=None)
Bases:
MixinUse the
AWS::Lambda::ResourcePolicyresource 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::ResourcePolicyresource, 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 theAWS::Lambda::ResourcePolicyresource to set access permissions. With this resource, you have more flexibility and fine-grained control thanAWS::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 theAWS::Lambda::Permissionresource, however using bothAWS::Lambda::PermissionandAWS::Lambda::ResourcePolicyto set permissions on a function can result in errors. Permissions defined inAWS::Lambda::Permissioncan 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 fromAWS::Lambda::PermissiontoAWS::Lambda::ResourcePolicy, do the following:Set a
Retain```deletion policy <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html>`_ on the ``AWS::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 `GetResourcePolicy <https://docs.aws.amazon.com/lambda/latest/api/API_GetResourcePolicy.html>`_LAM 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.
- See:
- CloudformationResource:
AWS::Lambda::ResourcePolicy
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.cfn_property_mixins import aws_lambda as lambda_ import aws_cdk as cdk # merge_strategy: cdk.IMergeStrategy # policy_document: Any cfn_resource_policy_props_mixin = lambda_.CfnResourcePolicyPropsMixin(lambda.CfnResourcePolicyMixinProps( policy_document=policy_document, resource_arn="resourceArn" ), strategy=merge_strategy )
Create a mixin to apply properties to
AWS::Lambda::ResourcePolicy.- Parameters:
props (
Union[CfnResourcePolicyMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[IMergeStrategy]) – Strategy for merging nested properties. Default: - PropertyMergeStrategy.combine()
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
None
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['policyDocument', 'resourceArn']
Static Methods
- classmethod is_mixin(x)
Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.