awscdks3objectlambdaalpha

package module
v2.241.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

AWS::S3ObjectLambda Construct Library

---

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


This construct library allows you to define S3 object lambda access points.

import "github.com/aws/aws-cdk-go/awscdk"
import s3 "github.com/aws/aws-cdk-go/awscdk"
import s3objectlambda "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"
import cdk "github.com/aws/aws-cdk-go/awscdk"

stack := cdk.NewStack()
bucket := s3.NewBucket(stack, jsii.String("MyBucket"))
handler := lambda.NewFunction(stack, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(jsii.String("lambda.zip")),
})
s3objectlambda.NewAccessPoint(stack, jsii.String("MyObjectLambda"), &AccessPointProps{
	Bucket: Bucket,
	Handler: Handler,
	AccessPointName: jsii.String("my-access-point"),
	Payload: map[string]interface{}{
		"prop": jsii.String("value"),
	},
})

Handling range and part number requests

Lambdas are currently limited to only transforming GetObject requests. However, they can additionally support GetObject-Range and GetObject-PartNumber requests, which needs to be specified in the access point configuration:

import "github.com/aws/aws-cdk-go/awscdk"
import s3 "github.com/aws/aws-cdk-go/awscdk"
import s3objectlambda "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"
import cdk "github.com/aws/aws-cdk-go/awscdk"

stack := cdk.NewStack()
bucket := s3.NewBucket(stack, jsii.String("MyBucket"))
handler := lambda.NewFunction(stack, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(jsii.String("lambda.zip")),
})
s3objectlambda.NewAccessPoint(stack, jsii.String("MyObjectLambda"), &AccessPointProps{
	Bucket: Bucket,
	Handler: Handler,
	AccessPointName: jsii.String("my-access-point"),
	SupportsGetObjectRange: jsii.Boolean(true),
	SupportsGetObjectPartNumber: jsii.Boolean(true),
})

Pass additional data to Lambda function

You can specify an additional object that provides supplemental data to the Lambda function used to transform objects. The data is delivered as a JSON payload to the Lambda:

import "github.com/aws/aws-cdk-go/awscdk"
import s3 "github.com/aws/aws-cdk-go/awscdk"
import s3objectlambda "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"
import cdk "github.com/aws/aws-cdk-go/awscdk"

stack := cdk.NewStack()
bucket := s3.NewBucket(stack, jsii.String("MyBucket"))
handler := lambda.NewFunction(stack, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(jsii.String("lambda.zip")),
})
s3objectlambda.NewAccessPoint(stack, jsii.String("MyObjectLambda"), &AccessPointProps{
	Bucket: Bucket,
	Handler: Handler,
	AccessPointName: jsii.String("my-access-point"),
	Payload: map[string]interface{}{
		"prop": jsii.String("value"),
	},
})

Accessing the S3 AccessPoint ARN

If you need access to the s3 accesspoint, you can get its ARN like so:

import s3objectlambda "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"

var accessPoint AccessPoint
s3AccessPointArn := accessPoint.S3AccessPointArn

This is only supported for AccessPoints created in the stack - currently you're unable to get the S3 AccessPoint ARN for imported AccessPoints. To do that you'd have to know the S3 bucket name beforehand.

Documentation

Overview

The CDK Construct Library for AWS::S3ObjectLambda

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessPoint_IsConstruct

func AccessPoint_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func AccessPoint_IsOwnedResource

func AccessPoint_IsOwnedResource(construct constructs.IConstruct) *bool

Returns true if the construct was created by CDK, and false otherwise. Experimental.

func AccessPoint_IsResource

func AccessPoint_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func AccessPoint_PROPERTY_INJECTION_ID

func AccessPoint_PROPERTY_INJECTION_ID() *string

func NewAccessPoint_Override

func NewAccessPoint_Override(a AccessPoint, scope constructs.Construct, id *string, props *AccessPointProps)

Experimental.

Types

type AccessPoint

type AccessPoint interface {
	awscdk.Resource
	IAccessPoint
	// The ARN of the access point.
	// Experimental.
	AccessPointArn() *string
	// The creation data of the access point.
	// Experimental.
	AccessPointCreationDate() *string
	// The ARN of the access point.
	// Experimental.
	AccessPointName() *string
	// Implement the `IAccessPoint.domainName` field.
	// Experimental.
	DomainName() *string
	// The environment this resource belongs to.
	//
	// For resources that are created and managed in a Stack (those created by
	// creating new class instances like `new Role()`, `new Bucket()`, etc.), this
	// is always the same as the environment of the stack they belong to.
	//
	// For referenced resources (those obtained from referencing methods like
	// `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
	// different than the stack they were imported into.
	// Experimental.
	Env() *interfaces.ResourceEnvironment
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
	//
	// This value will resolve to one of the following:
	// - a concrete value (e.g. `"my-awesome-bucket"`)
	// - `undefined`, when a name should be generated by CloudFormation
	// - a concrete name generated automatically during synthesis, in
	//   cross-environment scenarios.
	// Experimental.
	PhysicalName() *string
	// Implement the `IAccessPoint.regionalDomainName` field.
	// Experimental.
	RegionalDomainName() *string
	// The ARN of the S3 access point.
	// Experimental.
	S3AccessPointArn() *string
	// The stack in which this resource is defined.
	// Experimental.
	Stack() awscdk.Stack
	// Apply the given removal policy to this resource.
	//
	// The Removal Policy controls what happens to this resource when it stops
	// being managed by CloudFormation, either because you've removed it from the
	// CDK application or because you've made a change that requires the resource
	// to be replaced.
	//
	// The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
	// account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
	// Experimental.
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	// Experimental.
	GeneratePhysicalName() *string
	// Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`).
	//
	// Normally, this token will resolve to `arnAttr`, but if the resource is
	// referenced across environments, `arnComponents` will be used to synthesize
	// a concrete ARN with the resource's physical name. Make sure to reference
	// `this.physicalName` in `arnComponents`.
	// Experimental.
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	// Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`).
	//
	// Normally, this token will resolve to `nameAttr`, but if the resource is
	// referenced across environments, it will be resolved to `this.physicalName`,
	// which will be a concrete name.
	// Experimental.
	GetResourceNameAttribute(nameAttr *string) *string
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
	// Implement the `IAccessPoint.virtualHostedUrlForObject` method.
	// Experimental.
	VirtualHostedUrlForObject(key *string, options *awss3.VirtualHostedStyleUrlOptions) *string
	// Applies one or more mixins to this construct.
	//
	// Mixins are applied in order. The list of constructs is captured at the
	// start of the call, so constructs added by a mixin will not be visited.
	// Use multiple `with()` calls if subsequent mixins should apply to added
	// constructs.
	// Experimental.
	With(mixins ...constructs.IMixin) constructs.IConstruct
}

An S3 object lambda access point for intercepting and transforming `GetObject` requests.

Example:

import "github.com/aws/aws-cdk-go/awscdk"
import s3 "github.com/aws/aws-cdk-go/awscdk"
import s3objectlambda "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"
import cdk "github.com/aws/aws-cdk-go/awscdk"

stack := cdk.NewStack()
bucket := s3.NewBucket(stack, jsii.String("MyBucket"))
handler := lambda.NewFunction(stack, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(jsii.String("lambda.zip")),
})
s3objectlambda.NewAccessPoint(stack, jsii.String("MyObjectLambda"), &AccessPointProps{
	Bucket: Bucket,
	Handler: Handler,
	AccessPointName: jsii.String("my-access-point"),
	Payload: map[string]interface{}{
		"prop": jsii.String("value"),
	},
})

Experimental.

func NewAccessPoint

func NewAccessPoint(scope constructs.Construct, id *string, props *AccessPointProps) AccessPoint

Experimental.

type AccessPointAttributes

type AccessPointAttributes struct {
	// The ARN of the access point.
	// Experimental.
	AccessPointArn *string `field:"required" json:"accessPointArn" yaml:"accessPointArn"`
	// The creation data of the access point.
	// Experimental.
	AccessPointCreationDate *string `field:"required" json:"accessPointCreationDate" yaml:"accessPointCreationDate"`
}

The access point resource attributes.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import s3objectlambda_alpha "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"

accessPointAttributes := &AccessPointAttributes{
	AccessPointArn: jsii.String("accessPointArn"),
	AccessPointCreationDate: jsii.String("accessPointCreationDate"),
}

Experimental.

type AccessPointProps

type AccessPointProps struct {
	// The bucket to which this access point belongs.
	// Experimental.
	Bucket interfacesawss3.IBucketRef `field:"required" json:"bucket" yaml:"bucket"`
	// The Lambda function used to transform objects.
	// Experimental.
	Handler awslambda.IFunction `field:"required" json:"handler" yaml:"handler"`
	// The name of the S3 object lambda access point.
	// Default: a unique name will be generated.
	//
	// Experimental.
	AccessPointName *string `field:"optional" json:"accessPointName" yaml:"accessPointName"`
	// Whether CloudWatch metrics are enabled for the access point.
	// Default: false.
	//
	// Experimental.
	CloudWatchMetricsEnabled *bool `field:"optional" json:"cloudWatchMetricsEnabled" yaml:"cloudWatchMetricsEnabled"`
	// Additional JSON that provides supplemental data passed to the Lambda function on every request.
	// Default: - No data.
	//
	// Experimental.
	Payload *map[string]interface{} `field:"optional" json:"payload" yaml:"payload"`
	// Whether the Lambda function can process `GetObject-PartNumber` requests.
	// Default: false.
	//
	// Experimental.
	SupportsGetObjectPartNumber *bool `field:"optional" json:"supportsGetObjectPartNumber" yaml:"supportsGetObjectPartNumber"`
	// Whether the Lambda function can process `GetObject-Range` requests.
	// Default: false.
	//
	// Experimental.
	SupportsGetObjectRange *bool `field:"optional" json:"supportsGetObjectRange" yaml:"supportsGetObjectRange"`
}

The S3 object lambda access point configuration.

Example:

import "github.com/aws/aws-cdk-go/awscdk"
import s3 "github.com/aws/aws-cdk-go/awscdk"
import s3objectlambda "github.com/aws/aws-cdk-go/awscdks3objectlambdaalpha"
import cdk "github.com/aws/aws-cdk-go/awscdk"

stack := cdk.NewStack()
bucket := s3.NewBucket(stack, jsii.String("MyBucket"))
handler := lambda.NewFunction(stack, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(jsii.String("lambda.zip")),
})
s3objectlambda.NewAccessPoint(stack, jsii.String("MyObjectLambda"), &AccessPointProps{
	Bucket: Bucket,
	Handler: Handler,
	AccessPointName: jsii.String("my-access-point"),
	Payload: map[string]interface{}{
		"prop": jsii.String("value"),
	},
})

Experimental.

type IAccessPoint

type IAccessPoint interface {
	awscdk.IResource
	// The virtual hosted-style URL of an S3 object through this access point.
	//
	// Specify `regional: false` at the options for non-regional URL.
	//
	// Returns: an ObjectS3Url token.
	// Experimental.
	VirtualHostedUrlForObject(key *string, options *awss3.VirtualHostedStyleUrlOptions) *string
	// The ARN of the access point.
	// Experimental.
	AccessPointArn() *string
	// The creation data of the access point.
	// Experimental.
	AccessPointCreationDate() *string
	// The IPv4 DNS name of the access point.
	// Experimental.
	DomainName() *string
	// The regional domain name of the access point.
	// Experimental.
	RegionalDomainName() *string
}

The interface that represents the AccessPoint resource. Experimental.

func AccessPoint_FromAccessPointAttributes

func AccessPoint_FromAccessPointAttributes(scope constructs.Construct, id *string, attrs *AccessPointAttributes) IAccessPoint

Reference an existing AccessPoint defined outside of the CDK code. Experimental.

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL