# InlineCode

Canary code from an inline string.

Extends: [Code](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.Code.html) › InlineCode
Obtainable from: [Code.fromInline](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.Code.html#frominline)

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

## Example

TypeScript:

```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');
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_synthetics as synthetics

inline_code = synthetics.InlineCode("code")
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.synthetics.*;

InlineCode inlineCode = new InlineCode("code");
```

C# / .NET:

```csharp
// 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.AWS.Synthetics;

var inlineCode = new InlineCode("code");
```

Golang:

```go
// 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"

inlineCode := awscdk.Aws_synthetics.NewInlineCode(jsii.String("code"))
```

## Initializer

TypeScript:

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

Python:

```python
InlineCode(code: str)
```

Java:

```java
new InlineCode(String code)
```

C# / .NET:

```csharp
new InlineCode(string code)
```

Golang:

```go
NewInlineCode(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.
