diff --git a/API.md b/API.md index 9b44013b..397cdbd0 100644 --- a/API.md +++ b/API.md @@ -1,176 +1,514 @@ -# API Reference +# API Reference -**Classes** +## Constructs -Name|Description -----|----------- -[DockerImageName](#cdk-ecr-deployment-dockerimagename)|*No description* -[ECRDeployment](#cdk-ecr-deployment-ecrdeployment)|*No description* -[S3ArchiveName](#cdk-ecr-deployment-s3archivename)|*No description* +### ECRDeployment +#### Initializers -**Structs** +```typescript +import { ECRDeployment } from 'cdk-ecr-deployment' -Name|Description -----|----------- -[ECRDeploymentProps](#cdk-ecr-deployment-ecrdeploymentprops)|*No description* +new ECRDeployment(scope: Construct, id: string, props: ECRDeploymentProps) +``` +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | ECRDeploymentProps | *No description.* | -**Interfaces** +--- -Name|Description -----|----------- -[IImageName](#cdk-ecr-deployment-iimagename)|*No description* +##### `scope`Required +- *Type:* constructs.Construct +--- -## class DockerImageName +##### `id`Required +- *Type:* string +--- -__Implements__: [IImageName](#cdk-ecr-deployment-iimagename) +##### `props`Required -### Initializer +- *Type:* ECRDeploymentProps +--- +#### Methods +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| addToPrincipalPolicy | *No description.* | -```ts -new DockerImageName(name: string, creds?: string) +--- + +##### `toString` + +```typescript +public toString(): string ``` -* **name** (string) *No description* -* **creds** (string) The credentials of the docker image. +Returns a string representation of this construct. +##### `addToPrincipalPolicy` +```typescript +public addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResult +``` -### Properties +###### `statement`Required +- *Type:* aws-cdk-lib.aws_iam.PolicyStatement -Name | Type | Description ------|------|------------- -**uri** | string | The uri of the docker image. -**creds**? | string | The credentials of the docker image.
__*Optional*__ +--- +#### Static Functions +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | -## class ECRDeployment +--- +##### `isConstruct` +```typescript +import { ECRDeployment } from 'cdk-ecr-deployment' -__Implements__: [IConstruct](#constructs-iconstruct), [IDependable](#constructs-idependable) -__Extends__: [Construct](#constructs-construct) +ECRDeployment.isConstruct(x: any) +``` -### Initializer +Checks if `x` is a construct. +Use this method instead of `instanceof` to properly detect `Construct` +instances, even when the construct library is symlinked. +Explanation: in JavaScript, multiple copies of the `constructs` library on +disk are seen as independent, completely different libraries. As a +consequence, the class `Construct` in each copy of the `constructs` library +is seen as a different class, and an instance of one class will not test as +`instanceof` the other class. `npm install` will not create installations +like this, but users may manually symlink construct libraries together or +use a monorepo tool: in those cases, multiple copies of the `constructs` +library can be accidentally installed, and `instanceof` will behave +unpredictably. It is safest to avoid using `instanceof`, and using +this type-testing method instead. +###### `x`Required -```ts -new ECRDeployment(scope: Construct, id: string, props: ECRDeploymentProps) +- *Type:* any + +Any object. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + + +## Structs + +### ECRDeploymentProps + +#### Initializer + +```typescript +import { ECRDeploymentProps } from 'cdk-ecr-deployment' + +const eCRDeploymentProps: ECRDeploymentProps = { ... } +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| dest | IImageName | The destination of the docker image. | +| src | IImageName | The source of the docker image. | +| buildImage | string | Image to use to build Golang lambda for custom resource, if download fails or is not wanted. | +| environment | {[ key: string ]: string} | The environment variable to set. | +| lambdaHandler | string | The name of the lambda handler. | +| lambdaRuntime | aws-cdk-lib.aws_lambda.Runtime | The lambda function runtime environment. | +| memoryLimit | number | The amount of memory (in MiB) to allocate to the AWS Lambda function which replicates the files from the CDK bucket to the destination bucket. | +| role | aws-cdk-lib.aws_iam.IRole | Execution role associated with this function. | +| securityGroups | aws-cdk-lib.aws_ec2.SecurityGroup[] | The list of security groups to associate with the Lambda's network interfaces. | +| vpc | aws-cdk-lib.aws_ec2.IVpc | The VPC network to place the deployment lambda handler in. | +| vpcSubnets | aws-cdk-lib.aws_ec2.SubnetSelection | Where in the VPC to place the deployment lambda handler. | + +--- + +##### `dest`Required + +```typescript +public readonly dest: IImageName; +``` + +- *Type:* IImageName + +The destination of the docker image. + +--- + +##### `src`Required + +```typescript +public readonly src: IImageName; +``` + +- *Type:* IImageName + +The source of the docker image. + +--- + +##### `buildImage`Optional + +```typescript +public readonly buildImage: string; +``` + +- *Type:* string +- *Default:* public.ecr.aws/sam/build-go1.x:latest + +Image to use to build Golang lambda for custom resource, if download fails or is not wanted. + +Might be needed for local build if all images need to come from own registry. + +Note that image should use yum as a package manager and have golang available. + +--- + +##### `environment`Optional + +```typescript +public readonly environment: {[ key: string ]: string}; +``` + +- *Type:* {[ key: string ]: string} + +The environment variable to set. + +--- + +##### `lambdaHandler`Optional + +```typescript +public readonly lambdaHandler: string; +``` + +- *Type:* string +- *Default:* bootstrap + +The name of the lambda handler. + +--- + +##### `lambdaRuntime`Optional + +```typescript +public readonly lambdaRuntime: Runtime; +``` + +- *Type:* aws-cdk-lib.aws_lambda.Runtime +- *Default:* lambda.Runtime.PROVIDED_AL2023 + +The lambda function runtime environment. + +--- + +##### `memoryLimit`Optional + +```typescript +public readonly memoryLimit: number; +``` + +- *Type:* number +- *Default:* 512 + +The amount of memory (in MiB) to allocate to the AWS Lambda function which replicates the files from the CDK bucket to the destination bucket. + +If you are deploying large files, you will need to increase this number +accordingly. + +--- + +##### `role`Optional + +```typescript +public readonly role: IRole; +``` + +- *Type:* aws-cdk-lib.aws_iam.IRole +- *Default:* A role is automatically created + +Execution role associated with this function. + +--- + +##### `securityGroups`Optional + +```typescript +public readonly securityGroups: SecurityGroup[]; ``` -* **scope** ([Construct](#constructs-construct)) *No description* -* **id** (string) *No description* -* **props** ([ECRDeploymentProps](#cdk-ecr-deployment-ecrdeploymentprops)) *No description* - * **dest** ([IImageName](#cdk-ecr-deployment-iimagename)) The destination of the docker image. - * **src** ([IImageName](#cdk-ecr-deployment-iimagename)) The source of the docker image. - * **buildImage** (string) Image to use to build Golang lambda for custom resource, if download fails or is not wanted. __*Default*__: public.ecr.aws/sam/build-go1.x:latest - * **environment** (Map) The environment variable to set. __*Optional*__ - * **lambdaHandler** (string) The name of the lambda handler. __*Default*__: bootstrap - * **lambdaRuntime** ([aws_lambda.Runtime](#aws-cdk-lib-aws-lambda-runtime)) The lambda function runtime environment. __*Default*__: lambda.Runtime.PROVIDED_AL2023 - * **memoryLimit** (number) The amount of memory (in MiB) to allocate to the AWS Lambda function which replicates the files from the CDK bucket to the destination bucket. __*Default*__: 512 - * **role** ([aws_iam.IRole](#aws-cdk-lib-aws-iam-irole)) Execution role associated with this function. __*Default*__: A role is automatically created - * **securityGroups** (Array<[aws_ec2.SecurityGroup](#aws-cdk-lib-aws-ec2-securitygroup)>) The list of security groups to associate with the Lambda's network interfaces. __*Default*__: If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function. - * **vpc** ([aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc)) The VPC network to place the deployment lambda handler in. __*Default*__: None - * **vpcSubnets** ([aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)) Where in the VPC to place the deployment lambda handler. __*Default*__: the Vpc default strategy if not specified +- *Type:* aws-cdk-lib.aws_ec2.SecurityGroup[] +- *Default:* If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function. + +The list of security groups to associate with the Lambda's network interfaces. + +Only used if 'vpc' is supplied. + +--- + +##### `vpc`Optional + +```typescript +public readonly vpc: IVpc; +``` + +- *Type:* aws-cdk-lib.aws_ec2.IVpc +- *Default:* None + +The VPC network to place the deployment lambda handler in. + +--- + +##### `vpcSubnets`Optional + +```typescript +public readonly vpcSubnets: SubnetSelection; +``` + +- *Type:* aws-cdk-lib.aws_ec2.SubnetSelection +- *Default:* the Vpc default strategy if not specified + +Where in the VPC to place the deployment lambda handler. + +Only used if 'vpc' is supplied. + +--- + +## Classes + +### DockerImageName + +- *Implements:* IImageName + +#### Initializers + +```typescript +import { DockerImageName } from 'cdk-ecr-deployment' + +new DockerImageName(name: string, creds?: string) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| name | string | *No description.* | +| creds | string | The credentials of the docker image. | + +--- + +##### `name`Required + +- *Type:* string + +--- +##### `creds`Optional -### Methods +- *Type:* string +The credentials of the docker image. -#### addToPrincipalPolicy(statement) +Format `user:password` or `AWS Secrets Manager secret arn` or `AWS Secrets Manager secret name` +--- -```ts -addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResult + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| uri | string | The uri of the docker image. | +| creds | string | The credentials of the docker image. | + +--- + +##### `uri`Required + +```typescript +public readonly uri: string; ``` -* **statement** ([aws_iam.PolicyStatement](#aws-cdk-lib-aws-iam-policystatement)) *No description* +- *Type:* string -__Returns__: -* [aws_iam.AddToPrincipalPolicyResult](#aws-cdk-lib-aws-iam-addtoprincipalpolicyresult) +The uri of the docker image. +The uri spec follows https://github.com/containers/skopeo +--- -## class S3ArchiveName +##### `creds`Optional +```typescript +public readonly creds: string; +``` + +- *Type:* string + +The credentials of the docker image. +Format `user:password` or `AWS Secrets Manager secret arn` or `AWS Secrets Manager secret name` -__Implements__: [IImageName](#cdk-ecr-deployment-iimagename) +--- -### Initializer +### S3ArchiveName +- *Implements:* IImageName +#### Initializers + +```typescript +import { S3ArchiveName } from 'cdk-ecr-deployment' -```ts new S3ArchiveName(p: string, ref?: string, creds?: string) ``` -* **p** (string) *No description* -* **ref** (string) *No description* -* **creds** (string) The credentials of the docker image. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| p | string | *No description.* | +| ref | string | *No description.* | +| creds | string | The credentials of the docker image. | + +--- +##### `p`Required +- *Type:* string -### Properties +--- +##### `ref`Optional -Name | Type | Description ------|------|------------- -**uri** | string | The uri of the docker image. -**creds**? | string | The credentials of the docker image.
__*Optional*__ +- *Type:* string +--- +##### `creds`Optional -## struct ECRDeploymentProps +- *Type:* string +The credentials of the docker image. +Format `user:password` or `AWS Secrets Manager secret arn` or `AWS Secrets Manager secret name` +--- -Name | Type | Description ------|------|------------- -**dest** | [IImageName](#cdk-ecr-deployment-iimagename) | The destination of the docker image. -**src** | [IImageName](#cdk-ecr-deployment-iimagename) | The source of the docker image. -**buildImage**? | string | Image to use to build Golang lambda for custom resource, if download fails or is not wanted.
__*Default*__: public.ecr.aws/sam/build-go1.x:latest -**environment**? | Map | The environment variable to set.
__*Optional*__ -**lambdaHandler**? | string | The name of the lambda handler.
__*Default*__: bootstrap -**lambdaRuntime**? | [aws_lambda.Runtime](#aws-cdk-lib-aws-lambda-runtime) | The lambda function runtime environment.
__*Default*__: lambda.Runtime.PROVIDED_AL2023 -**memoryLimit**? | number | The amount of memory (in MiB) to allocate to the AWS Lambda function which replicates the files from the CDK bucket to the destination bucket.
__*Default*__: 512 -**role**? | [aws_iam.IRole](#aws-cdk-lib-aws-iam-irole) | Execution role associated with this function.
__*Default*__: A role is automatically created -**securityGroups**? | Array<[aws_ec2.SecurityGroup](#aws-cdk-lib-aws-ec2-securitygroup)> | The list of security groups to associate with the Lambda's network interfaces.
__*Default*__: If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function. -**vpc**? | [aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc) | The VPC network to place the deployment lambda handler in.
__*Default*__: None -**vpcSubnets**? | [aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection) | Where in the VPC to place the deployment lambda handler.
__*Default*__: the Vpc default strategy if not specified +#### Properties +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| uri | string | The uri of the docker image. | +| creds | string | The credentials of the docker image. | +--- -## interface IImageName +##### `uri`Required + +```typescript +public readonly uri: string; +``` + +- *Type:* string + +The uri of the docker image. + +The uri spec follows https://github.com/containers/skopeo + +--- + +##### `creds`Optional + +```typescript +public readonly creds: string; +``` -__Implemented by__: [DockerImageName](#cdk-ecr-deployment-dockerimagename), [S3ArchiveName](#cdk-ecr-deployment-s3archivename) +- *Type:* string +The credentials of the docker image. +Format `user:password` or `AWS Secrets Manager secret arn` or `AWS Secrets Manager secret name` -### Properties +--- + + +## Protocols + +### IImageName + +- *Implemented By:* DockerImageName, S3ArchiveName, IImageName + + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| uri | string | The uri of the docker image. | +| creds | string | The credentials of the docker image. | + +--- + +##### `uri`Required + +```typescript +public readonly uri: string; +``` + +- *Type:* string + +The uri of the docker image. + +The uri spec follows https://github.com/containers/skopeo + +--- + +##### `creds`Optional + +```typescript +public readonly creds: string; +``` +- *Type:* string -Name | Type | Description ------|------|------------- -**uri** | string | The uri of the docker image. -**creds**? | string | The credentials of the docker image.
__*Optional*__ +The credentials of the docker image. +Format `user:password` or `AWS Secrets Manager secret arn` or `AWS Secrets Manager secret name` +---