# API Reference
## Constructs
### Ec2Deployer
Represents a Deployer resource for deploying an artifact to EC2 using CodeDeploy.
#### Initializers
```typescript
import { Ec2Deployer } from 'cdk-deployer'
new Ec2Deployer(scope: Construct, id: string, props: Ec2DeployerProps)
```
##### `scope`Required
- *Type:* [`@aws-cdk/core.Construct`](#@aws-cdk/core.Construct)
---
##### `id`Required
- *Type:* `string`
---
##### `props`Required
- *Type:* [`cdk-deployer.Ec2DeployerProps`](#cdk-deployer.Ec2DeployerProps)
---
#### Properties
##### `code`Required
```typescript
public readonly code: CodeConfig;
```
- *Type:* [`cdk-deployer.CodeConfig`](#cdk-deployer.CodeConfig)
The source code to be deployed.
---
##### `deploymentGroup`Required
```typescript
public readonly deploymentGroup: IServerDeploymentGroup;
```
- *Type:* [`@aws-cdk/aws-codedeploy.IServerDeploymentGroup`](#@aws-cdk/aws-codedeploy.IServerDeploymentGroup)
The deployment group being deployed to.
---
##### `waitToComplete`Required
```typescript
public readonly waitToComplete: boolean;
```
- *Type:* `boolean`
Whether the enclosing stack will wait for the deployment to complete.
---
##### `deploymentTimeout`Optional
```typescript
public readonly deploymentTimeout: Duration;
```
- *Type:* [`@aws-cdk/core.Duration`](#@aws-cdk/core.Duration)
Amount of time the stack will wait for the deployment operation to complete.
---
##### `instanceRoles`Optional
```typescript
public readonly instanceRoles: IRole[];
```
- *Type:* [`@aws-cdk/aws-iam.IRole`](#@aws-cdk/aws-iam.IRole)[]
The IAM roles associated with the target instances to be deployed to.
This is used to ensure the target instances have the appropriate permissions to download the deployment artifact from S3.
This prop is only required when the instance roles cannot be dynamically pulled from the supplied deploymentGroup's autoScalingGroups property,
for example when deploymentGroup is of type IServerDeploymentGroup or if the deploymentGroup is not associated with an ASG.
---
#### Constants
##### `MAX_DEPLOYMENT_TIMEOUT`
- *Type:* [`@aws-cdk/core.Duration`](#@aws-cdk/core.Duration)
Maximum allowed value for deploymentTimeout prop.
---
## Structs
### CodeConfig
Result of binding `Code` into a `Ec2Deployer`.
#### Initializer
```typescript
import { CodeConfig } from 'cdk-deployer'
const codeConfig: CodeConfig = { ... }
```
##### `s3Location`Required
```typescript
public readonly s3Location: Location;
```
- *Type:* [`@aws-cdk/aws-s3.Location`](#@aws-cdk/aws-s3.Location)
- *Default:* code is an s3 location
The location of the code in S3.
---
### Ec2DeployerProps
Construction properties for the Ec2Deployer object.
#### Initializer
```typescript
import { Ec2DeployerProps } from 'cdk-deployer'
const ec2DeployerProps: Ec2DeployerProps = { ... }
```
##### `code`Required
```typescript
public readonly code: Code;
```
- *Type:* [`cdk-deployer.Code`](#cdk-deployer.Code)
The source code to be deployed.
---
##### `deploymentGroup`Required
```typescript
public readonly deploymentGroup: IServerDeploymentGroup;
```
- *Type:* [`@aws-cdk/aws-codedeploy.IServerDeploymentGroup`](#@aws-cdk/aws-codedeploy.IServerDeploymentGroup)
The deployment group to deploy the artifact to.
---
##### `deploymentTimeout`Optional
```typescript
public readonly deploymentTimeout: Duration;
```
- *Type:* [`@aws-cdk/core.Duration`](#@aws-cdk/core.Duration)
- *Default:* 5 minutes
Amount of time the stack will wait for the deployment operation to complete, for a maximum of 2 hours.
Has no effect if waitToComplete = false.
---
##### `instanceRoles`Optional
```typescript
public readonly instanceRoles: IRole[];
```
- *Type:* [`@aws-cdk/aws-iam.IRole`](#@aws-cdk/aws-iam.IRole)[]
- *Default:* gets the instance roles from serverDeploymentGroup.autoScalingGroups[].role
The IAM roles associated with the target instances to be deployed to.
This is used to ensure the target instances have the appropriate permissions to download the deployment artifact from S3.
This prop is only required when the instance roles cannot be dynamically pulled from the supplied deploymentGroup's autoScalingGroups property,
for example when deploymentGroup is of type IServerDeploymentGroup or if the deploymentGroup is not associated with an ASG.
---
##### `waitToComplete`Optional
```typescript
public readonly waitToComplete: boolean;
```
- *Type:* `boolean`
- *Default:* true
Whether the enclosing stack should wait for the deployment to complete.
---
### ResourceBindOptions
#### Initializer
```typescript
import { ResourceBindOptions } from 'cdk-deployer'
const resourceBindOptions: ResourceBindOptions = { ... }
```
##### `resourceProperty`Optional
```typescript
public readonly resourceProperty: string;
```
- *Type:* `string`
- *Default:* Code
The name of the CloudFormation property to annotate with asset metadata.
> https://github.com/aws/aws-cdk/issues/1432
---
## Classes
### AssetCode
Application code from a local directory.
#### Initializers
```typescript
import { AssetCode } from 'cdk-deployer'
new AssetCode(path: string, options?: AssetOptions)
```
##### `path`Required
- *Type:* `string`
The path to the asset file or directory.
---
##### `options`Optional
- *Type:* [`@aws-cdk/aws-s3-assets.AssetOptions`](#@aws-cdk/aws-s3-assets.AssetOptions)
---
#### Methods
##### `bind`
```typescript
public bind(scope: Construct)
```
###### `scope`Required
- *Type:* [`@aws-cdk/core.Construct`](#@aws-cdk/core.Construct)
---
#### Properties
##### `path`Required
```typescript
public readonly path: string;
```
- *Type:* `string`
The path to the asset file or directory.
---
### Code
Represents the Application Code.
#### Initializers
```typescript
import { Code } from 'cdk-deployer'
new Code()
```
#### Methods
##### `bind`
```typescript
public bind(scope: Construct)
```
###### `scope`Required
- *Type:* [`@aws-cdk/core.Construct`](#@aws-cdk/core.Construct)
The binding scope.
Don't be smart about trying to down-cast or
assume it's initialized. You may just use it as a construct scope.
---
#### Static Functions
##### `fromAsset`
```typescript
import { Code } from 'cdk-deployer'
Code.fromAsset(path: string, options?: AssetOptions)
```
###### `path`Required
- *Type:* `string`
Either a directory with the application code bundle or a .zip file.
---
###### `options`Optional
- *Type:* [`@aws-cdk/aws-s3-assets.AssetOptions`](#@aws-cdk/aws-s3-assets.AssetOptions)
---
##### `fromBucket`
```typescript
import { Code } from 'cdk-deployer'
Code.fromBucket(bucket: IBucket, key: string, objectVersion?: string)
```
###### `bucket`Required
- *Type:* [`@aws-cdk/aws-s3.IBucket`](#@aws-cdk/aws-s3.IBucket)
The S3 bucket.
---
###### `key`Required
- *Type:* `string`
The object key.
---
###### `objectVersion`Optional
- *Type:* `string`
Optional S3 object version.
---
### S3Code
Application code from an S3 archive.
#### Initializers
```typescript
import { S3Code } from 'cdk-deployer'
new S3Code(bucket: IBucket, key: string, objectVersion?: string)
```
##### `bucket`Required
- *Type:* [`@aws-cdk/aws-s3.IBucket`](#@aws-cdk/aws-s3.IBucket)
---
##### `key`Required
- *Type:* `string`
---
##### `objectVersion`Optional
- *Type:* `string`
---
#### Methods
##### `bind`
```typescript
public bind(_scope: Construct)
```
###### `_scope`Required
- *Type:* [`@aws-cdk/core.Construct`](#@aws-cdk/core.Construct)
---
#### Properties
##### `isInline`Required
```typescript
public readonly isInline: boolean;
```
- *Type:* `boolean`
---