# CfnParametersCode

Lambda code defined using 2 CloudFormation parameters.

Useful when you don't have access to the code of your Lambda from your CDK code, so you can't use Assets,
and you want to deploy the Lambda in a CodePipeline, using CloudFormation Actions -
you can fill the parameters using the `#assign` method.

Extends: [Code](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Code.html) › CfnParametersCode
Obtainable from: [Code.fromCfnParameters](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Code.html#fromcfnparameters)

- Source: [`aws-lambda/lib/code.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-lambda/lib/code.ts#L612)

## Example

TypeScript:

```ts
const lambdaStack = new cdk.Stack(app, 'LambdaStack');
const lambdaCode = lambda.Code.fromCfnParameters();
new lambda.Function(lambdaStack, 'Lambda', {
  code: lambdaCode,
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
});
// other resources that your Lambda needs, added to the lambdaStack...

const pipelineStack = new cdk.Stack(app, 'PipelineStack');
const pipeline = new codepipeline.Pipeline(pipelineStack, 'Pipeline', {
  crossAccountKeys: true,
});

// add the source code repository containing this code to your Pipeline,
// and the source code of the Lambda Function, if they're separate
const cdkSourceOutput = new codepipeline.Artifact();
const cdkSourceAction = new codepipeline_actions.CodeCommitSourceAction({
  repository: new codecommit.Repository(pipelineStack, 'CdkCodeRepo', {
    repositoryName: 'CdkCodeRepo',
  }),
  actionName: 'CdkCode_Source',
  output: cdkSourceOutput,
});
const lambdaSourceOutput = new codepipeline.Artifact();
const lambdaSourceAction = new codepipeline_actions.CodeCommitSourceAction({
  repository: new codecommit.Repository(pipelineStack, 'LambdaCodeRepo', {
    repositoryName: 'LambdaCodeRepo',
  }),
  actionName: 'LambdaCode_Source',
  output: lambdaSourceOutput,
});
pipeline.addStage({
  stageName: 'Source',
  actions: [cdkSourceAction, lambdaSourceAction],
});

// synthesize the Lambda CDK template, using CodeBuild
// the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
// adjust the build environment and/or commands accordingly
const cdkBuildProject = new codebuild.Project(pipelineStack, 'CdkBuildProject', {
  environment: {
    buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
  },
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      install: {
        commands: 'npm install',
      },
      build: {
        commands: [
          'npm run build',
          'npm run cdk synth LambdaStack -- -o .',
        ],
      },
    },
    artifacts: {
      files: 'LambdaStack.template.yaml',
    },
  }),
});
const cdkBuildOutput = new codepipeline.Artifact();
const cdkBuildAction = new codepipeline_actions.CodeBuildAction({
  actionName: 'CDK_Build',
  project: cdkBuildProject,
  input: cdkSourceOutput,
  outputs: [cdkBuildOutput],
});

// build your Lambda code, using CodeBuild
// again, this example assumes your Lambda is written in TypeScript/JavaScript -
// make sure to adjust the build environment and/or commands if they don't match your specific situation
const lambdaBuildProject = new codebuild.Project(pipelineStack, 'LambdaBuildProject', {
  environment: {
    buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
  },
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      install: {
        commands: 'npm install',
      },
      build: {
        commands: 'npm run build',
      },
    },
    artifacts: {
      files: [
        'index.js',
        'node_modules/**/*',
      ],
    },
  }),
});
const lambdaBuildOutput = new codepipeline.Artifact();
const lambdaBuildAction = new codepipeline_actions.CodeBuildAction({
  actionName: 'Lambda_Build',
  project: lambdaBuildProject,
  input: lambdaSourceOutput,
  outputs: [lambdaBuildOutput],
});

pipeline.addStage({
  stageName: 'Build',
  actions: [cdkBuildAction, lambdaBuildAction],
});

// finally, deploy your Lambda Stack
pipeline.addStage({
  stageName: 'Deploy',
  actions: [
    new codepipeline_actions.CloudFormationCreateUpdateStackAction({
      actionName: 'Lambda_CFN_Deploy',
      templatePath: cdkBuildOutput.atPath('LambdaStack.template.yaml'),
      stackName: 'LambdaStackDeployedName',
      adminPermissions: true,
      parameterOverrides: lambdaCode.assign(lambdaBuildOutput.s3Location),
      extraInputs: [
        lambdaBuildOutput,
      ],
    }),
  ],
});
```

Python:

```python
lambda_stack = cdk.Stack(app, "LambdaStack")
lambda_code = lambda_.Code.from_cfn_parameters()
lambda_.Function(lambda_stack, "Lambda",
    code=lambda_code,
    handler="index.handler",
    runtime=lambda_.Runtime.NODEJS_LATEST
)
# other resources that your Lambda needs, added to the lambdaStack...

pipeline_stack = cdk.Stack(app, "PipelineStack")
pipeline = codepipeline.Pipeline(pipeline_stack, "Pipeline",
    cross_account_keys=True
)

# add the source code repository containing this code to your Pipeline,
# and the source code of the Lambda Function, if they're separate
cdk_source_output = codepipeline.Artifact()
cdk_source_action = codepipeline_actions.CodeCommitSourceAction(
    repository=codecommit.Repository(pipeline_stack, "CdkCodeRepo",
        repository_name="CdkCodeRepo"
    ),
    action_name="CdkCode_Source",
    output=cdk_source_output
)
lambda_source_output = codepipeline.Artifact()
lambda_source_action = codepipeline_actions.CodeCommitSourceAction(
    repository=codecommit.Repository(pipeline_stack, "LambdaCodeRepo",
        repository_name="LambdaCodeRepo"
    ),
    action_name="LambdaCode_Source",
    output=lambda_source_output
)
pipeline.add_stage(
    stage_name="Source",
    actions=[cdk_source_action, lambda_source_action]
)

# synthesize the Lambda CDK template, using CodeBuild
# the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
# adjust the build environment and/or commands accordingly
cdk_build_project = codebuild.Project(pipeline_stack, "CdkBuildProject",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxBuildImage.STANDARD_7_0
    ),
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "install": {
                "commands": "npm install"
            },
            "build": {
                "commands": ["npm run build", "npm run cdk synth LambdaStack -- -o ."
                ]
            }
        },
        "artifacts": {
            "files": "LambdaStack.template.yaml"
        }
    })
)
cdk_build_output = codepipeline.Artifact()
cdk_build_action = codepipeline_actions.CodeBuildAction(
    action_name="CDK_Build",
    project=cdk_build_project,
    input=cdk_source_output,
    outputs=[cdk_build_output]
)

# build your Lambda code, using CodeBuild
# again, this example assumes your Lambda is written in TypeScript/JavaScript -
# make sure to adjust the build environment and/or commands if they don't match your specific situation
lambda_build_project = codebuild.Project(pipeline_stack, "LambdaBuildProject",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxBuildImage.STANDARD_7_0
    ),
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "install": {
                "commands": "npm install"
            },
            "build": {
                "commands": "npm run build"
            }
        },
        "artifacts": {
            "files": ["index.js", "node_modules/**/*"
            ]
        }
    })
)
lambda_build_output = codepipeline.Artifact()
lambda_build_action = codepipeline_actions.CodeBuildAction(
    action_name="Lambda_Build",
    project=lambda_build_project,
    input=lambda_source_output,
    outputs=[lambda_build_output]
)

pipeline.add_stage(
    stage_name="Build",
    actions=[cdk_build_action, lambda_build_action]
)

# finally, deploy your Lambda Stack
pipeline.add_stage(
    stage_name="Deploy",
    actions=[
        codepipeline_actions.CloudFormationCreateUpdateStackAction(
            action_name="Lambda_CFN_Deploy",
            template_path=cdk_build_output.at_path("LambdaStack.template.yaml"),
            stack_name="LambdaStackDeployedName",
            admin_permissions=True,
            parameter_overrides=lambda_code.assign(lambda_build_output.s3_location),
            extra_inputs=[lambda_build_output
            ]
        )
    ]
)
```

Java:

```java
Stack lambdaStack = new Stack(app, "LambdaStack");
CfnParametersCode lambdaCode = Code.fromCfnParameters();
Function.Builder.create(lambdaStack, "Lambda")
        .code(lambdaCode)
        .handler("index.handler")
        .runtime(Runtime.NODEJS_LATEST)
        .build();
// other resources that your Lambda needs, added to the lambdaStack...

Stack pipelineStack = new Stack(app, "PipelineStack");
Pipeline pipeline = Pipeline.Builder.create(pipelineStack, "Pipeline")
        .crossAccountKeys(true)
        .build();

// add the source code repository containing this code to your Pipeline,
// and the source code of the Lambda Function, if they're separate
Artifact cdkSourceOutput = new Artifact();
CodeCommitSourceAction cdkSourceAction = CodeCommitSourceAction.Builder.create()
        .repository(Repository.Builder.create(pipelineStack, "CdkCodeRepo")
                .repositoryName("CdkCodeRepo")
                .build())
        .actionName("CdkCode_Source")
        .output(cdkSourceOutput)
        .build();
Artifact lambdaSourceOutput = new Artifact();
CodeCommitSourceAction lambdaSourceAction = CodeCommitSourceAction.Builder.create()
        .repository(Repository.Builder.create(pipelineStack, "LambdaCodeRepo")
                .repositoryName("LambdaCodeRepo")
                .build())
        .actionName("LambdaCode_Source")
        .output(lambdaSourceOutput)
        .build();
pipeline.addStage(StageOptions.builder()
        .stageName("Source")
        .actions(List.of(cdkSourceAction, lambdaSourceAction))
        .build());

// synthesize the Lambda CDK template, using CodeBuild
// the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
// adjust the build environment and/or commands accordingly
Project cdkBuildProject = Project.Builder.create(pipelineStack, "CdkBuildProject")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxBuildImage.STANDARD_7_0)
                .build())
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "install", Map.of(
                                "commands", "npm install"),
                        "build", Map.of(
                                "commands", List.of("npm run build", "npm run cdk synth LambdaStack -- -o ."))),
                "artifacts", Map.of(
                        "files", "LambdaStack.template.yaml"))))
        .build();
Artifact cdkBuildOutput = new Artifact();
CodeBuildAction cdkBuildAction = CodeBuildAction.Builder.create()
        .actionName("CDK_Build")
        .project(cdkBuildProject)
        .input(cdkSourceOutput)
        .outputs(List.of(cdkBuildOutput))
        .build();

// build your Lambda code, using CodeBuild
// again, this example assumes your Lambda is written in TypeScript/JavaScript -
// make sure to adjust the build environment and/or commands if they don't match your specific situation
Project lambdaBuildProject = Project.Builder.create(pipelineStack, "LambdaBuildProject")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxBuildImage.STANDARD_7_0)
                .build())
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "install", Map.of(
                                "commands", "npm install"),
                        "build", Map.of(
                                "commands", "npm run build")),
                "artifacts", Map.of(
                        "files", List.of("index.js", "node_modules/**/*")))))
        .build();
Artifact lambdaBuildOutput = new Artifact();
CodeBuildAction lambdaBuildAction = CodeBuildAction.Builder.create()
        .actionName("Lambda_Build")
        .project(lambdaBuildProject)
        .input(lambdaSourceOutput)
        .outputs(List.of(lambdaBuildOutput))
        .build();

pipeline.addStage(StageOptions.builder()
        .stageName("Build")
        .actions(List.of(cdkBuildAction, lambdaBuildAction))
        .build());

// finally, deploy your Lambda Stack
pipeline.addStage(StageOptions.builder()
        .stageName("Deploy")
        .actions(List.of(
            CloudFormationCreateUpdateStackAction.Builder.create()
                    .actionName("Lambda_CFN_Deploy")
                    .templatePath(cdkBuildOutput.atPath("LambdaStack.template.yaml"))
                    .stackName("LambdaStackDeployedName")
                    .adminPermissions(true)
                    .parameterOverrides(lambdaCode.assign(lambdaBuildOutput.getS3Location()))
                    .extraInputs(List.of(lambdaBuildOutput))
                    .build()))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var lambdaStack = new Stack(app, "LambdaStack");
var lambdaCode = Code.FromCfnParameters();
new Function(lambdaStack, "Lambda", new FunctionProps {
    Code = lambdaCode,
    Handler = "index.handler",
    Runtime = Runtime.NODEJS_LATEST
});
// other resources that your Lambda needs, added to the lambdaStack...

var pipelineStack = new Stack(app, "PipelineStack");
var pipeline = new Pipeline(pipelineStack, "Pipeline", new PipelineProps {
    CrossAccountKeys = true
});

// add the source code repository containing this code to your Pipeline,
// and the source code of the Lambda Function, if they're separate
var cdkSourceOutput = new Artifact();
var cdkSourceAction = new CodeCommitSourceAction(new CodeCommitSourceActionProps {
    Repository = new Repository(pipelineStack, "CdkCodeRepo", new RepositoryProps {
        RepositoryName = "CdkCodeRepo"
    }),
    ActionName = "CdkCode_Source",
    Output = cdkSourceOutput
});
var lambdaSourceOutput = new Artifact();
var lambdaSourceAction = new CodeCommitSourceAction(new CodeCommitSourceActionProps {
    Repository = new Repository(pipelineStack, "LambdaCodeRepo", new RepositoryProps {
        RepositoryName = "LambdaCodeRepo"
    }),
    ActionName = "LambdaCode_Source",
    Output = lambdaSourceOutput
});
pipeline.AddStage(new StageOptions {
    StageName = "Source",
    Actions = new [] { cdkSourceAction, lambdaSourceAction }
});

// synthesize the Lambda CDK template, using CodeBuild
// the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
// adjust the build environment and/or commands accordingly
var cdkBuildProject = new Project(pipelineStack, "CdkBuildProject", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxBuildImage.STANDARD_7_0
    },
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string>> {
            { "install", new Struct {
                Commands = "npm install"
            } },
            { "build", new Struct {
                Commands = new [] { "npm run build", "npm run cdk synth LambdaStack -- -o ." }
            } }
        } },
        { "artifacts", new Dictionary<string, string> {
            { "files", "LambdaStack.template.yaml" }
        } }
    })
});
var cdkBuildOutput = new Artifact();
var cdkBuildAction = new CodeBuildAction(new CodeBuildActionProps {
    ActionName = "CDK_Build",
    Project = cdkBuildProject,
    Input = cdkSourceOutput,
    Outputs = new [] { cdkBuildOutput }
});

// build your Lambda code, using CodeBuild
// again, this example assumes your Lambda is written in TypeScript/JavaScript -
// make sure to adjust the build environment and/or commands if they don't match your specific situation
var lambdaBuildProject = new Project(pipelineStack, "LambdaBuildProject", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxBuildImage.STANDARD_7_0
    },
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string>> {
            { "install", new Struct {
                Commands = "npm install"
            } },
            { "build", new Struct {
                Commands = "npm run build"
            } }
        } },
        { "artifacts", new Dictionary<string, string[]> {
            { "files", new [] { "index.js", "node_modules/**/*" } }
        } }
    })
});
var lambdaBuildOutput = new Artifact();
var lambdaBuildAction = new CodeBuildAction(new CodeBuildActionProps {
    ActionName = "Lambda_Build",
    Project = lambdaBuildProject,
    Input = lambdaSourceOutput,
    Outputs = new [] { lambdaBuildOutput }
});

pipeline.AddStage(new StageOptions {
    StageName = "Build",
    Actions = new [] { cdkBuildAction, lambdaBuildAction }
});

// finally, deploy your Lambda Stack
pipeline.AddStage(new StageOptions {
    StageName = "Deploy",
    Actions = new [] {
        new CloudFormationCreateUpdateStackAction(new CloudFormationCreateUpdateStackActionProps {
            ActionName = "Lambda_CFN_Deploy",
            TemplatePath = cdkBuildOutput.AtPath("LambdaStack.template.yaml"),
            StackName = "LambdaStackDeployedName",
            AdminPermissions = true,
            ParameterOverrides = lambdaCode.Assign(lambdaBuildOutput.S3Location),
            ExtraInputs = new [] { lambdaBuildOutput }
        }) }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
lambdaStack := cdk.NewStack(app, jsii.String("LambdaStack"))
lambdaCode := lambda.Code_FromCfnParameters()
lambda.NewFunction(lambdaStack, jsii.String("Lambda"), &FunctionProps{
	Code: lambdaCode,
	Handler: jsii.String("index.handler"),
	Runtime: lambda.Runtime_NODEJS_LATEST(),
})
// other resources that your Lambda needs, added to the lambdaStack...

pipelineStack := cdk.NewStack(app, jsii.String("PipelineStack"))
pipeline := codepipeline.NewPipeline(pipelineStack, jsii.String("Pipeline"), &PipelineProps{
	CrossAccountKeys: jsii.Boolean(true),
})

// add the source code repository containing this code to your Pipeline,
// and the source code of the Lambda Function, if they're separate
cdkSourceOutput := codepipeline.NewArtifact()
cdkSourceAction := codepipeline_actions.NewCodeCommitSourceAction(&CodeCommitSourceActionProps{
	Repository: codecommit.NewRepository(pipelineStack, jsii.String("CdkCodeRepo"), &RepositoryProps{
		RepositoryName: jsii.String("CdkCodeRepo"),
	}),
	ActionName: jsii.String("CdkCode_Source"),
	Output: cdkSourceOutput,
})
lambdaSourceOutput := codepipeline.NewArtifact()
lambdaSourceAction := codepipeline_actions.NewCodeCommitSourceAction(&CodeCommitSourceActionProps{
	Repository: codecommit.NewRepository(pipelineStack, jsii.String("LambdaCodeRepo"), &RepositoryProps{
		RepositoryName: jsii.String("LambdaCodeRepo"),
	}),
	ActionName: jsii.String("LambdaCode_Source"),
	Output: lambdaSourceOutput,
})
pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Source"),
	Actions: []IAction{
		cdkSourceAction,
		lambdaSourceAction,
	},
})

// synthesize the Lambda CDK template, using CodeBuild
// the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
// adjust the build environment and/or commands accordingly
cdkBuildProject := codebuild.NewProject(pipelineStack, jsii.String("CdkBuildProject"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
	},
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string]*string{
			"install": map[string]*string{
				"commands": jsii.String("npm install"),
			},
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("npm run build"),
					jsii.String("npm run cdk synth LambdaStack -- -o ."),
				},
			},
		},
		"artifacts": map[string]*string{
			"files": jsii.String("LambdaStack.template.yaml"),
		},
	}),
})
cdkBuildOutput := codepipeline.NewArtifact()
cdkBuildAction := codepipeline_actions.NewCodeBuildAction(&CodeBuildActionProps{
	ActionName: jsii.String("CDK_Build"),
	Project: cdkBuildProject,
	Input: cdkSourceOutput,
	Outputs: []Artifact{
		cdkBuildOutput,
	},
})

// build your Lambda code, using CodeBuild
// again, this example assumes your Lambda is written in TypeScript/JavaScript -
// make sure to adjust the build environment and/or commands if they don't match your specific situation
lambdaBuildProject := codebuild.NewProject(pipelineStack, jsii.String("LambdaBuildProject"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
	},
	BuildSpec: codebuild.BuildSpec_*FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string]*string{
			"install": map[string]*string{
				"commands": jsii.String("npm install"),
			},
			"build": map[string]*string{
				"commands": jsii.String("npm run build"),
			},
		},
		"artifacts": map[string][]*string{
			"files": []*string{
				jsii.String("index.js"),
				jsii.String("node_modules/**/*"),
			},
		},
	}),
})
lambdaBuildOutput := codepipeline.NewArtifact()
lambdaBuildAction := codepipeline_actions.NewCodeBuildAction(&CodeBuildActionProps{
	ActionName: jsii.String("Lambda_Build"),
	Project: lambdaBuildProject,
	Input: lambdaSourceOutput,
	Outputs: []Artifact{
		lambdaBuildOutput,
	},
})

pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Build"),
	Actions: []IAction{
		cdkBuildAction,
		lambdaBuildAction,
	},
})

// finally, deploy your Lambda Stack
pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Deploy"),
	Actions: []IAction{
		codepipeline_actions.NewCloudFormationCreateUpdateStackAction(&CloudFormationCreateUpdateStackActionProps{
			ActionName: jsii.String("Lambda_CFN_Deploy"),
			TemplatePath: cdkBuildOutput.AtPath(jsii.String("LambdaStack.template.yaml")),
			StackName: jsii.String("LambdaStackDeployedName"),
			AdminPermissions: jsii.Boolean(true),
			ParameterOverrides: lambdaCode.Assign(lambdaBuildOutput.s3Location),
			ExtraInputs: []Artifact{
				lambdaBuildOutput,
			},
		}),
	},
})
```

## Initializer

TypeScript:

```ts
new CfnParametersCode(props?: CfnParametersCodeProps)
```

Python:

```python
CfnParametersCode(props: typing.Optional[CfnParametersCodeProps] = None)
```

Java:

```java
new CfnParametersCode(CfnParametersCodeProps props)
```

C# / .NET:

```csharp
new CfnParametersCode(CfnParametersCodeProps? props = null)
```

Golang:

```go
NewCfnParametersCode(Props CfnParametersCodeProps)
```

## Properties

- `bucketNameParam`: string

- `isInline`: boolean — Determines whether this Code is inline code or not.

- `objectKeyParam`: string

## Methods

- `assign(location: Location): { [key: string]: any }` — Create a parameters map from this instance's CloudFormation parameters.

  It returns a map with 2 keys that correspond to the names of the parameters defined in this Lambda code,
  and as values it contains the appropriate expressions pointing at the provided S3 location
  (most likely, obtained from a CodePipeline Artifact by calling the `artifact.s3Location` method).
  The result should be provided to the CloudFormation Action
  that is deploying the Stack that the Lambda with this code is part of,
  in the `parameterOverrides` property.

  **Parameters**

  - `location` — the location of the object in S3 that represents the Lambda code.

- `bind(scope: Construct): CodeConfig` — Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.

- `bindToResource(_resource: CfnResource, _options?: ResourceBindOptions): void` — 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.

- `fromAsset(path: string, options?: AssetOptions): AssetCode` (static) — Loads the function code from a local disk path.

  **Parameters**

  - `path` — Either a directory with the Lambda code bundle or a .zip file.

- `fromAssetImage(directory: string, props?: AssetImageCodeProps): AssetImageCode` (static) — Create an ECR image from the specified asset and bind it as the Lambda code.

  **Parameters**

  - `directory` — the directory from which the asset must be created.
  - `props` — properties to further configure the selected image.

- `fromBucket(bucket: IBucket, key: string, objectVersion?: string): S3Code` (static) — Lambda handler code as an S3 object.

  Note: If `objectVersion` is not defined, the lambda will not be updated automatically if the code in the bucket is updated.
  This is because CDK/Cloudformation does not track changes on the source S3 Bucket. It is recommended to either use S3Code.fromAsset() instead or set objectVersion.

  **Parameters**

  - `bucket` — The S3 bucket.
  - `key` — The object key.
  - `objectVersion` — Optional S3 object version.

- `fromBucketV2(bucket: IBucket, key: string, options?: BucketOptions): S3CodeV2` (static) — Lambda handler code as an S3 object.

  Note: If `options.objectVersion` is not defined, the lambda will not be updated automatically if the code in the bucket is updated.
  This is because CDK/Cloudformation does not track changes on the source S3 Bucket. It is recommended to either use S3Code.fromAsset() instead or set objectVersion.

  **Parameters**

  - `bucket` — The S3 bucket.
  - `key` — The object key.
  - `options` — Optional parameters for setting the code, current optional parameters to set here are 1.

- `fromCfnParameters(props?: CfnParametersCodeProps): CfnParametersCode // chainable` (static) — Creates a new Lambda source defined using CloudFormation parameters.

  **Parameters**

  - `props` — optional construction properties of `CfnParametersCode`.

  **Returns:** a new instance of `CfnParametersCode`

- `fromCustomCommand(output: string, command: string[], options?: CustomCommandOptions): AssetCode` (static) — Runs a command to build the code asset that will be used.

  **Parameters**

  - `output` — Where the output of the command will be directed, either a directory or a .zip file with the output Lambda code bundle * For example, if you use the command to run a build script (e.g., [ 'node', 'bundle_code.js' ]), and the build script generates a directory `/my/lambda/code` containing code that should be ran in a Lambda function, then output should be set to `/my/lambda/code`.
  - `command` — The command which will be executed to generate the output, for example, [ 'node', 'bundle_code.js' ].
  - `options` — options for the custom command, and other asset options -- but bundling options are not allowed.

- `fromDockerBuild(path: string, options?: DockerBuildAssetOptions): AssetCode` (static) — 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.

  **Parameters**

  - `path` — The path to the directory containing the Docker file.
  - `options` — Docker build options.

- `fromEcrImage(repository: IRepository, props?: EcrImageCodeProps): EcrImageCode` (static) — Use an existing ECR image as the Lambda code.

  **Parameters**

  - `repository` — the ECR repository that the image is in.
  - `props` — properties to further configure the selected image.

- `fromInline(code: string): InlineCode` (static) — Inline code for Lambda handler.

  **Parameters**

  - `code` — The actual handler code (the resulting zip file cannot exceed 4MB).

  **Returns:** `LambdaInlineCode` with inline code.
