Class AssetCode
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.lambda.Code
software.amazon.awscdk.services.lambda.AssetCode
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.106.0 (build e852934)",
date="2025-02-05T22:42:06.326Z")
@Stability(Stable)
public class AssetCode
extends Code
Lambda code from a local directory.
Example:
// Lambda function containing logic that evaluates compliance with the rule. Function evalComplianceFn = Function.Builder.create(this, "CustomFunction") .code(AssetCode.fromInline("exports.handler = (event) => console.log(event);")) .handler("index.handler") .runtime(Runtime.NODEJS_18_X) .build(); // A custom rule that runs on configuration changes of EC2 instances CustomRule customRule = CustomRule.Builder.create(this, "Custom") .configurationChanges(true) .lambdaFunction(evalComplianceFn) .ruleScope(RuleScope.fromResource(ResourceType.EC2_INSTANCE)) .build(); // A rule to detect stack drifts CloudFormationStackDriftDetectionCheck driftRule = new CloudFormationStackDriftDetectionCheck(this, "Drift"); // Topic to which compliance notification events will be published Topic complianceTopic = new Topic(this, "ComplianceTopic"); // Send notification on compliance change events driftRule.onComplianceChange("ComplianceChange", OnEventOptions.builder() .target(new SnsTopic(complianceTopic)) .build());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbind
(software.constructs.Construct scope) Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.void
bindToResource
(CfnResource resource) Called after the CFN function resource has been created to allow the code class to bind to it.void
bindToResource
(CfnResource resource, ResourceBindOptions options) Called after the CFN function resource has been created to allow the code class to bind to it.Determines whether this Code is inline code or not.getPath()
The path to the asset file or directory.Methods inherited from class software.amazon.awscdk.services.lambda.Code
fromAsset, fromAsset, fromAssetImage, fromAssetImage, fromBucket, fromBucket, fromBucketV2, fromBucketV2, fromCfnParameters, fromCfnParameters, fromCustomCommand, fromCustomCommand, fromDockerBuild, fromDockerBuild, fromEcrImage, fromEcrImage, fromInline
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, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
AssetCode
protected AssetCode(software.amazon.jsii.JsiiObjectRef objRef) -
AssetCode
protected AssetCode(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
AssetCode
- Parameters:
path
- The path to the asset file or directory. This parameter is required.options
-
-
AssetCode
- Parameters:
path
- The path to the asset file or directory. This parameter is required.
-
-
Method Details
-
bind
Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. -
bindToResource
@Stability(Stable) public void bindToResource(@NotNull CfnResource resource, @Nullable ResourceBindOptions options) Called after the CFN function resource has been created to allow the code class to bind to it.Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
- Overrides:
bindToResource
in classCode
- Parameters:
resource
- This parameter is required.options
-
-
bindToResource
Called after the CFN function resource has been created to allow the code class to bind to it.Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
- Overrides:
bindToResource
in classCode
- Parameters:
resource
- This parameter is required.
-
getIsInline
Determines whether this Code is inline code or not. -
getPath
The path to the asset file or directory.
-