package awslambda import ( _init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii" _jsii_ "github.com/aws/jsii-runtime-go/runtime" "github.com/aws/aws-cdk-go/awscdk/v2" "github.com/aws/aws-cdk-go/awscdk/v2/awsecr" "github.com/aws/aws-cdk-go/awscdk/v2/awss3" "github.com/aws/aws-cdk-go/awscdk/v2/awss3assets" "github.com/aws/constructs-go/constructs/v10" ) // Lambda code from a local directory. // // Example: // // Lambda function containing logic that evaluates compliance with the rule. // evalComplianceFn := lambda.NewFunction(this, jsii.String("CustomFunction"), &FunctionProps{ // Code: lambda.AssetCode_FromInline(jsii.String("exports.handler = (event) => console.log(event);")), // Handler: jsii.String("index.handler"), // Runtime: lambda.Runtime_NODEJS_18_X(), // }) // // // A custom rule that runs on configuration changes of EC2 instances // customRule := config.NewCustomRule(this, jsii.String("Custom"), &CustomRuleProps{ // ConfigurationChanges: jsii.Boolean(true), // LambdaFunction: evalComplianceFn, // RuleScope: config.RuleScope_FromResource(config.ResourceType_EC2_INSTANCE()), // }) // // // A rule to detect stack drifts // driftRule := config.NewCloudFormationStackDriftDetectionCheck(this, jsii.String("Drift")) // // // Topic to which compliance notification events will be published // complianceTopic := sns.NewTopic(this, jsii.String("ComplianceTopic")) // // // Send notification on compliance change events // driftRule.onComplianceChange(jsii.String("ComplianceChange"), &OnEventOptions{ // Target: targets.NewSnsTopic(complianceTopic), // }) // type AssetCode interface { Code // Determines whether this Code is inline code or not. IsInline() *bool // The path to the asset file or directory. Path() *string // Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. Bind(scope constructs.Construct) *CodeConfig // 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. BindToResource(resource awscdk.CfnResource, options *ResourceBindOptions) } // The jsii proxy struct for AssetCode type jsiiProxy_AssetCode struct { jsiiProxy_Code } func (j *jsiiProxy_AssetCode) IsInline() *bool { var returns *bool _jsii_.Get( j, "isInline", &returns, ) return returns } func (j *jsiiProxy_AssetCode) Path() *string { var returns *string _jsii_.Get( j, "path", &returns, ) return returns } func NewAssetCode(path *string, options *awss3assets.AssetOptions) AssetCode { _init_.Initialize() if err := validateNewAssetCodeParameters(path, options); err != nil { panic(err) } j := jsiiProxy_AssetCode{} _jsii_.Create( "aws-cdk-lib.aws_lambda.AssetCode", []interface{}{path, options}, &j, ) return &j } func NewAssetCode_Override(a AssetCode, path *string, options *awss3assets.AssetOptions) { _init_.Initialize() _jsii_.Create( "aws-cdk-lib.aws_lambda.AssetCode", []interface{}{path, options}, a, ) } // Loads the function code from a local disk path. func AssetCode_FromAsset(path *string, options *awss3assets.AssetOptions) AssetCode { _init_.Initialize() if err := validateAssetCode_FromAssetParameters(path, options); err != nil { panic(err) } var returns AssetCode _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromAsset", []interface{}{path, options}, &returns, ) return returns } // Create an ECR image from the specified asset and bind it as the Lambda code. func AssetCode_FromAssetImage(directory *string, props *AssetImageCodeProps) AssetImageCode { _init_.Initialize() if err := validateAssetCode_FromAssetImageParameters(directory, props); err != nil { panic(err) } var returns AssetImageCode _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromAssetImage", []interface{}{directory, props}, &returns, ) return returns } // Lambda handler code as an S3 object. func AssetCode_FromBucket(bucket awss3.IBucket, key *string, objectVersion *string) S3Code { _init_.Initialize() if err := validateAssetCode_FromBucketParameters(bucket, key); err != nil { panic(err) } var returns S3Code _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromBucket", []interface{}{bucket, key, objectVersion}, &returns, ) return returns } // Creates a new Lambda source defined using CloudFormation parameters. // // Returns: a new instance of `CfnParametersCode`. func AssetCode_FromCfnParameters(props *CfnParametersCodeProps) CfnParametersCode { _init_.Initialize() if err := validateAssetCode_FromCfnParametersParameters(props); err != nil { panic(err) } var returns CfnParametersCode _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromCfnParameters", []interface{}{props}, &returns, ) return returns } // Loads the function code from an asset created by a Docker build. // // By default, the asset is expected to be located at `/asset` in the // image. func AssetCode_FromDockerBuild(path *string, options *DockerBuildAssetOptions) AssetCode { _init_.Initialize() if err := validateAssetCode_FromDockerBuildParameters(path, options); err != nil { panic(err) } var returns AssetCode _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromDockerBuild", []interface{}{path, options}, &returns, ) return returns } // Use an existing ECR image as the Lambda code. func AssetCode_FromEcrImage(repository awsecr.IRepository, props *EcrImageCodeProps) EcrImageCode { _init_.Initialize() if err := validateAssetCode_FromEcrImageParameters(repository, props); err != nil { panic(err) } var returns EcrImageCode _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromEcrImage", []interface{}{repository, props}, &returns, ) return returns } // Inline code for Lambda handler. // // Returns: `LambdaInlineCode` with inline code. func AssetCode_FromInline(code *string) InlineCode { _init_.Initialize() if err := validateAssetCode_FromInlineParameters(code); err != nil { panic(err) } var returns InlineCode _jsii_.StaticInvoke( "aws-cdk-lib.aws_lambda.AssetCode", "fromInline", []interface{}{code}, &returns, ) return returns } func (a *jsiiProxy_AssetCode) Bind(scope constructs.Construct) *CodeConfig { if err := a.validateBindParameters(scope); err != nil { panic(err) } var returns *CodeConfig _jsii_.Invoke( a, "bind", []interface{}{scope}, &returns, ) return returns } func (a *jsiiProxy_AssetCode) BindToResource(resource awscdk.CfnResource, options *ResourceBindOptions) { if err := a.validateBindToResourceParameters(resource, options); err != nil { panic(err) } _jsii_.InvokeVoid( a, "bindToResource", []interface{}{resource, options}, ) }