Class CfnPermission
- All Implemented Interfaces:
IInspectable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
AWS::Lambda::Permission
resource grants an AWS service or another account permission to use a function.
You can apply the policy at the function level, or specify a qualifier to restrict access to a single version or alias. If you use a qualifier, the invoker must use the full Amazon Resource Name (ARN) of that version or alias to invoke the function.
To grant permission to another account, specify the account ID as the Principal
. To grant permission to an organization defined in AWS Organizations , specify the organization ID as the PrincipalOrgID
. For AWS services, the principal is a domain-style identifier defined by the service, like s3.amazonaws.com
or sns.amazonaws.com
. For AWS services, you can also specify the ARN of the associated resource as the SourceArn
. If you grant permission to a service principal without specifying the source, other accounts could potentially configure resources in their account to invoke your Lambda function.
If your function has a function URL, you can specify the FunctionUrlAuthType
parameter. This adds a condition to your permission that only applies when your function URL's AuthType
matches the specified FunctionUrlAuthType
. For more information about the AuthType
parameter, see Security and auth model for Lambda function URLs .
This resource adds a statement to a resource-based permission policy for the function. For more information about function policies, see Lambda Function Policies .
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.lambda.*; CfnPermission cfnPermission = CfnPermission.Builder.create(this, "MyCfnPermission") .action("action") .functionName("functionName") .principal("principal") // the properties below are optional .eventSourceToken("eventSourceToken") .functionUrlAuthType("functionUrlAuthType") .principalOrgId("principalOrgId") .sourceAccount("sourceAccount") .sourceArn("sourceArn") .build();
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionprotected
CfnPermission
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnPermission
(software.amazon.jsii.JsiiObjectRef objRef) CfnPermission
(software.constructs.Construct scope, String id, CfnPermissionProps props) -
Method Summary
Modifier and TypeMethodDescriptionThe action that the principal can use on the function.For Alexa Smart Home functions, a token that the invoker must supply.The name or ARN of the Lambda function, version, or alias.The type of authentication that your function URL uses.The AWS service , AWS account , IAM user, or IAM role that invokes the function.The identifier for your organization in AWS Organizations .For AWS service , the ID of the AWS account that owns the resource.For AWS services , the ARN of the AWS resource that invokes the function.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
The action that the principal can use on the function.void
setEventSourceToken
(String value) For Alexa Smart Home functions, a token that the invoker must supply.void
setFunctionName
(String value) The name or ARN of the Lambda function, version, or alias.void
setFunctionUrlAuthType
(String value) The type of authentication that your function URL uses.void
setPrincipal
(String value) The AWS service , AWS account , IAM user, or IAM role that invokes the function.void
setPrincipalOrgId
(String value) The identifier for your organization in AWS Organizations .void
setSourceAccount
(String value) For AWS service , the ID of the AWS account that owns the resource.void
setSourceArn
(String value) For AWS services , the ARN of the AWS resource that invokes the function.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnPermission
protected CfnPermission(software.amazon.jsii.JsiiObjectRef objRef) -
CfnPermission
protected CfnPermission(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnPermission
@Stability(Stable) public CfnPermission(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnPermissionProps props) - Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.props
- Resource properties. This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrId
-
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getAction
The action that the principal can use on the function. -
setAction
The action that the principal can use on the function. -
getFunctionName
The name or ARN of the Lambda function, version, or alias. -
setFunctionName
The name or ARN of the Lambda function, version, or alias. -
getPrincipal
The AWS service , AWS account , IAM user, or IAM role that invokes the function. -
setPrincipal
The AWS service , AWS account , IAM user, or IAM role that invokes the function. -
getEventSourceToken
For Alexa Smart Home functions, a token that the invoker must supply. -
setEventSourceToken
For Alexa Smart Home functions, a token that the invoker must supply. -
getFunctionUrlAuthType
The type of authentication that your function URL uses. -
setFunctionUrlAuthType
The type of authentication that your function URL uses. -
getPrincipalOrgId
The identifier for your organization in AWS Organizations . -
setPrincipalOrgId
The identifier for your organization in AWS Organizations . -
getSourceAccount
For AWS service , the ID of the AWS account that owns the resource. -
setSourceAccount
For AWS service , the ID of the AWS account that owns the resource. -
getSourceArn
For AWS services , the ARN of the AWS resource that invokes the function. -
setSourceArn
For AWS services , the ARN of the AWS resource that invokes the function.
-