InitSourceAssetOptions Struct
Additional options for an InitSource that builds an asset from local files.
| Source | aws-ec2/lib/cfn-init-elements.ts |
|---|
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_kms as interfaces_kms } from 'aws-cdk-lib/interfaces';
declare const dockerImage: cdk.DockerImage;
declare const grantable: iam.IGrantable;
declare const initServiceRestartHandle: ec2.InitServiceRestartHandle;
declare const keyRef: interfaces_kms.IKeyRef;
declare const localBundling: cdk.ILocalBundling;
const initSourceAssetOptions: ec2.InitSourceAssetOptions = {
assetHash: 'assetHash',
assetHashType: cdk.AssetHashType.SOURCE,
bundling: {
image: dockerImage,
// the properties below are optional
bundlingFileAccess: cdk.BundlingFileAccess.VOLUME_COPY,
command: ['command'],
entrypoint: ['entrypoint'],
environment: {
environmentKey: 'environment',
},
local: localBundling,
network: 'network',
outputType: cdk.BundlingOutput.ARCHIVED,
platform: 'platform',
securityOpt: 'securityOpt',
user: 'user',
volumes: [{
containerPath: 'containerPath',
hostPath: 'hostPath',
// the properties below are optional
consistency: cdk.DockerVolumeConsistency.CONSISTENT,
}],
volumesFrom: ['volumesFrom'],
workingDirectory: 'workingDirectory',
},
deployTime: false,
displayName: 'displayName',
exclude: ['exclude'],
followSymlinks: cdk.SymlinkFollowMode.NEVER,
ignoreMode: cdk.IgnoreMode.GLOB,
readers: [grantable],
serviceRestartHandles: [initServiceRestartHandle],
sourceKMSKey: keyRef,
};
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_iam as iam
from aws_cdk.interfaces import aws_kms as interfaces_kms
# docker_image: cdk.DockerImage
# grantable: iam.IGrantable
# init_service_restart_handle: ec2.InitServiceRestartHandle
# key_ref: interfaces_kms.IKeyRef
# local_bundling: cdk.ILocalBundling
init_source_asset_options = ec2.InitSourceAssetOptions(
asset_hash="assetHash",
asset_hash_type=cdk.AssetHashType.SOURCE,
bundling=cdk.BundlingOptions(
image=docker_image,
# the properties below are optional
bundling_file_access=cdk.BundlingFileAccess.VOLUME_COPY,
command=["command"],
entrypoint=["entrypoint"],
environment={
"environment_key": "environment"
},
local=local_bundling,
network="network",
output_type=cdk.BundlingOutput.ARCHIVED,
platform="platform",
security_opt="securityOpt",
user="user",
volumes=[cdk.DockerVolume(
container_path="containerPath",
host_path="hostPath",
# the properties below are optional
consistency=cdk.DockerVolumeConsistency.CONSISTENT
)],
volumes_from=["volumesFrom"],
working_directory="workingDirectory"
),
deploy_time=False,
display_name="displayName",
exclude=["exclude"],
follow_symlinks=cdk.SymlinkFollowMode.NEVER,
ignore_mode=cdk.IgnoreMode.GLOB,
readers=[grantable],
service_restart_handles=[init_service_restart_handle],
source_kms_key=key_ref
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.interfaces.kms.*;
DockerImage dockerImage;
IGrantable grantable;
InitServiceRestartHandle initServiceRestartHandle;
IKeyRef keyRef;
ILocalBundling localBundling;
InitSourceAssetOptions initSourceAssetOptions = InitSourceAssetOptions.builder()
.assetHash("assetHash")
.assetHashType(AssetHashType.SOURCE)
.bundling(BundlingOptions.builder()
.image(dockerImage)
// the properties below are optional
.bundlingFileAccess(BundlingFileAccess.VOLUME_COPY)
.command(List.of("command"))
.entrypoint(List.of("entrypoint"))
.environment(Map.of(
"environmentKey", "environment"))
.local(localBundling)
.network("network")
.outputType(BundlingOutput.ARCHIVED)
.platform("platform")
.securityOpt("securityOpt")
.user("user")
.volumes(List.of(DockerVolume.builder()
.containerPath("containerPath")
.hostPath("hostPath")
// the properties below are optional
.consistency(DockerVolumeConsistency.CONSISTENT)
.build()))
.volumesFrom(List.of("volumesFrom"))
.workingDirectory("workingDirectory")
.build())
.deployTime(false)
.displayName("displayName")
.exclude(List.of("exclude"))
.followSymlinks(SymlinkFollowMode.NEVER)
.ignoreMode(IgnoreMode.GLOB)
.readers(List.of(grantable))
.serviceRestartHandles(List.of(initServiceRestartHandle))
.sourceKMSKey(keyRef)
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.Interfaces.KMS;
DockerImage dockerImage;
IGrantable grantable;
InitServiceRestartHandle initServiceRestartHandle;
IKeyRef keyRef;
ILocalBundling localBundling;
var initSourceAssetOptions = new InitSourceAssetOptions {
AssetHash = "assetHash",
AssetHashType = AssetHashType.SOURCE,
Bundling = new BundlingOptions {
Image = dockerImage,
// the properties below are optional
BundlingFileAccess = BundlingFileAccess.VOLUME_COPY,
Command = new [] { "command" },
Entrypoint = new [] { "entrypoint" },
Environment = new Dictionary<string, string> {
{ "environmentKey", "environment" }
},
Local = localBundling,
Network = "network",
OutputType = BundlingOutput.ARCHIVED,
Platform = "platform",
SecurityOpt = "securityOpt",
User = "user",
Volumes = new [] { new DockerVolume {
ContainerPath = "containerPath",
HostPath = "hostPath",
// the properties below are optional
Consistency = DockerVolumeConsistency.CONSISTENT
} },
VolumesFrom = new [] { "volumesFrom" },
WorkingDirectory = "workingDirectory"
},
DeployTime = false,
DisplayName = "displayName",
Exclude = new [] { "exclude" },
FollowSymlinks = SymlinkFollowMode.NEVER,
IgnoreMode = IgnoreMode.GLOB,
Readers = new [] { grantable },
ServiceRestartHandles = new [] { initServiceRestartHandle },
SourceKMSKey = keyRef
};
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var dockerImage DockerImage
var grantable IGrantable
var initServiceRestartHandle InitServiceRestartHandle
var keyRef IKeyRef
var localBundling ILocalBundling
initSourceAssetOptions := &InitSourceAssetOptions{
AssetHash: jsii.String("assetHash"),
AssetHashType: cdk.AssetHashType_SOURCE,
Bundling: &BundlingOptions{
Image: dockerImage,
// the properties below are optional
BundlingFileAccess: cdk.BundlingFileAccess_VOLUME_COPY,
Command: []*string{
jsii.String("command"),
},
Entrypoint: []*string{
jsii.String("entrypoint"),
},
Environment: map[string]*string{
"environmentKey": jsii.String("environment"),
},
Local: localBundling,
Network: jsii.String("network"),
OutputType: cdk.BundlingOutput_ARCHIVED,
Platform: jsii.String("platform"),
SecurityOpt: jsii.String("securityOpt"),
User: jsii.String("user"),
Volumes: []DockerVolume{
&DockerVolume{
ContainerPath: jsii.String("containerPath"),
HostPath: jsii.String("hostPath"),
// the properties below are optional
Consistency: cdk.DockerVolumeConsistency_CONSISTENT,
},
},
VolumesFrom: []*string{
jsii.String("volumesFrom"),
},
WorkingDirectory: jsii.String("workingDirectory"),
},
DeployTime: jsii.Boolean(false),
DisplayName: jsii.String("displayName"),
Exclude: []*string{
jsii.String("exclude"),
},
FollowSymlinks: cdk.SymlinkFollowMode_NEVER,
IgnoreMode: cdk.IgnoreMode_GLOB,
Readers: []IGrantable{
grantable,
},
ServiceRestartHandles: []InitServiceRestartHandle{
initServiceRestartHandle,
},
SourceKMSKey: keyRef,
}
Properties
assetHashoptionalstringasset_hashoptionalstrassetHashoptionalStringAssetHashoptionalstringAssetHashoptional*string #Default: based on assetHashType
notes
If assetHashType is set it must be set to AssetHashType.CUSTOM. For consistency, this custom hash will be SHA256 hashed and encoded as hex. The resulting hash will be the asset hash.
NOTE: the hash is used in order to identify a specific revision of the asset, and used for optimizing and caching deployment activities related to this asset such as packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will need to make sure it is updated every time the asset changes, or otherwise it is possible that some deployments will not be invalidated.
assetHashTypeoptionalAssetHashTypeasset_hash_typeoptionalAssetHashTypeassetHashTypeoptionalAssetHashTypeAssetHashTypeoptionalAssetHashTypeAssetHashTypeoptionalAssetHashType #Default: the default is AssetHashType.SOURCE, but if assetHash is explicitly specified this value defaults to AssetHashType.CUSTOM.
If assetHash is configured, this option must be undefined or AssetHashType.CUSTOM.
bundlingoptionalBundlingOptionsbundlingoptionalBundlingOptionsbundlingoptionalBundlingOptionsBundlingoptionalBundlingOptionsBundlingoptionalBundlingOptions #Default: uploaded as-is to S3 if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to S3 otherwise
The asset path will be mounted at /asset-input. The Docker container is responsible for putting content at /asset-output. The content at /asset-output will be zipped and used as the final asset.
deployTimeoptionalbooleandeploy_timeoptionalbooldeployTimeoptionalBooleanDeployTimeoptionalboolDeployTimeoptional*bool = false #notes
i.e. are copied over to a different location and not needed afterwards. Setting this property to true has an impact on the lifecycle of the asset, because we will assume that it is safe to delete after the CloudFormation deployment succeeds.
For example, Lambda Function assets are copied over to Lambda during deployment. Therefore, it is not necessary to store the asset in S3, so we consider those deployTime assets.
displayNameoptionalstringdisplay_nameoptionalstrdisplayNameoptionalStringDisplayNameoptionalstringDisplayNameoptional*string #Default: Stack-relative construct path
notes
If supplied, the display name will be used in locations where the asset identifier is printed, like in the CLI progress information. If the same asset is added multiple times, the display name of the first occurrence is used.
The default is the construct path of the Asset construct, with respect to the enclosing stack. If the asset is produced by a construct helper function (such as lambda.Code.fromAsset()), this will look like MyFunction/Code.
We use the stack-relative construct path so that in the common case where you have multiple stacks with the same asset, we won't show something like /MyBetaStack/MyFunction/Code when you are actually deploying to production.
excludeoptionalstring[]excludeoptionaltyping.List[str]excludeoptionalList<String>Excludeoptionalstring[]Excludeoptional*[]*string #Default: nothing is excluded
notes
Without bundling
When used without the bundling property, the asset is just a regular file copy operation. In that case, this controls the files that will be included in the copy. Files matching the exclude patterns will not be included in the copy.
With bundling
When used with the bundling property, the asset is produced by a bundling operation. In that case, the value of exclude is only meaningful if the assetHashType is set to AssetHashType.SOURCE, and ignored for other asset hash types. The exclude patterns will be used to determine which files contribute to the asset, and the bundling command is skipped if the source files have not changed since the last bundling operation.
NOTE: The bundling operation still has access to all files in the source path, regardless of the exclude patterns. It is your responsibility to ensure the exclude pattern accurately matches the files the bundling operation will actually access and base its final output on.
For OUTPUT or CUSTOM asset hash types, the exclude pattern is ignored.
followSymlinksoptionalSymlinkFollowModefollow_symlinksoptionalSymlinkFollowModefollowSymlinksoptionalSymlinkFollowModeFollowSymlinksoptionalSymlinkFollowModeFollowSymlinksoptionalSymlinkFollowMode = SymlinkFollowMode.EXTERNAL #notes
Symlinks may be copied, materialized or rejected. Note that if symlinks are copied they should be relative; absolute symlinks will lose their meaning if the cloud assembly is moved to another machine.
Without bundling
When used without the bundling property, the asset is just a regular file copy operation. In that case, symlinks are materialized or blocked with respect to the sourcePath directory as they are being copied.
With bundling
When used with the bundling property, the asset is produced by a bundling operation. In that case, the bundling command is fully in charge of producing a set of files in an output directory, and the AssetStaging construct will never affect symlink materialization.
If the assetHashType is AssetHashType.SOURCE, this flag affects what the source hash is based on, and the recommended value is one of SymlinkFollowMode.EXTERNAL or SymlinkFollowMode.BLOCK_EXTERNAL.
If the SymlinkFollowMode.BLOCK_EXTERNAL mode is used:
- symlinks pointing outside the source tree will be blocked if using
AssetHashType.SOURCE. - symlinks pointing outside the bundle output will be blocked.
ignoreModeoptionalIgnoreModeignore_modeoptionalIgnoreModeignoreModeoptionalIgnoreModeIgnoreModeoptionalIgnoreModeIgnoreModeoptionalIgnoreMode #Default: IgnoreMode.GLOB for file assets, IgnoreMode.DOCKER for image assets (requires that the @aws-cdk/aws-ecr-assets:dockerIgnoreSupport feature flag is set, which is recommended)
readersoptionalIGrantable[]readersoptionaltyping.List[IGrantable]readersoptionalList<IGrantable>ReadersoptionalIGrantable[]Readersoptional*[]IGrantable #Default: No principals that can read file asset.
You can use asset.grantRead(principal) to grant read permissions later.
serviceRestartHandlesoptionalInitServiceRestartHandle[]service_restart_handlesoptionaltyping.List[InitServiceRestartHandle]serviceRestartHandlesoptionalList<InitServiceRestartHandle>ServiceRestartHandlesoptionalInitServiceRestartHandle[]ServiceRestartHandlesoptional*[]InitServiceRestartHandle #Default: Do not restart any service