awss3deployment

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 12 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketDeployment_IsConstruct

func BucketDeployment_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NewBucketDeployment_Override

func NewBucketDeployment_Override(b BucketDeployment, scope constructs.Construct, id *string, props *BucketDeploymentProps)

Types

type BucketDeployment

type BucketDeployment interface {
	constructs.Construct
	// The bucket after the deployment.
	//
	// If you want to reference the destination bucket in another construct and make sure the
	// bucket deployment has happened before the next operation is started, pass the other construct
	// a reference to `deployment.deployedBucket`.
	//
	// Doing this replaces calling `otherResource.node.addDependency(deployment)`.
	DeployedBucket() awss3.IBucket
	// The tree node.
	Node() constructs.Node
	// Returns a string representation of this construct.
	ToString() *string
}

`BucketDeployment` populates an S3 bucket with the contents of .zip files from other S3 buckets or from local disk.

Example:

var websiteBucket bucket

deployment := s3deploy.NewBucketDeployment(this, jsii.String("DeployWebsite"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(path.join(__dirname, jsii.String("my-website"))),
	},
	destinationBucket: websiteBucket,
})

NewConstructThatReadsFromTheBucket(this, jsii.String("Consumer"), map[string]iBucket{
	// Use 'deployment.deployedBucket' instead of 'websiteBucket' here
	"bucket": deployment.deployedBucket,
})

func NewBucketDeployment

func NewBucketDeployment(scope constructs.Construct, id *string, props *BucketDeploymentProps) BucketDeployment

type BucketDeploymentProps

type BucketDeploymentProps struct {
	// The S3 bucket to sync the contents of the zip file to.
	DestinationBucket awss3.IBucket `json:"destinationBucket" yaml:"destinationBucket"`
	// The sources from which to deploy the contents of this bucket.
	Sources *[]ISource `json:"sources" yaml:"sources"`
	// System-defined x-amz-acl metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
	//
	AccessControl awss3.BucketAccessControl `json:"accessControl" yaml:"accessControl"`
	// System-defined cache-control metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	CacheControl *[]CacheControl `json:"cacheControl" yaml:"cacheControl"`
	// System-defined cache-disposition metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	ContentDisposition *string `json:"contentDisposition" yaml:"contentDisposition"`
	// System-defined content-encoding metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	ContentEncoding *string `json:"contentEncoding" yaml:"contentEncoding"`
	// System-defined content-language metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	ContentLanguage *string `json:"contentLanguage" yaml:"contentLanguage"`
	// System-defined content-type metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	ContentType *string `json:"contentType" yaml:"contentType"`
	// Key prefix in the destination bucket.
	//
	// Must be <=104 characters.
	DestinationKeyPrefix *string `json:"destinationKeyPrefix" yaml:"destinationKeyPrefix"`
	// The CloudFront distribution using the destination bucket as an origin.
	//
	// Files in the distribution's edge caches will be invalidated after
	// files are uploaded to the destination bucket.
	Distribution awscloudfront.IDistribution `json:"distribution" yaml:"distribution"`
	// The file paths to invalidate in the CloudFront distribution.
	DistributionPaths *[]*string `json:"distributionPaths" yaml:"distributionPaths"`
	// If this is set, matching files or objects will be excluded from the deployment's sync command.
	//
	// This can be used to exclude a file from being pruned in the destination bucket.
	//
	// If you want to just exclude files from the deployment package (which excludes these files
	// evaluated when invalidating the asset), you should leverage the `exclude` property of
	// `AssetOptions` when defining your source.
	// See: https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters
	//
	Exclude *[]*string `json:"exclude" yaml:"exclude"`
	// System-defined expires metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	Expires awscdk.Expiration `json:"expires" yaml:"expires"`
	// If this is set, matching files or objects will be included with the deployment's sync command.
	//
	// Since all files from the deployment package are included by default, this property
	// is usually leveraged alongside an `exclude` filter.
	// See: https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters
	//
	Include *[]*string `json:"include" yaml:"include"`
	// The number of days that the lambda function's log events are kept in CloudWatch Logs.
	LogRetention awslogs.RetentionDays `json:"logRetention" yaml:"logRetention"`
	// The amount of memory (in MiB) to allocate to the AWS Lambda function which replicates the files from the CDK bucket to the destination bucket.
	//
	// If you are deploying large files, you will need to increase this number
	// accordingly.
	MemoryLimit *float64 `json:"memoryLimit" yaml:"memoryLimit"`
	// User-defined object metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#UserMetadata
	//
	Metadata *UserDefinedObjectMetadata `json:"metadata" yaml:"metadata"`
	// If this is set to false, files in the destination bucket that do not exist in the asset, will NOT be deleted during deployment (create/update).
	// See: https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
	//
	Prune *bool `json:"prune" yaml:"prune"`
	// If this is set to "false", the destination files will be deleted when the resource is deleted or the destination is updated.
	//
	// NOTICE: Configuring this to "false" might have operational implications. Please
	// visit to the package documentation referred below to make sure you fully understand those implications.
	// See: https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-s3-deployment#retain-on-delete
	//
	RetainOnDelete *bool `json:"retainOnDelete" yaml:"retainOnDelete"`
	// Execution role associated with this function.
	Role awsiam.IRole `json:"role" yaml:"role"`
	// System-defined x-amz-server-side-encryption metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	ServerSideEncryption ServerSideEncryption `json:"serverSideEncryption" yaml:"serverSideEncryption"`
	// System-defined x-amz-server-side-encryption-aws-kms-key-id metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	ServerSideEncryptionAwsKmsKeyId *string `json:"serverSideEncryptionAwsKmsKeyId" yaml:"serverSideEncryptionAwsKmsKeyId"`
	// System-defined x-amz-server-side-encryption-customer-algorithm metadata to be set on all objects in the deployment.
	//
	// Warning: This is not a useful parameter until this bug is fixed: https://github.com/aws/aws-cdk/issues/6080
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html#sse-c-how-to-programmatically-intro
	//
	ServerSideEncryptionCustomerAlgorithm *string `json:"serverSideEncryptionCustomerAlgorithm" yaml:"serverSideEncryptionCustomerAlgorithm"`
	// System-defined x-amz-storage-class metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	StorageClass StorageClass `json:"storageClass" yaml:"storageClass"`
	// Mount an EFS file system.
	//
	// Enable this if your assets are large and you encounter disk space errors.
	// Enabling this option will require a VPC to be specified.
	UseEfs *bool `json:"useEfs" yaml:"useEfs"`
	// The VPC network to place the deployment lambda handler in.
	//
	// This is required if `useEfs` is set.
	Vpc awsec2.IVpc `json:"vpc" yaml:"vpc"`
	// Where in the VPC to place the deployment lambda handler.
	//
	// Only used if 'vpc' is supplied.
	VpcSubnets *awsec2.SubnetSelection `json:"vpcSubnets" yaml:"vpcSubnets"`
	// System-defined x-amz-website-redirect-location metadata to be set on all objects in the deployment.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata
	//
	WebsiteRedirectLocation *string `json:"websiteRedirectLocation" yaml:"websiteRedirectLocation"`
}

Properties for `BucketDeployment`.

Example:

var websiteBucket bucket

deployment := s3deploy.NewBucketDeployment(this, jsii.String("DeployWebsite"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(path.join(__dirname, jsii.String("my-website"))),
	},
	destinationBucket: websiteBucket,
})

NewConstructThatReadsFromTheBucket(this, jsii.String("Consumer"), map[string]iBucket{
	// Use 'deployment.deployedBucket' instead of 'websiteBucket' here
	"bucket": deployment.deployedBucket,
})

type CacheControl

type CacheControl interface {
	// The raw cache control setting.
	Value() interface{}
}

Used for HTTP cache-control header, which influences downstream caches.

Example:

var destinationBucket bucket
s3deploy.NewBucketDeployment(this, jsii.String("BucketDeployment"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(jsii.String("./website"), &assetOptions{
			exclude: []*string{
				jsii.String("index.html"),
			},
		}),
	},
	destinationBucket: destinationBucket,
	cacheControl: []cacheControl{
		s3deploy.*cacheControl.fromString(jsii.String("max-age=31536000,public,immutable")),
	},
	prune: jsii.Boolean(false),
})

s3deploy.NewBucketDeployment(this, jsii.String("HTMLBucketDeployment"), &bucketDeploymentProps{
	sources: []*iSource{
		s3deploy.*source.asset(jsii.String("./website"), &assetOptions{
			exclude: []*string{
				jsii.String("*"),
				jsii.String("!index.html"),
			},
		}),
	},
	destinationBucket: destinationBucket,
	cacheControl: []*cacheControl{
		s3deploy.*cacheControl.fromString(jsii.String("max-age=0,no-cache,no-store,must-revalidate")),
	},
	prune: jsii.Boolean(false),
})

See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata

func CacheControl_FromString

func CacheControl_FromString(s *string) CacheControl

Constructs a custom cache control key from the literal value.

func CacheControl_MaxAge

func CacheControl_MaxAge(t awscdk.Duration) CacheControl

Sets 'max-age=<duration-in-seconds>'.

func CacheControl_MustRevalidate

func CacheControl_MustRevalidate() CacheControl

Sets 'must-revalidate'.

func CacheControl_NoCache

func CacheControl_NoCache() CacheControl

Sets 'no-cache'.

func CacheControl_NoTransform

func CacheControl_NoTransform() CacheControl

Sets 'no-transform'.

func CacheControl_ProxyRevalidate

func CacheControl_ProxyRevalidate() CacheControl

Sets 'proxy-revalidate'.

func CacheControl_SMaxAge

func CacheControl_SMaxAge(t awscdk.Duration) CacheControl

Sets 's-maxage=<duration-in-seconds>'.

func CacheControl_SetPrivate

func CacheControl_SetPrivate() CacheControl

Sets 'private'.

func CacheControl_SetPublic

func CacheControl_SetPublic() CacheControl

Sets 'public'.

type DeploymentSourceContext

type DeploymentSourceContext struct {
	// The role for the handler.
	HandlerRole awsiam.IRole `json:"handlerRole" yaml:"handlerRole"`
}

Bind context for ISources.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"import iam "github.com/aws/aws-cdk-go/awscdk/aws_iam"import awscdk "github.com/aws/aws-cdk-go/awscdk"import s3_deployment "github.com/aws/aws-cdk-go/awscdk/aws_s3_deployment"

var role role
deploymentSourceContext := &deploymentSourceContext{
	handlerRole: role,
}

type ISource

type ISource interface {
	// Binds the source to a bucket deployment.
	Bind(scope constructs.Construct, context *DeploymentSourceContext) *SourceConfig
}

Represents a source for bucket deployments.

func Source_Asset

func Source_Asset(path *string, options *awss3assets.AssetOptions) ISource

Uses a local asset as the deployment source.

If the local asset is a .zip archive, make sure you trust the producer of the archive.

func Source_Bucket

func Source_Bucket(bucket awss3.IBucket, zipObjectKey *string) ISource

Uses a .zip file stored in an S3 bucket as the source for the destination bucket contents.

Make sure you trust the producer of the archive.

func Source_Data added in v2.11.0

func Source_Data(objectKey *string, data *string) ISource

Deploys an object with the specified string contents into the bucket.

The content can include deploy-time values (such as `snsTopic.topicArn`) that will get resolved only during deployment.

To store a JSON object use `Source.jsonData()`.

func Source_JsonData added in v2.11.0

func Source_JsonData(objectKey *string, obj interface{}) ISource

Deploys an object with the specified JSON object into the bucket.

The object can include deploy-time values (such as `snsTopic.topicArn`) that will get resolved only during deployment.

type ServerSideEncryption

type ServerSideEncryption string

Indicates whether server-side encryption is enabled for the object, and whether that encryption is from the AWS Key Management Service (AWS KMS) or from Amazon S3 managed encryption (SSE-S3).

Example:

websiteBucket := s3.NewBucket(this, jsii.String("WebsiteBucket"), &bucketProps{
	websiteIndexDocument: jsii.String("index.html"),
	publicReadAccess: jsii.Boolean(true),
})

s3deploy.NewBucketDeployment(this, jsii.String("DeployWebsite"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(jsii.String("./website-dist")),
	},
	destinationBucket: websiteBucket,
	destinationKeyPrefix: jsii.String("web/static"),
	 // optional prefix in destination bucket
	metadata: &userDefinedObjectMetadata{
		a: jsii.String("1"),
		b: jsii.String("2"),
	},
	 // user-defined metadata

	// system-defined metadata
	contentType: jsii.String("text/html"),
	contentLanguage: jsii.String("en"),
	storageClass: s3deploy.storageClass_INTELLIGENT_TIERING,
	serverSideEncryption: s3deploy.serverSideEncryption_AES_256,
	cacheControl: []cacheControl{
		s3deploy.*cacheControl.setPublic(),
		s3deploy.*cacheControl.maxAge(duration.hours(jsii.Number(1))),
	},
	accessControl: s3.bucketAccessControl_BUCKET_OWNER_FULL_CONTROL,
})

See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata

const (
	// 'AES256'.
	ServerSideEncryption_AES_256 ServerSideEncryption = "AES_256"
	// 'aws:kms'.
	ServerSideEncryption_AWS_KMS ServerSideEncryption = "AWS_KMS"
)

type Source

type Source interface {
}

Specifies bucket deployment source.

Usage:

Source.bucket(bucket, key)
Source.asset('/local/path/to/directory')
Source.asset('/local/path/to/a/file.zip')
Source.data('hello/world/file.txt', 'Hello, world!')
Source.data('config.json', { baz: topic.topicArn })

Example:

var websiteBucket bucket

deployment := s3deploy.NewBucketDeployment(this, jsii.String("DeployWebsite"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(path.join(__dirname, jsii.String("my-website"))),
	},
	destinationBucket: websiteBucket,
})

NewConstructThatReadsFromTheBucket(this, jsii.String("Consumer"), map[string]iBucket{
	// Use 'deployment.deployedBucket' instead of 'websiteBucket' here
	"bucket": deployment.deployedBucket,
})

type SourceConfig

type SourceConfig struct {
	// The source bucket to deploy from.
	Bucket awss3.IBucket `json:"bucket" yaml:"bucket"`
	// An S3 object key in the source bucket that points to a zip file.
	ZipObjectKey *string `json:"zipObjectKey" yaml:"zipObjectKey"`
	// A set of markers to substitute in the source content.
	Markers *map[string]interface{} `json:"markers" yaml:"markers"`
}

Source information.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"import s3 "github.com/aws/aws-cdk-go/awscdk/aws_s3"import awscdk "github.com/aws/aws-cdk-go/awscdk"import s3_deployment "github.com/aws/aws-cdk-go/awscdk/aws_s3_deployment"

var bucket bucket
var markers interface{}
sourceConfig := &sourceConfig{
	bucket: bucket,
	zipObjectKey: jsii.String("zipObjectKey"),

	// the properties below are optional
	markers: map[string]interface{}{
		"markersKey": markers,
	},
}

type StorageClass

type StorageClass string

Storage class used for storing the object.

Example:

websiteBucket := s3.NewBucket(this, jsii.String("WebsiteBucket"), &bucketProps{
	websiteIndexDocument: jsii.String("index.html"),
	publicReadAccess: jsii.Boolean(true),
})

s3deploy.NewBucketDeployment(this, jsii.String("DeployWebsite"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(jsii.String("./website-dist")),
	},
	destinationBucket: websiteBucket,
	destinationKeyPrefix: jsii.String("web/static"),
	 // optional prefix in destination bucket
	metadata: &userDefinedObjectMetadata{
		a: jsii.String("1"),
		b: jsii.String("2"),
	},
	 // user-defined metadata

	// system-defined metadata
	contentType: jsii.String("text/html"),
	contentLanguage: jsii.String("en"),
	storageClass: s3deploy.storageClass_INTELLIGENT_TIERING,
	serverSideEncryption: s3deploy.serverSideEncryption_AES_256,
	cacheControl: []cacheControl{
		s3deploy.*cacheControl.setPublic(),
		s3deploy.*cacheControl.maxAge(duration.hours(jsii.Number(1))),
	},
	accessControl: s3.bucketAccessControl_BUCKET_OWNER_FULL_CONTROL,
})

See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata

const (
	// 'STANDARD'.
	StorageClass_STANDARD StorageClass = "STANDARD"
	// 'REDUCED_REDUNDANCY'.
	StorageClass_REDUCED_REDUNDANCY StorageClass = "REDUCED_REDUNDANCY"
	// 'STANDARD_IA'.
	StorageClass_STANDARD_IA StorageClass = "STANDARD_IA"
	// 'ONEZONE_IA'.
	StorageClass_ONEZONE_IA StorageClass = "ONEZONE_IA"
	// 'INTELLIGENT_TIERING'.
	StorageClass_INTELLIGENT_TIERING StorageClass = "INTELLIGENT_TIERING"
	// 'GLACIER'.
	StorageClass_GLACIER StorageClass = "GLACIER"
	// 'DEEP_ARCHIVE'.
	StorageClass_DEEP_ARCHIVE StorageClass = "DEEP_ARCHIVE"
)

type UserDefinedObjectMetadata

type UserDefinedObjectMetadata struct {
}

Custom user defined metadata.

Example:

websiteBucket := s3.NewBucket(this, jsii.String("WebsiteBucket"), &bucketProps{
	websiteIndexDocument: jsii.String("index.html"),
	publicReadAccess: jsii.Boolean(true),
})

s3deploy.NewBucketDeployment(this, jsii.String("DeployWebsite"), &bucketDeploymentProps{
	sources: []iSource{
		s3deploy.source.asset(jsii.String("./website-dist")),
	},
	destinationBucket: websiteBucket,
	destinationKeyPrefix: jsii.String("web/static"),
	 // optional prefix in destination bucket
	metadata: &userDefinedObjectMetadata{
		a: jsii.String("1"),
		b: jsii.String("2"),
	},
	 // user-defined metadata

	// system-defined metadata
	contentType: jsii.String("text/html"),
	contentLanguage: jsii.String("en"),
	storageClass: s3deploy.storageClass_INTELLIGENT_TIERING,
	serverSideEncryption: s3deploy.serverSideEncryption_AES_256,
	cacheControl: []cacheControl{
		s3deploy.*cacheControl.setPublic(),
		s3deploy.*cacheControl.maxAge(duration.hours(jsii.Number(1))),
	},
	accessControl: s3.bucketAccessControl_BUCKET_OWNER_FULL_CONTROL,
})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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