Class BundlingOptions
(experimental) Bundling options.
Inheritance
Implements
Namespace: Amazon.CDK.AWS.Lambda.Go
Assembly: Amazon.CDK.AWS.Lambda.Go.dll
Syntax (csharp)
public class BundlingOptions : Object, IBundlingOptions
Syntax (vb)
Public Class BundlingOptions
Inherits Object
Implements IBundlingOptions
Remarks
Stability: Experimental
ExampleMetadata: infused
Examples
new GoFunction(this, "handler", new GoFunctionProps {
Entry = "app/cmd/api",
Bundling = new BundlingOptions {
DockerImage = DockerImage.FromBuild("/path/to/Dockerfile")
}
});
Synopsis
Constructors
BundlingOptions() |
Properties
AssetHash | (experimental) Specify a custom hash for this asset. |
AssetHashType | (experimental) Determines how the asset hash is calculated. Assets will get rebuilt and uploaded only if their hash has changed. |
BuildArgs | (experimental) Build arguments to pass when building the bundling image. |
CgoEnabled | (experimental) Whether or not to enable cgo during go build. |
CommandHooks | (experimental) Command hooks. |
DockerImage | (experimental) A custom bundling Docker image. |
Environment | (experimental) Environment variables defined when go runs. |
ForcedDockerBundling | (experimental) Force bundling in a Docker container even if local bundling is possible. |
GoBuildFlags | (experimental) List of additional flags to use while building. |
GoProxies | (experimental) What Go proxies to use to fetch the packages involved in the build. |
Constructors
BundlingOptions()
public BundlingOptions()
Properties
AssetHash
(experimental) Specify a custom hash for this asset.
public string AssetHash { get; set; }
Property Value
System.String
Remarks
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.
Default: - based on assetHashType
Stability: Experimental
AssetHashType
(experimental) Determines how the asset hash is calculated. Assets will get rebuilt and uploaded only if their hash has changed.
public Nullable<AssetHashType> AssetHashType { get; set; }
Property Value
System.Nullable<AssetHashType>
Remarks
If the asset hash is set to OUTPUT
(default), the hash is calculated
after bundling. This means that any change in the output will cause
the asset to be invalidated and uploaded. Bear in mind that the
go binary that is output can be different depending on the environment
that it was compiled in. If you want to control when the output is changed
it is recommended that you use immutable build images such as
public.ecr.aws/bitnami/golang:1.16.3-debian-10-r16
.
If the asset hash is set to SOURCE
, then only changes to the source
directory will cause the asset to rebuild. If your go project has multiple
Lambda functions this means that an update to any one function could cause
all the functions to be rebuilt and uploaded.
Default: - AssetHashType.OUTPUT. If assetHash
is also specified,
the default is CUSTOM
.
Stability: Experimental
BuildArgs
(experimental) Build arguments to pass when building the bundling image.
public IDictionary<string, string> BuildArgs { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.String>
Remarks
Default: - no build arguments are passed
Stability: Experimental
CgoEnabled
(experimental) Whether or not to enable cgo during go build.
public Nullable<bool> CgoEnabled { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
This will set the CGO_ENABLED environment variable
Default: - false
Stability: Experimental
CommandHooks
(experimental) Command hooks.
public ICommandHooks CommandHooks { get; set; }
Property Value
Remarks
Default: - do not run additional commands
Stability: Experimental
DockerImage
(experimental) A custom bundling Docker image.
public DockerImage DockerImage { get; set; }
Property Value
Remarks
Default: - use the Docker image provided by
Stability: Experimental
Aws-cdk: /aws-lambda-go
Environment
(experimental) Environment variables defined when go runs.
public IDictionary<string, string> Environment { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.String>
Remarks
Default: - no environment variables are defined.
Stability: Experimental
ForcedDockerBundling
(experimental) Force bundling in a Docker container even if local bundling is possible.
public Nullable<bool> ForcedDockerBundling { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false
Stability: Experimental
GoBuildFlags
(experimental) List of additional flags to use while building.
public string[] GoBuildFlags { get; set; }
Property Value
System.String[]
Remarks
For example: ['ldflags "-s -w"']
Default: - none
Stability: Experimental
GoProxies
(experimental) What Go proxies to use to fetch the packages involved in the build.
public string[] GoProxies { get; set; }
Property Value
System.String[]
Remarks
Pass a list of proxy addresses in order, and/or the string 'direct'
to
attempt direct access.
By default this construct uses no proxies, but a standard Go install would use the Google proxy by default. To recreate that behavior, do the following:
new GoFunction(this, "GoFunction", new GoFunctionProps {
Entry = "app/cmd/api",
Bundling = new BundlingOptions {
GoProxies = new [] { GoFunction.GOOGLE_GOPROXY, "direct" }
}
});
Default: - Direct access
Stability: Experimental