Class CfnPermission
- All Implemented Interfaces:
IConstruct,IDependable,IInspectable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
AWS::Lambda::Permission.
The 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();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCfnPermission(Construct scope, String id, CfnPermissionProps props) Create a newAWS::Lambda::Permission.protectedCfnPermission(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnPermission(software.amazon.jsii.JsiiObjectRef objRef) -
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 of the Lambda function, version, or alias.The type of authentication that your function URL uses.The AWS service or AWS account 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.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidThe action that the principal can use on the function.voidsetEventSourceToken(String value) For Alexa Smart Home functions, a token that the invoker must supply.voidsetFunctionName(String value) The name of the Lambda function, version, or alias.voidsetFunctionUrlAuthType(String value) The type of authentication that your function URL uses.voidsetPrincipal(String value) The AWS service or AWS account that invokes the function.voidsetPrincipalOrgId(String value) The identifier for your organization in AWS Organizations .voidsetSourceAccount(String value) For AWS service , the ID of the AWS account that owns the resource.voidsetSourceArn(String value) For AWS services , the ARN of the AWS resource that invokes the function.Methods inherited from class software.amazon.awscdk.core.CfnResource
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.core.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.core.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 Construct scope, @NotNull String id, @NotNull CfnPermissionProps props) Create a newAWS::Lambda::Permission.- Parameters:
scope-- scope in which this resource is defined.
id-- scoped id of the resource.
props-- resource properties.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector-- tree inspector to collect and process attributes.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getAction
The action that the principal can use on the function.For example,
lambda:InvokeFunctionorlambda:GetFunction. -
setAction
The action that the principal can use on the function.For example,
lambda:InvokeFunctionorlambda:GetFunction. -
getFunctionName
The name of the Lambda function, version, or alias.Name formats - Function name –
my-function(name-only),my-function:v1(with alias).- Function ARN –
arn:aws:lambda:us-west-2:123456789012:function:my-function. - Partial ARN –
123456789012:function:my-function.
You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.
- Function ARN –
-
setFunctionName
The name of the Lambda function, version, or alias.Name formats - Function name –
my-function(name-only),my-function:v1(with alias).- Function ARN –
arn:aws:lambda:us-west-2:123456789012:function:my-function. - Partial ARN –
123456789012:function:my-function.
You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.
- Function ARN –
-
getPrincipal
The AWS service or AWS account that invokes the function.If you specify a service, use
SourceArnorSourceAccountto limit who can invoke the function through that service. -
setPrincipal
The AWS service or AWS account that invokes the function.If you specify a service, use
SourceArnorSourceAccountto limit who can invoke the function through that service. -
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.Set to
AWS_IAMif you want to restrict access to authenticated users only. Set toNONEif you want to bypass IAM authentication to create a public endpoint. For more information, see Security and auth model for Lambda function URLs . -
setFunctionUrlAuthType
The type of authentication that your function URL uses.Set to
AWS_IAMif you want to restrict access to authenticated users only. Set toNONEif you want to bypass IAM authentication to create a public endpoint. For more information, see Security and auth model for Lambda function URLs . -
getPrincipalOrgId
The identifier for your organization in AWS Organizations .Use this to grant permissions to all the AWS accounts under this organization.
-
setPrincipalOrgId
The identifier for your organization in AWS Organizations .Use this to grant permissions to all the AWS accounts under this organization.
-
getSourceAccount
For AWS service , the ID of the AWS account that owns the resource.Use this together with
SourceArnto ensure that the specified account owns the resource. It is possible for an Amazon S3 bucket to be deleted by its owner and recreated by another account. -
setSourceAccount
For AWS service , the ID of the AWS account that owns the resource.Use this together with
SourceArnto ensure that the specified account owns the resource. It is possible for an Amazon S3 bucket to be deleted by its owner and recreated by another account. -
getSourceArn
For AWS services , the ARN of the AWS resource that invokes the function.For example, an Amazon S3 bucket or Amazon SNS topic.
Note that Lambda configures the comparison using the
StringLikeoperator. -
setSourceArn
For AWS services , the ARN of the AWS resource that invokes the function.For example, an Amazon S3 bucket or Amazon SNS topic.
Note that Lambda configures the comparison using the
StringLikeoperator.
-