# InitSource

Extract an archive into a directory.

Extends: InitElement › InitSource

- Source: [`aws-ec2/lib/cfn-init-elements.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts#L914)

## Example

```ts
declare const myBucket: s3.Bucket;

const handle = new ec2.InitServiceRestartHandle();

ec2.CloudFormationInit.fromElements(
  ec2.InitFile.fromString('/etc/nginx/nginx.conf', '...', { serviceRestartHandles: [handle] }),
  ec2.InitSource.fromS3Object('/var/www/html', myBucket, 'html.zip', { serviceRestartHandles: [handle] }),
  ec2.InitService.enable('nginx', {
    serviceRestartHandle: handle,
  })
);
```

## Properties

- `elementType`: string — Returns the init element type for this element.

## Methods

- `fromAsset(targetDirectory: string, path: string, options?: InitSourceAssetOptions): InitSource // chainable` (static) — Create an InitSource from an asset created from the given path.

- `fromExistingAsset(targetDirectory: string, asset: Asset, options?: InitSourceOptions): InitSource // chainable` (static) — Extract a directory from an existing directory asset.

- `fromGitHub(targetDirectory: string, owner: string, repo: string, refSpec?: string, options?: InitSourceOptions): InitSource // chainable` (static) — Extract a GitHub branch into a given directory.

- `fromS3Object(targetDirectory: string, bucket: IBucket, key: string, options?: InitSourceOptions): InitSource // chainable` (static) — Extract an archive stored in an S3 bucket into the given directory.

- `fromUrl(targetDirectory: string, url: string, options?: InitSourceOptions): InitSource // chainable` (static) — Retrieve a URL and extract it into the given directory.
