aws-cdk-lib.aws_ec2.InitSource

class InitSource

LanguageType name
.NETAmazon.CDK.AWS.EC2.InitSource
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#InitSource
Javasoftware.amazon.awscdk.services.ec2.InitSource
Pythonaws_cdk.aws_ec2.InitSource
TypeScript (source)aws-cdk-lib » aws_ec2 » InitSource

Extends InitElement

Extract an archive into a directory.

Example

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,
  })
);

Initializer (protected)

super(targetDirectory: string, serviceHandles?: InitServiceRestartHandle[])

Parameters

  • targetDirectory string
  • serviceHandles InitServiceRestartHandle[]

Properties

NameTypeDescription
elementTypestringReturns the init element type for this element.

elementType

Type: string

Returns the init element type for this element.

Methods

NameDescription
static fromAsset(targetDirectory, path, options?)Create an InitSource from an asset created from the given path.
static fromExistingAsset(targetDirectory, asset, options?)Extract a directory from an existing directory asset.
static fromGitHub(targetDirectory, owner, repo, refSpec?, options?)Extract a GitHub branch into a given directory.
static fromS3Object(targetDirectory, bucket, key, options?)Extract an archive stored in an S3 bucket into the given directory.
static fromUrl(targetDirectory, url, options?)Retrieve a URL and extract it into the given directory.

static fromAsset(targetDirectory, path, options?)

public static fromAsset(targetDirectory: string, path: string, options?: InitSourceAssetOptions): InitSource

Parameters

  • targetDirectory string
  • path string
  • options InitSourceAssetOptions

Returns

  • InitSource

Create an InitSource from an asset created from the given path.


static fromExistingAsset(targetDirectory, asset, options?)

public static fromExistingAsset(targetDirectory: string, asset: Asset, options?: InitSourceOptions): InitSource

Parameters

  • targetDirectory string
  • asset Asset
  • options InitSourceOptions

Returns

  • InitSource

Extract a directory from an existing directory asset.


static fromGitHub(targetDirectory, owner, repo, refSpec?, options?)

public static fromGitHub(targetDirectory: string, owner: string, repo: string, refSpec?: string, options?: InitSourceOptions): InitSource

Parameters

  • targetDirectory string
  • owner string
  • repo string
  • refSpec string
  • options InitSourceOptions

Returns

  • InitSource

Extract a GitHub branch into a given directory.


static fromS3Object(targetDirectory, bucket, key, options?)

public static fromS3Object(targetDirectory: string, bucket: IBucket, key: string, options?: InitSourceOptions): InitSource

Parameters

  • targetDirectory string
  • bucket IBucket
  • key string
  • options InitSourceOptions

Returns

  • InitSource

Extract an archive stored in an S3 bucket into the given directory.


static fromUrl(targetDirectory, url, options?)

public static fromUrl(targetDirectory: string, url: string, options?: InitSourceOptions): InitSource

Parameters

  • targetDirectory string
  • url string
  • options InitSourceOptions

Returns

  • InitSource

Retrieve a URL and extract it into the given directory.