# InlineCode

Canary code from an inline string.

Extends: Code › InlineCode

- Source: [`aws-synthetics/lib/code.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-synthetics/lib/code.ts#L200)
- Type last changed: v2.177.0 · 25 Jan 2025

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_synthetics as synthetics } from 'aws-cdk-lib';
const inlineCode = new synthetics.InlineCode('code');
```

## Initializer

```ts
new InlineCode(code: string)
```

## Methods

- `bind(scope: Construct, handler: string, _family: RuntimeFamily, _runtimeName?: string): CodeConfig` — Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.

- `fromAsset(assetPath: string, options?: AssetOptions): AssetCode` (static) — Specify code from a local path.

  Path must include the folder structure `nodejs/node_modules/myCanaryFilename.js`.

  **Parameters**

  - `assetPath` — Either a directory or a .zip file.

  **Returns:** `AssetCode` associated with the specified path.

- `fromBucket(bucket: IBucketRef, key: string, objectVersion?: string): S3Code` (static) — Specify code from an s3 bucket.

  The object in the s3 bucket must be a .zip file that contains
  the structure `nodejs/node_modules/myCanaryFilename.js`.

  **Parameters**

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

  **Returns:** `S3Code` associated with the specified S3 object.

- `fromInline(code: string): InlineCode // chainable` (static) — Specify code inline.

  **Parameters**

  - `code` — The actual handler code (limited to 5MB).

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