token-injectable-docker-builder 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +178 -22
- package/API.md +189 -0
- package/README.md +140 -6
- package/isComplete/isComplete.js +3 -2
- package/lib/index.d.ts +49 -0
- package/lib/index.js +133 -51
- package/package.json +1 -1
package/.jsii
CHANGED
|
@@ -8536,7 +8536,7 @@
|
|
|
8536
8536
|
},
|
|
8537
8537
|
"name": "token-injectable-docker-builder",
|
|
8538
8538
|
"readme": {
|
|
8539
|
-
"markdown": "# TokenInjectableDockerBuilder\n\nThe `TokenInjectableDockerBuilder` is a flexible AWS CDK construct that enables the usage of AWS CDK tokens in the building, pushing, and deployment of Docker images to Amazon Elastic Container Registry (ECR). It leverages AWS CodeBuild and Lambda custom resources.\n\n---\n\n## Why?\n\nAWS CDK already provides mechanisms for creating deployable assets using Docker, such as [DockerImageAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerImageAsset.html) and [DockerImageCode](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.DockerImageCode.html), but these constructs are limited because they cannot accept CDK tokens as build-args. The `TokenInjectableDockerBuilder` allows injecting CDK tokens as build-time arguments into Docker-based assets, enabling more dynamic dependency relationships.\n\nFor example, a Next.js frontend Docker image may require an API Gateway URL as an argument to create a reference from the UI to the associated API in a given deployment. With this construct, you can deploy the API Gateway first, then pass its URL as a build-time argument to the Next.js Docker image. As a result, your Next.js frontend can dynamically fetch data from the API Gateway without hardcoding the URL or needing multiple separate stacks.\n\n---\n\n## Features\n\n- **Build and Push Docker Images**: Automatically builds and pushes Docker images to ECR.\n- **Token Support**: Supports custom build arguments for Docker builds, including CDK tokens resolved at deployment time.\n- **Custom Install and Pre-Build Commands**: Allows specifying custom commands to run during the `install` and `pre_build` phases of the CodeBuild build process.\n- **VPC Configuration**: Supports deploying the CodeBuild project within a VPC, with customizable security groups and subnet selection.\n- **Docker Login**: Supports Docker login using credentials stored in AWS Secrets Manager.\n- **ECR Repository Management**: Creates an ECR repository with lifecycle rules and encryption.\n- **Integration with ECS and Lambda**: Provides outputs for use in AWS ECS and AWS Lambda.\n- **Custom Build Query Interval**: Configure how frequently the custom resource polls for build completion using the `completenessQueryInterval` property (defaults to 30 seconds).\n- **Custom Dockerfile**: Specify a custom Dockerfile name via the `file` property (e.g. `Dockerfile.production`), allowing multiple Docker images from the same source directory.\n- **ECR Docker Layer Caching**: By default, builds use `docker buildx` with ECR as a remote cache backend, reducing build times by reusing layers across deploys. Set `cacheDisabled: true` to force a clean build from scratch.\n- **Persistent Build Logs**: Pass `buildLogGroup` with a log group that has RETAIN removal policy so build logs survive rollbacks and stack deletion for debugging.\n\n---\n\n## Installation\n\n### For NPM\n\nInstall the construct using NPM:\n\n```bash\nnpm install token-injectable-docker-builder\n```\n\n### For Python\n\nInstall the construct using pip:\n\n```bash\npip install token-injectable-docker-builder\n```\n\n---\n\n## Constructor\n\n### `TokenInjectableDockerBuilder`\n\n#### Parameters\n\n- **`scope`**: The construct's parent scope.\n- **`id`**: The construct ID.\n- **`props`**: Configuration properties.\n\n#### Properties in `TokenInjectableDockerBuilderProps`\n\n| Property | Type | Required | Description |\n|----------------------------|-----------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `path` | `string` | Yes | The file path to the Dockerfile or source code directory. |\n| `buildArgs` | `{ [key: string]: string }` | No | Build arguments to pass to the Docker build process. These are transformed into `--build-arg` flags. To use in Dockerfile, leverage the `ARG` keyword. For more details, please see the [official Docker docs](https://docs.docker.com/build/building/variables/). |\n| `dockerLoginSecretArn` | `string` | No | ARN of an AWS Secrets Manager secret for Docker credentials. Skips login if not provided. |\n| `vpc` | `IVpc` | No | The VPC in which the CodeBuild project will be deployed. If provided, the CodeBuild project will be launched within the specified VPC. |\n| `securityGroups` | `ISecurityGroup[]` | No | The security groups to attach to the CodeBuild project. These should define the network access rules for the CodeBuild project. |\n| `subnetSelection` | `SubnetSelection` | No | The subnet selection to specify which subnets to use within the VPC. Allows the user to select private, public, or isolated subnets. |\n| `installCommands` | `string[]` | No | Custom commands to run during the `install` phase of the CodeBuild build process. Will be executed before the Docker image is built. Useful for installing necessary dependencies for running pre-build scripts. |\n| `preBuildCommands` | `string[]` | No | Custom commands to run during the `pre_build` phase of the CodeBuild build process. Will be executed before the Docker image is built. Useful for running pre-build scripts, such as fetching configs. |\n| `kmsEncryption` | `boolean` | No | Whether to enable KMS encryption for the ECR repository. If `true`, a KMS key will be created for encrypting ECR images; otherwise, AES-256 encryption is used. Defaults to `false`. |\n| `completenessQueryInterval`| `Duration` | No | The query interval for checking if the CodeBuild project has completed. This determines how frequently the custom resource polls for build completion. Defaults to `Duration.seconds(30)`. |\n| `exclude` | `string[]` | No | A list of file paths in the Docker directory to exclude from the S3 asset bundle. If a `.dockerignore` file is present in the source directory, its contents will be used if this prop is not set. Defaults to an empty list or `.dockerignore` contents. |\n| `file` | `string` | No | The name of the Dockerfile to use for the build. Passed as `--file` to `docker build`. Useful when a project has multiple Dockerfiles (e.g. `Dockerfile.production`, `Dockerfile.admin`). Defaults to `Dockerfile`. |\n| `cacheDisabled` | `boolean` | No | When `true`, disables Docker layer caching. Every build runs from scratch. Use for debugging, corrupted cache, or major dependency changes. Defaults to `false`. |\n| `buildLogGroup` | `ILogGroup` | No | CloudWatch log group for CodeBuild build logs. When provided with RETAIN removal policy, logs survive rollbacks and stack deletion. If not provided, CodeBuild uses default logging (logs are deleted on rollback). |\n\n---\n\n## Usage Examples\n\n### Simple Usage Example\n\nThis example demonstrates the basic usage of the `TokenInjectableDockerBuilder`, where a Next.js frontend Docker image requires an API Gateway URL as a build argument to create a reference from the UI to the associated API in a given deployment.\n\n#### TypeScript/NPM Example\n\n```typescript\nimport * as cdk from 'aws-cdk-lib';\nimport { TokenInjectableDockerBuilder } from 'token-injectable-docker-builder';\nimport * as ecs from 'aws-cdk-lib/aws-ecs';\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as apigateway from 'aws-cdk-lib/aws-apigateway';\n\nexport class SimpleStack extends cdk.Stack {\n constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n\n // Create your API Gateway\n const api = new apigateway.RestApi(this, 'MyApiGateway', {\n restApiName: 'MyService',\n });\n\n // Create the Docker builder\n const dockerBuilder = new TokenInjectableDockerBuilder(this, 'SimpleDockerBuilder', {\n path: './nextjs-app', // Path to your Next.js app Docker context\n buildArgs: {\n API_URL: api.url, // Pass the API Gateway URL as a build argument\n },\n // Optionally override the default completeness query interval:\n // completenessQueryInterval: cdk.Duration.seconds(45),\n });\n\n // Use in ECS\n const cluster = new ecs.Cluster(this, 'EcsCluster', {\n vpc: new ec2.Vpc(this, 'Vpc'),\n });\n\n const service = new ecs.FargateService(this, 'FargateService', {\n cluster,\n taskDefinition: new ecs.FargateTaskDefinition(this, 'TaskDef', {\n cpu: 512,\n memoryLimitMiB: 1024,\n }).addContainer('Container', {\n image: dockerBuilder.containerImage,\n logging: ecs.LogDriver.awsLogs({ streamPrefix: 'MyApp' }),\n }),\n });\n\n service.node.addDependency(dockerBuilder);\n }\n}\n```\n\n#### Python Example\n\n```python\nfrom aws_cdk import (\n aws_ecs as ecs,\n aws_ec2 as ec2,\n aws_apigateway as apigateway,\n Duration,\n core as cdk,\n)\nfrom token_injectable_docker_builder import TokenInjectableDockerBuilder\n\nclass SimpleStack(cdk.Stack):\n\n def __init__(self, scope: cdk.App, id: str, **kwargs):\n super().__init__(scope, id, **kwargs)\n\n # Create your API Gateway\n api = apigateway.RestApi(self, \"MyApiGateway\",\n rest_api_name=\"MyService\",\n )\n\n # Create the Docker builder\n docker_builder = TokenInjectableDockerBuilder(self, \"SimpleDockerBuilder\",\n path=\"./nextjs-app\", # Path to your Next.js app Docker context\n build_args={\n \"API_URL\": api.url, # Pass the API Gateway URL as a build argument\n },\n # Optionally override the default completeness query interval:\n # completeness_query_interval=Duration.seconds(45)\n )\n\n # Use in ECS\n vpc = ec2.Vpc(self, \"Vpc\")\n cluster = ecs.Cluster(self, \"EcsCluster\", vpc=vpc)\n\n task_definition = ecs.FargateTaskDefinition(self, \"TaskDef\",\n cpu=512,\n memory_limit_mib=1024,\n )\n\n task_definition.node.add_dependency(docker_builder)\n\n task_definition.add_container(\"Container\",\n image=docker_builder.container_image,\n logging=ecs.LogDriver.aws_logs(stream_prefix=\"MyApp\"),\n )\n\n ecs.FargateService(self, \"FargateService\",\n cluster=cluster,\n task_definition=task_definition,\n )\n```\n\n---\n\n### Advanced Usage Example\n\nBuilding on the previous example, this advanced usage demonstrates how to include additional configurations, such as fetching private API endpoints and configuration files during the build process.\n\n#### TypeScript/NPM Example\n\n```typescript\nimport * as cdk from 'aws-cdk-lib';\nimport { TokenInjectableDockerBuilder } from 'token-injectable-docker-builder';\nimport * as ecs from 'aws-cdk-lib/aws-ecs';\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as apigateway from 'aws-cdk-lib/aws-apigateway';\n\nexport class AdvancedStack extends cdk.Stack {\n constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n\n // Create your API Gateway\n const api = new apigateway.RestApi(this, 'MyApiGateway', {\n restApiName: 'MyService',\n });\n\n // VPC and Security Group for CodeBuild\n const vpc = new ec2.Vpc(this, 'MyVpc');\n const securityGroup = new ec2.SecurityGroup(this, 'MySecurityGroup', {\n vpc,\n });\n\n // Create the Docker builder with additional pre-build commands\n const dockerBuilder = new TokenInjectableDockerBuilder(this, 'AdvancedDockerBuilder', {\n path: './nextjs-app',\n buildArgs: {\n API_URL: api.url,\n },\n vpc,\n securityGroups: [securityGroup],\n subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },\n installCommands: [\n 'echo \"Updating package lists...\"',\n 'apt-get update -y',\n 'echo \"Installing necessary packages...\"',\n 'apt-get install -y curl',\n ],\n preBuildCommands: [\n 'echo \"Fetching private API configuration...\"',\n // Replace with your actual command to fetch configs\n 'curl -o config.json https://internal-api.example.com/config',\n ],\n // Optionally override the default completeness query interval:\n // completenessQueryInterval: cdk.Duration.seconds(45),\n });\n\n // Use in ECS\n const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });\n\n const service = new ecs.FargateService(this, 'FargateService', {\n cluster,\n taskDefinition: new ecs.FargateTaskDefinition(this, 'TaskDef', {\n cpu: 512,\n memoryLimitMiB: 1024,\n }).addContainer('Container', {\n image: dockerBuilder.containerImage,\n logging: ecs.LogDriver.awsLogs({ streamPrefix: 'MyApp' }),\n }),\n });\n\n service.node.addDependency(dockerBuilder);\n }\n}\n```\n\n#### Python Example\n\n```python\nfrom aws_cdk import (\n aws_ecs as ecs,\n aws_ec2 as ec2,\n aws_apigateway as apigateway,\n Duration,\n core as cdk,\n)\nfrom token_injectable_docker_builder import TokenInjectableDockerBuilder\n\nclass AdvancedStack(cdk.Stack):\n\n def __init__(self, scope: cdk.App, id: str, **kwargs):\n super().__init__(scope, id, **kwargs)\n\n # Create your API Gateway\n api = apigateway.RestApi(self, \"MyApiGateway\",\n rest_api_name=\"MyService\",\n )\n\n # VPC and Security Group for CodeBuild\n vpc = ec2.Vpc(self, \"MyVpc\")\n security_group = ec2.SecurityGroup(self, \"MySecurityGroup\", vpc=vpc)\n\n # Create the Docker builder with additional pre-build commands\n docker_builder = TokenInjectableDockerBuilder(self, \"AdvancedDockerBuilder\",\n path=\"./nextjs-app\",\n build_args={\n \"API_URL\": api.url,\n },\n vpc=vpc,\n security_groups=[security_group],\n subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS),\n install_commands=[\n 'echo \"Updating package lists...\"',\n 'apt-get update -y',\n 'echo \"Installing necessary packages...\"',\n 'apt-get install -y curl',\n ],\n pre_build_commands=[\n 'echo \"Fetching private API configuration...\"',\n # Replace with your actual command to fetch configs\n 'curl -o config.json https://internal-api.example.com/config',\n ],\n # Optionally override the default completeness query interval:\n # completeness_query_interval=Duration.seconds(45)\n )\n\n # Use in ECS\n cluster = ecs.Cluster(self, \"EcsCluster\", vpc=vpc)\n\n task_definition = ecs.FargateTaskDefinition(self, \"TaskDef\",\n cpu=512,\n memory_limit_mib=1024,\n )\n\n task_definition.node.add_dependency(docker_builder)\n\n task_definition.add_container(\"Container\",\n image=docker_builder.container_image,\n logging=ecs.LogDriver.aws_logs(stream_prefix=\"MyApp\"),\n )\n\n ecs.FargateService(self, \"FargateService\",\n cluster=cluster,\n task_definition=task_definition,\n )\n```\n\nIn this advanced example:\n\n- **VPC Configuration**: The CodeBuild project is configured to run inside a VPC with specified security groups and subnet selection, allowing it to access internal resources such as a private API endpoint.\n- **Custom Install and Pre-Build Commands**: The `installCommands` and `preBuildCommands` properties are used to install necessary packages and fetch configuration files from a private API before building the Docker image.\n- **Access to Internal APIs**: By running inside a VPC and configuring the security groups appropriately, the CodeBuild project can access private endpoints not accessible over the public internet.\n\n---\n\n## How It Works\n\n1. **Docker Source**: Packages the source code or Dockerfile specified in the `path` property as an S3 asset.\n2. **CodeBuild Project**:\n - Uses the packaged asset and `buildArgs` to build the Docker image.\n - Executes any custom `installCommands` and `preBuildCommands` during the build process.\n - Pushes the image to an ECR repository.\n3. **Custom Resource**:\n - Triggers the build process using a Lambda function (`onEvent`).\n - Monitors the build status using another Lambda function (`isComplete`) which polls at the interval specified by `completenessQueryInterval` (defaulting to 30 seconds if not provided).\n4. **Outputs**:\n - `.containerImage`: Returns the Docker image for ECS.\n - `.dockerImageCode`: Returns the Docker image code for Lambda.\n\n---\n\n## IAM Permissions\n\nThe construct automatically grants permissions for:\n\n- **CodeBuild**:\n - Pull and push images to ECR.\n - Access to AWS Secrets Manager if `dockerLoginSecretArn` is provided.\n - Access to the KMS key for encryption.\n- **Lambda Functions**:\n - Start and monitor CodeBuild builds.\n - Access CloudWatch Logs.\n - Access to the KMS key for encryption.\n - Pull and push images to ECR.\n\n---\n\n## Notes\n\n- **Build Arguments**: Pass custom arguments via `buildArgs` as `--build-arg` flags. CDK tokens can be used to inject dynamic values resolved at deployment time.\n- **Custom Commands**: Use `installCommands` and `preBuildCommands` to run custom shell commands during the build process. This can be useful for installing dependencies or fetching configuration files.\n- **VPC Configuration**: If your build process requires access to resources within a VPC, you can specify the VPC, security groups, and subnet selection.\n- **Docker Login**: If you need to log in to a private Docker registry before building the image, provide the ARN of a secret in AWS Secrets Manager containing the Docker credentials.\n- **ECR Repository**: Automatically creates an ECR repository with lifecycle rules to manage image retention, encryption with a KMS key, and image scanning on push.\n- **Build Query Interval**: The polling frequency for checking build completion can be customized via the `completenessQueryInterval` property.\n- **Custom Dockerfile**: Use the `file` property to specify a Dockerfile other than the default `Dockerfile`. This is passed as the `--file` flag to `docker build`.\n- **Docker Layer Caching**: By default, builds use ECR as a remote cache backend (via `docker buildx`), which can reduce build times by up to 25%. Set `cacheDisabled: true` when you need a clean build—for example, when debugging, the cache is corrupted, or after major dependency upgrades.\n- **Build Log Retention**: Pass `buildLogGroup` with a log group that has RETAIN removal policy to ensure build logs survive CloudFormation rollbacks and stack deletion.\n\n---\n\n## Troubleshooting\n\n1. **Build Errors**: Check the CodeBuild logs in CloudWatch Logs for detailed error messages. If you pass `buildLogGroup` with RETAIN removal policy, logs persist even after rollbacks. Otherwise, logs are deleted when the CodeBuild project is removed during rollback.\n2. **Lambda Errors**: Check the `onEvent` and `isComplete` Lambda function logs in CloudWatch Logs.\n3. **Permissions**: Ensure IAM roles have the required permissions for CodeBuild, ECR, Secrets Manager, and KMS if applicable.\n4. **Network Access**: If the build requires network access (e.g., to download dependencies or access internal APIs), ensure that the VPC configuration allows necessary network connectivity, and adjust security group rules accordingly.\n\n---\n\n## Support\n\nFor issues or feature requests, please open an issue on [GitHub](https://github.com/AlexTech314/TokenInjectableDockerBuilder).\n\n---\n\n## Reference Links\n\n[](https://constructs.dev/packages/token-injectable-docker-builder)\n\n---\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n---\n\n## Acknowledgements\n\n- Inspired by the need for more dynamic Docker asset management in AWS CDK.\n- Thanks to the AWS CDK community for their continuous support and contributions.\n\n---\n\nFeel free to reach out if you have any questions or need further assistance!\n"
|
|
8539
|
+
"markdown": "# TokenInjectableDockerBuilder\n\nThe `TokenInjectableDockerBuilder` is a flexible AWS CDK construct that enables the usage of AWS CDK tokens in the building, pushing, and deployment of Docker images to Amazon Elastic Container Registry (ECR). It leverages AWS CodeBuild and Lambda custom resources.\n\n---\n\n## Why?\n\nAWS CDK already provides mechanisms for creating deployable assets using Docker, such as [DockerImageAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerImageAsset.html) and [DockerImageCode](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.DockerImageCode.html), but these constructs are limited because they cannot accept CDK tokens as build-args. The `TokenInjectableDockerBuilder` allows injecting CDK tokens as build-time arguments into Docker-based assets, enabling more dynamic dependency relationships.\n\nFor example, a Next.js frontend Docker image may require an API Gateway URL as an argument to create a reference from the UI to the associated API in a given deployment. With this construct, you can deploy the API Gateway first, then pass its URL as a build-time argument to the Next.js Docker image. As a result, your Next.js frontend can dynamically fetch data from the API Gateway without hardcoding the URL or needing multiple separate stacks.\n\n---\n\n## Features\n\n- **Build and Push Docker Images**: Automatically builds and pushes Docker images to ECR.\n- **Token Support**: Supports custom build arguments for Docker builds, including CDK tokens resolved at deployment time.\n- **Shared Provider (Singleton)**: When building multiple Docker images in the same stack, use `TokenInjectableDockerBuilderProvider` to share a single pair of Lambda functions across all builders, reducing resource overhead from ~2 Lambdas per image to 2 Lambdas total.\n- **Custom Install and Pre-Build Commands**: Allows specifying custom commands to run during the `install` and `pre_build` phases of the CodeBuild build process.\n- **VPC Configuration**: Supports deploying the CodeBuild project within a VPC, with customizable security groups and subnet selection.\n- **Docker Login**: Supports Docker login using credentials stored in AWS Secrets Manager.\n- **ECR Repository Management**: Creates an ECR repository with lifecycle rules and encryption.\n- **Integration with ECS and Lambda**: Provides outputs for use in AWS ECS and AWS Lambda.\n- **Custom Build Query Interval**: Configure how frequently the custom resource polls for build completion using the `completenessQueryInterval` property (defaults to 30 seconds).\n- **Custom Dockerfile**: Specify a custom Dockerfile name via the `file` property (e.g. `Dockerfile.production`), allowing multiple Docker images from the same source directory.\n- **ECR Docker Layer Caching**: By default, builds use `docker buildx` with ECR as a remote cache backend, reducing build times by reusing layers across deploys. Set `cacheDisabled: true` to force a clean build from scratch.\n- **Persistent Build Logs**: Pass `buildLogGroup` with a log group that has RETAIN removal policy so build logs survive rollbacks and stack deletion for debugging.\n\n---\n\n## Installation\n\n### For NPM\n\nInstall the construct using NPM:\n\n```bash\nnpm install token-injectable-docker-builder\n```\n\n### For Python\n\nInstall the construct using pip:\n\n```bash\npip install token-injectable-docker-builder\n```\n\n---\n\n## API Reference\n\n### `TokenInjectableDockerBuilderProvider`\n\nA singleton construct that creates the `onEvent` and `isComplete` Lambda functions once per stack. When building multiple Docker images, share a single provider to avoid creating redundant Lambda functions.\n\n#### Static Methods\n\n| Method | Description |\n|---|---|\n| `getOrCreate(scope, props?)` | Returns the existing provider for the stack, or creates one if it doesn't exist. |\n\n#### Properties in `TokenInjectableDockerBuilderProviderProps`\n\n| Property | Type | Required | Description |\n|---|---|---|---|\n| `queryInterval` | `Duration` | No | How often the provider polls for build completion. Defaults to `Duration.seconds(30)`. |\n\n#### Instance Properties\n\n| Property | Type | Description |\n|---|---|---|\n| `serviceToken` | `string` | The service token used by CustomResource instances. |\n\n#### Instance Methods\n\n| Method | Description |\n|---|---|\n| `registerProject(project, ecrRepo, encryptionKey?)` | Grants the shared Lambdas permission to start builds and access ECR for a specific CodeBuild project. Called automatically when `provider` is passed to `TokenInjectableDockerBuilder`. |\n\n---\n\n### `TokenInjectableDockerBuilder`\n\n#### Parameters\n\n- **`scope`**: The construct's parent scope.\n- **`id`**: The construct ID.\n- **`props`**: Configuration properties.\n\n#### Properties in `TokenInjectableDockerBuilderProps`\n\n| Property | Type | Required | Description |\n|----------------------------|-----------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `path` | `string` | Yes | The file path to the Dockerfile or source code directory. |\n| `buildArgs` | `{ [key: string]: string }` | No | Build arguments to pass to the Docker build process. These are transformed into `--build-arg` flags. To use in Dockerfile, leverage the `ARG` keyword. For more details, please see the [official Docker docs](https://docs.docker.com/build/building/variables/). |\n| `provider` | `TokenInjectableDockerBuilderProvider` | No | Shared provider for the custom resource Lambdas. Use `TokenInjectableDockerBuilderProvider.getOrCreate(this)` to share a single pair of Lambdas across all builders in the same stack. When omitted, each builder creates its own Lambdas (original behavior). |\n| `dockerLoginSecretArn` | `string` | No | ARN of an AWS Secrets Manager secret for Docker credentials. Skips login if not provided. |\n| `vpc` | `IVpc` | No | The VPC in which the CodeBuild project will be deployed. If provided, the CodeBuild project will be launched within the specified VPC. |\n| `securityGroups` | `ISecurityGroup[]` | No | The security groups to attach to the CodeBuild project. These should define the network access rules for the CodeBuild project. |\n| `subnetSelection` | `SubnetSelection` | No | The subnet selection to specify which subnets to use within the VPC. Allows the user to select private, public, or isolated subnets. |\n| `installCommands` | `string[]` | No | Custom commands to run during the `install` phase of the CodeBuild build process. Will be executed before the Docker image is built. Useful for installing necessary dependencies for running pre-build scripts. |\n| `preBuildCommands` | `string[]` | No | Custom commands to run during the `pre_build` phase of the CodeBuild build process. Will be executed before the Docker image is built. Useful for running pre-build scripts, such as fetching configs. |\n| `kmsEncryption` | `boolean` | No | Whether to enable KMS encryption for the ECR repository. If `true`, a KMS key will be created for encrypting ECR images; otherwise, AES-256 encryption is used. Defaults to `false`. |\n| `completenessQueryInterval`| `Duration` | No | The query interval for checking if the CodeBuild project has completed. This determines how frequently the custom resource polls for build completion. Defaults to `Duration.seconds(30)`. Ignored when `provider` is set (the provider's `queryInterval` is used instead). |\n| `exclude` | `string[]` | No | A list of file paths in the Docker directory to exclude from the S3 asset bundle. If a `.dockerignore` file is present in the source directory, its contents will be used if this prop is not set. Defaults to an empty list or `.dockerignore` contents. |\n| `file` | `string` | No | The name of the Dockerfile to use for the build. Passed as `--file` to `docker build`. Useful when a project has multiple Dockerfiles (e.g. `Dockerfile.production`, `Dockerfile.admin`). Defaults to `Dockerfile`. |\n| `cacheDisabled` | `boolean` | No | When `true`, disables Docker layer caching. Every build runs from scratch. Use for debugging, corrupted cache, or major dependency changes. Defaults to `false`. |\n| `buildLogGroup` | `ILogGroup` | No | CloudWatch log group for CodeBuild build logs. When provided with RETAIN removal policy, logs survive rollbacks and stack deletion. If not provided, CodeBuild uses default logging (logs are deleted on rollback). |\n\n#### Instance Properties\n\n| Property | Type | Description |\n|---|---|---|\n| `containerImage` | `ContainerImage` | An ECS-compatible container image referencing the built Docker image. |\n| `dockerImageCode` | `DockerImageCode` | A Lambda-compatible Docker image code referencing the built Docker image. |\n\n---\n\n## Usage Examples\n\n### Shared Provider (Recommended for Multiple Images)\n\nWhen building multiple Docker images in the same stack, use a shared provider to avoid creating redundant Lambda functions. Without a shared provider, each builder creates 2 Lambdas + 1 Provider framework Lambda. With 10 images, that's 30 Lambdas. A shared provider reduces this to just 3 Lambdas total.\n\n#### TypeScript/NPM Example\n\n```typescript\nimport * as cdk from 'aws-cdk-lib';\nimport {\n TokenInjectableDockerBuilder,\n TokenInjectableDockerBuilderProvider,\n} from 'token-injectable-docker-builder';\nimport * as ecs from 'aws-cdk-lib/aws-ecs';\n\nexport class MultiImageStack extends cdk.Stack {\n constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n\n // Create a shared provider once per stack (singleton)\n const provider = TokenInjectableDockerBuilderProvider.getOrCreate(this);\n\n // Build multiple Docker images sharing the same provider\n const apiBuilder = new TokenInjectableDockerBuilder(this, 'ApiImage', {\n path: './src/api',\n provider,\n });\n\n const workerBuilder = new TokenInjectableDockerBuilder(this, 'WorkerImage', {\n path: './src/worker',\n provider,\n });\n\n const frontendBuilder = new TokenInjectableDockerBuilder(this, 'FrontendImage', {\n path: './src/frontend',\n buildArgs: { API_URL: 'https://api.example.com' },\n provider,\n });\n\n // Use in ECS task definitions\n const taskDef = new ecs.FargateTaskDefinition(this, 'TaskDef');\n taskDef.addContainer('api', { image: apiBuilder.containerImage });\n taskDef.addContainer('worker', { image: workerBuilder.containerImage });\n }\n}\n```\n\n#### Python Example\n\n```python\nfrom aws_cdk import aws_ecs as ecs, core as cdk\nfrom token_injectable_docker_builder import (\n TokenInjectableDockerBuilder,\n TokenInjectableDockerBuilderProvider,\n)\n\nclass MultiImageStack(cdk.Stack):\n def __init__(self, scope: cdk.App, id: str, **kwargs):\n super().__init__(scope, id, **kwargs)\n\n # Create a shared provider once per stack (singleton)\n provider = TokenInjectableDockerBuilderProvider.get_or_create(self)\n\n # Build multiple Docker images sharing the same provider\n api_builder = TokenInjectableDockerBuilder(self, \"ApiImage\",\n path=\"./src/api\",\n provider=provider,\n )\n\n worker_builder = TokenInjectableDockerBuilder(self, \"WorkerImage\",\n path=\"./src/worker\",\n provider=provider,\n )\n\n frontend_builder = TokenInjectableDockerBuilder(self, \"FrontendImage\",\n path=\"./src/frontend\",\n build_args={\"API_URL\": \"https://api.example.com\"},\n provider=provider,\n )\n```\n\n### Simple Usage Example\n\nThis example demonstrates the basic usage of the `TokenInjectableDockerBuilder`, where a Next.js frontend Docker image requires an API Gateway URL as a build argument to create a reference from the UI to the associated API in a given deployment.\n\n#### TypeScript/NPM Example\n\n```typescript\nimport * as cdk from 'aws-cdk-lib';\nimport { TokenInjectableDockerBuilder } from 'token-injectable-docker-builder';\nimport * as ecs from 'aws-cdk-lib/aws-ecs';\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as apigateway from 'aws-cdk-lib/aws-apigateway';\n\nexport class SimpleStack extends cdk.Stack {\n constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n\n // Create your API Gateway\n const api = new apigateway.RestApi(this, 'MyApiGateway', {\n restApiName: 'MyService',\n });\n\n // Create the Docker builder\n const dockerBuilder = new TokenInjectableDockerBuilder(this, 'SimpleDockerBuilder', {\n path: './nextjs-app', // Path to your Next.js app Docker context\n buildArgs: {\n API_URL: api.url, // Pass the API Gateway URL as a build argument\n },\n // Optionally override the default completeness query interval:\n // completenessQueryInterval: cdk.Duration.seconds(45),\n });\n\n // Use in ECS\n const cluster = new ecs.Cluster(this, 'EcsCluster', {\n vpc: new ec2.Vpc(this, 'Vpc'),\n });\n\n const service = new ecs.FargateService(this, 'FargateService', {\n cluster,\n taskDefinition: new ecs.FargateTaskDefinition(this, 'TaskDef', {\n cpu: 512,\n memoryLimitMiB: 1024,\n }).addContainer('Container', {\n image: dockerBuilder.containerImage,\n logging: ecs.LogDriver.awsLogs({ streamPrefix: 'MyApp' }),\n }),\n });\n\n service.node.addDependency(dockerBuilder);\n }\n}\n```\n\n#### Python Example\n\n```python\nfrom aws_cdk import (\n aws_ecs as ecs,\n aws_ec2 as ec2,\n aws_apigateway as apigateway,\n Duration,\n core as cdk,\n)\nfrom token_injectable_docker_builder import TokenInjectableDockerBuilder\n\nclass SimpleStack(cdk.Stack):\n\n def __init__(self, scope: cdk.App, id: str, **kwargs):\n super().__init__(scope, id, **kwargs)\n\n # Create your API Gateway\n api = apigateway.RestApi(self, \"MyApiGateway\",\n rest_api_name=\"MyService\",\n )\n\n # Create the Docker builder\n docker_builder = TokenInjectableDockerBuilder(self, \"SimpleDockerBuilder\",\n path=\"./nextjs-app\", # Path to your Next.js app Docker context\n build_args={\n \"API_URL\": api.url, # Pass the API Gateway URL as a build argument\n },\n # Optionally override the default completeness query interval:\n # completeness_query_interval=Duration.seconds(45)\n )\n\n # Use in ECS\n vpc = ec2.Vpc(self, \"Vpc\")\n cluster = ecs.Cluster(self, \"EcsCluster\", vpc=vpc)\n\n task_definition = ecs.FargateTaskDefinition(self, \"TaskDef\",\n cpu=512,\n memory_limit_mib=1024,\n )\n\n task_definition.node.add_dependency(docker_builder)\n\n task_definition.add_container(\"Container\",\n image=docker_builder.container_image,\n logging=ecs.LogDriver.aws_logs(stream_prefix=\"MyApp\"),\n )\n\n ecs.FargateService(self, \"FargateService\",\n cluster=cluster,\n task_definition=task_definition,\n )\n```\n\n---\n\n### Advanced Usage Example\n\nBuilding on the previous example, this advanced usage demonstrates how to include additional configurations, such as fetching private API endpoints and configuration files during the build process.\n\n#### TypeScript/NPM Example\n\n```typescript\nimport * as cdk from 'aws-cdk-lib';\nimport { TokenInjectableDockerBuilder } from 'token-injectable-docker-builder';\nimport * as ecs from 'aws-cdk-lib/aws-ecs';\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as apigateway from 'aws-cdk-lib/aws-apigateway';\n\nexport class AdvancedStack extends cdk.Stack {\n constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n\n // Create your API Gateway\n const api = new apigateway.RestApi(this, 'MyApiGateway', {\n restApiName: 'MyService',\n });\n\n // VPC and Security Group for CodeBuild\n const vpc = new ec2.Vpc(this, 'MyVpc');\n const securityGroup = new ec2.SecurityGroup(this, 'MySecurityGroup', {\n vpc,\n });\n\n // Create the Docker builder with additional pre-build commands\n const dockerBuilder = new TokenInjectableDockerBuilder(this, 'AdvancedDockerBuilder', {\n path: './nextjs-app',\n buildArgs: {\n API_URL: api.url,\n },\n vpc,\n securityGroups: [securityGroup],\n subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },\n installCommands: [\n 'echo \"Updating package lists...\"',\n 'apt-get update -y',\n 'echo \"Installing necessary packages...\"',\n 'apt-get install -y curl',\n ],\n preBuildCommands: [\n 'echo \"Fetching private API configuration...\"',\n // Replace with your actual command to fetch configs\n 'curl -o config.json https://internal-api.example.com/config',\n ],\n // Optionally override the default completeness query interval:\n // completenessQueryInterval: cdk.Duration.seconds(45),\n });\n\n // Use in ECS\n const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });\n\n const service = new ecs.FargateService(this, 'FargateService', {\n cluster,\n taskDefinition: new ecs.FargateTaskDefinition(this, 'TaskDef', {\n cpu: 512,\n memoryLimitMiB: 1024,\n }).addContainer('Container', {\n image: dockerBuilder.containerImage,\n logging: ecs.LogDriver.awsLogs({ streamPrefix: 'MyApp' }),\n }),\n });\n\n service.node.addDependency(dockerBuilder);\n }\n}\n```\n\n#### Python Example\n\n```python\nfrom aws_cdk import (\n aws_ecs as ecs,\n aws_ec2 as ec2,\n aws_apigateway as apigateway,\n Duration,\n core as cdk,\n)\nfrom token_injectable_docker_builder import TokenInjectableDockerBuilder\n\nclass AdvancedStack(cdk.Stack):\n\n def __init__(self, scope: cdk.App, id: str, **kwargs):\n super().__init__(scope, id, **kwargs)\n\n # Create your API Gateway\n api = apigateway.RestApi(self, \"MyApiGateway\",\n rest_api_name=\"MyService\",\n )\n\n # VPC and Security Group for CodeBuild\n vpc = ec2.Vpc(self, \"MyVpc\")\n security_group = ec2.SecurityGroup(self, \"MySecurityGroup\", vpc=vpc)\n\n # Create the Docker builder with additional pre-build commands\n docker_builder = TokenInjectableDockerBuilder(self, \"AdvancedDockerBuilder\",\n path=\"./nextjs-app\",\n build_args={\n \"API_URL\": api.url,\n },\n vpc=vpc,\n security_groups=[security_group],\n subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS),\n install_commands=[\n 'echo \"Updating package lists...\"',\n 'apt-get update -y',\n 'echo \"Installing necessary packages...\"',\n 'apt-get install -y curl',\n ],\n pre_build_commands=[\n 'echo \"Fetching private API configuration...\"',\n # Replace with your actual command to fetch configs\n 'curl -o config.json https://internal-api.example.com/config',\n ],\n # Optionally override the default completeness query interval:\n # completeness_query_interval=Duration.seconds(45)\n )\n\n # Use in ECS\n cluster = ecs.Cluster(self, \"EcsCluster\", vpc=vpc)\n\n task_definition = ecs.FargateTaskDefinition(self, \"TaskDef\",\n cpu=512,\n memory_limit_mib=1024,\n )\n\n task_definition.node.add_dependency(docker_builder)\n\n task_definition.add_container(\"Container\",\n image=docker_builder.container_image,\n logging=ecs.LogDriver.aws_logs(stream_prefix=\"MyApp\"),\n )\n\n ecs.FargateService(self, \"FargateService\",\n cluster=cluster,\n task_definition=task_definition,\n )\n```\n\nIn this advanced example:\n\n- **VPC Configuration**: The CodeBuild project is configured to run inside a VPC with specified security groups and subnet selection, allowing it to access internal resources such as a private API endpoint.\n- **Custom Install and Pre-Build Commands**: The `installCommands` and `preBuildCommands` properties are used to install necessary packages and fetch configuration files from a private API before building the Docker image.\n- **Access to Internal APIs**: By running inside a VPC and configuring the security groups appropriately, the CodeBuild project can access private endpoints not accessible over the public internet.\n\n---\n\n## How It Works\n\n1. **Docker Source**: Packages the source code or Dockerfile specified in the `path` property as an S3 asset.\n2. **CodeBuild Project**:\n - Uses the packaged asset and `buildArgs` to build the Docker image.\n - Executes any custom `installCommands` and `preBuildCommands` during the build process.\n - Pushes the image to an ECR repository.\n - By default, uses `docker buildx` with ECR registry cache to speed up builds.\n3. **Custom Resource**:\n - Triggers the build process using a Lambda function (`onEvent`).\n - Monitors the build status using another Lambda function (`isComplete`) which polls at the interval specified by `completenessQueryInterval` (defaulting to 30 seconds if not provided).\n - When using a shared `provider`, the same pair of Lambdas handles all builders in the stack.\n4. **Outputs**:\n - `.containerImage`: Returns the Docker image for ECS.\n - `.dockerImageCode`: Returns the Docker image code for Lambda.\n\n### Resource Comparison\n\n| Scenario | Lambdas Created | CodeBuild Projects | ECR Repos |\n|---|---|---|---|\n| 5 images, no shared provider | 15 (3 per image) | 5 | 5 |\n| 5 images, shared provider | 3 (shared) | 5 | 5 |\n| 10 images, no shared provider | 30 (3 per image) | 10 | 10 |\n| 10 images, shared provider | 3 (shared) | 10 | 10 |\n\n---\n\n## IAM Permissions\n\nThe construct automatically grants permissions for:\n\n- **CodeBuild**:\n - Pull and push images to ECR.\n - Access to AWS Secrets Manager if `dockerLoginSecretArn` is provided.\n - Access to the KMS key for encryption.\n- **Lambda Functions** (per-instance or shared provider):\n - Start and monitor CodeBuild builds.\n - Access CloudWatch Logs.\n - Access to the KMS key for encryption.\n - Pull and push images to ECR.\n\nWhen using the shared provider, `registerProject()` incrementally adds IAM permissions for each CodeBuild project and ECR repository.\n\n---\n\n## Notes\n\n- **Shared Provider**: Use `TokenInjectableDockerBuilderProvider.getOrCreate(this)` when building multiple images in the same stack. This is the recommended approach for stacks with 2+ Docker images.\n- **Build Arguments**: Pass custom arguments via `buildArgs` as `--build-arg` flags. CDK tokens can be used to inject dynamic values resolved at deployment time.\n- **Custom Commands**: Use `installCommands` and `preBuildCommands` to run custom shell commands during the build process. This can be useful for installing dependencies or fetching configuration files.\n- **VPC Configuration**: If your build process requires access to resources within a VPC, you can specify the VPC, security groups, and subnet selection.\n- **Docker Login**: If you need to log in to a private Docker registry before building the image, provide the ARN of a secret in AWS Secrets Manager containing the Docker credentials.\n- **ECR Repository**: Automatically creates an ECR repository with lifecycle rules to manage image retention, encryption with a KMS key, and image scanning on push.\n- **Build Query Interval**: The polling frequency for checking build completion can be customized via the `completenessQueryInterval` property (per-instance) or `queryInterval` (shared provider).\n- **Custom Dockerfile**: Use the `file` property to specify a Dockerfile other than the default `Dockerfile`. This is passed as the `--file` flag to `docker build`.\n- **Docker Layer Caching**: By default, builds use ECR as a remote cache backend (via `docker buildx`), which can reduce build times by up to 25%. Set `cacheDisabled: true` when you need a clean build—for example, when debugging, the cache is corrupted, or after major dependency upgrades.\n- **Build Log Retention**: Pass `buildLogGroup` with a log group that has RETAIN removal policy to ensure build logs survive CloudFormation rollbacks and stack deletion.\n- **Backward Compatibility**: The `provider` prop is optional. Omitting it preserves the original behavior where each builder creates its own Lambdas. Existing code works without changes.\n\n---\n\n## Troubleshooting\n\n1. **Build Errors**: Check the CodeBuild logs in CloudWatch Logs for detailed error messages. If you pass `buildLogGroup` with RETAIN removal policy, logs persist even after rollbacks. Otherwise, logs are deleted when the CodeBuild project is removed during rollback.\n2. **Lambda Errors**: Check the `onEvent` and `isComplete` Lambda function logs in CloudWatch Logs. With a shared provider, both builders' events flow through the same Lambdas—filter by `ProjectName` in the logs.\n3. **Permissions**: Ensure IAM roles have the required permissions for CodeBuild, ECR, Secrets Manager, and KMS if applicable. When using a shared provider, verify that `registerProject()` was called for each builder (this happens automatically when passing the `provider` prop).\n4. **Network Access**: If the build requires network access (e.g., to download dependencies or access internal APIs), ensure that the VPC configuration allows necessary network connectivity, and adjust security group rules accordingly.\n\n---\n\n## Support\n\nFor issues or feature requests, please open an issue on [GitHub](https://github.com/AlexTech314/TokenInjectableDockerBuilder).\n\n---\n\n## Reference Links\n\n[](https://constructs.dev/packages/token-injectable-docker-builder)\n\n---\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n---\n\n## Acknowledgements\n\n- Inspired by the need for more dynamic Docker asset management in AWS CDK.\n- Thanks to the AWS CDK community for their continuous support and contributions.\n\n---\n\nFeel free to reach out if you have any questions or need further assistance!\n"
|
|
8540
8540
|
},
|
|
8541
8541
|
"repository": {
|
|
8542
8542
|
"type": "git",
|
|
@@ -8568,7 +8568,7 @@
|
|
|
8568
8568
|
},
|
|
8569
8569
|
"locationInModule": {
|
|
8570
8570
|
"filename": "src/index.ts",
|
|
8571
|
-
"line":
|
|
8571
|
+
"line": 301
|
|
8572
8572
|
},
|
|
8573
8573
|
"parameters": [
|
|
8574
8574
|
{
|
|
@@ -8603,7 +8603,7 @@
|
|
|
8603
8603
|
"kind": "class",
|
|
8604
8604
|
"locationInModule": {
|
|
8605
8605
|
"filename": "src/index.ts",
|
|
8606
|
-
"line":
|
|
8606
|
+
"line": 276
|
|
8607
8607
|
},
|
|
8608
8608
|
"name": "TokenInjectableDockerBuilder",
|
|
8609
8609
|
"properties": [
|
|
@@ -8615,7 +8615,7 @@
|
|
|
8615
8615
|
"immutable": true,
|
|
8616
8616
|
"locationInModule": {
|
|
8617
8617
|
"filename": "src/index.ts",
|
|
8618
|
-
"line":
|
|
8618
|
+
"line": 286
|
|
8619
8619
|
},
|
|
8620
8620
|
"name": "containerImage",
|
|
8621
8621
|
"type": {
|
|
@@ -8630,7 +8630,7 @@
|
|
|
8630
8630
|
"immutable": true,
|
|
8631
8631
|
"locationInModule": {
|
|
8632
8632
|
"filename": "src/index.ts",
|
|
8633
|
-
"line":
|
|
8633
|
+
"line": 292
|
|
8634
8634
|
},
|
|
8635
8635
|
"name": "dockerImageCode",
|
|
8636
8636
|
"type": {
|
|
@@ -8651,7 +8651,7 @@
|
|
|
8651
8651
|
"kind": "interface",
|
|
8652
8652
|
"locationInModule": {
|
|
8653
8653
|
"filename": "src/index.ts",
|
|
8654
|
-
"line":
|
|
8654
|
+
"line": 120
|
|
8655
8655
|
},
|
|
8656
8656
|
"name": "TokenInjectableDockerBuilderProps",
|
|
8657
8657
|
"properties": [
|
|
@@ -8664,7 +8664,7 @@
|
|
|
8664
8664
|
"immutable": true,
|
|
8665
8665
|
"locationInModule": {
|
|
8666
8666
|
"filename": "src/index.ts",
|
|
8667
|
-
"line":
|
|
8667
|
+
"line": 124
|
|
8668
8668
|
},
|
|
8669
8669
|
"name": "path",
|
|
8670
8670
|
"type": {
|
|
@@ -8682,7 +8682,7 @@
|
|
|
8682
8682
|
"immutable": true,
|
|
8683
8683
|
"locationInModule": {
|
|
8684
8684
|
"filename": "src/index.ts",
|
|
8685
|
-
"line":
|
|
8685
|
+
"line": 135
|
|
8686
8686
|
},
|
|
8687
8687
|
"name": "buildArgs",
|
|
8688
8688
|
"optional": true,
|
|
@@ -8706,7 +8706,7 @@
|
|
|
8706
8706
|
"immutable": true,
|
|
8707
8707
|
"locationInModule": {
|
|
8708
8708
|
"filename": "src/index.ts",
|
|
8709
|
-
"line":
|
|
8709
|
+
"line": 257
|
|
8710
8710
|
},
|
|
8711
8711
|
"name": "buildLogGroup",
|
|
8712
8712
|
"optional": true,
|
|
@@ -8725,7 +8725,7 @@
|
|
|
8725
8725
|
"immutable": true,
|
|
8726
8726
|
"locationInModule": {
|
|
8727
8727
|
"filename": "src/index.ts",
|
|
8728
|
-
"line":
|
|
8728
|
+
"line": 248
|
|
8729
8729
|
},
|
|
8730
8730
|
"name": "cacheDisabled",
|
|
8731
8731
|
"optional": true,
|
|
@@ -8744,7 +8744,7 @@
|
|
|
8744
8744
|
"immutable": true,
|
|
8745
8745
|
"locationInModule": {
|
|
8746
8746
|
"filename": "src/index.ts",
|
|
8747
|
-
"line":
|
|
8747
|
+
"line": 223
|
|
8748
8748
|
},
|
|
8749
8749
|
"name": "completenessQueryInterval",
|
|
8750
8750
|
"optional": true,
|
|
@@ -8763,7 +8763,7 @@
|
|
|
8763
8763
|
"immutable": true,
|
|
8764
8764
|
"locationInModule": {
|
|
8765
8765
|
"filename": "src/index.ts",
|
|
8766
|
-
"line":
|
|
8766
|
+
"line": 152
|
|
8767
8767
|
},
|
|
8768
8768
|
"name": "dockerLoginSecretArn",
|
|
8769
8769
|
"optional": true,
|
|
@@ -8782,7 +8782,7 @@
|
|
|
8782
8782
|
"immutable": true,
|
|
8783
8783
|
"locationInModule": {
|
|
8784
8784
|
"filename": "src/index.ts",
|
|
8785
|
-
"line":
|
|
8785
|
+
"line": 231
|
|
8786
8786
|
},
|
|
8787
8787
|
"name": "exclude",
|
|
8788
8788
|
"optional": true,
|
|
@@ -8807,7 +8807,7 @@
|
|
|
8807
8807
|
"immutable": true,
|
|
8808
8808
|
"locationInModule": {
|
|
8809
8809
|
"filename": "src/index.ts",
|
|
8810
|
-
"line":
|
|
8810
|
+
"line": 240
|
|
8811
8811
|
},
|
|
8812
8812
|
"name": "file",
|
|
8813
8813
|
"optional": true,
|
|
@@ -8826,7 +8826,7 @@
|
|
|
8826
8826
|
"immutable": true,
|
|
8827
8827
|
"locationInModule": {
|
|
8828
8828
|
"filename": "src/index.ts",
|
|
8829
|
-
"line":
|
|
8829
|
+
"line": 192
|
|
8830
8830
|
},
|
|
8831
8831
|
"name": "installCommands",
|
|
8832
8832
|
"optional": true,
|
|
@@ -8850,7 +8850,7 @@
|
|
|
8850
8850
|
"immutable": true,
|
|
8851
8851
|
"locationInModule": {
|
|
8852
8852
|
"filename": "src/index.ts",
|
|
8853
|
-
"line":
|
|
8853
|
+
"line": 215
|
|
8854
8854
|
},
|
|
8855
8855
|
"name": "kmsEncryption",
|
|
8856
8856
|
"optional": true,
|
|
@@ -8869,7 +8869,7 @@
|
|
|
8869
8869
|
"immutable": true,
|
|
8870
8870
|
"locationInModule": {
|
|
8871
8871
|
"filename": "src/index.ts",
|
|
8872
|
-
"line":
|
|
8872
|
+
"line": 206
|
|
8873
8873
|
},
|
|
8874
8874
|
"name": "preBuildCommands",
|
|
8875
8875
|
"optional": true,
|
|
@@ -8882,6 +8882,25 @@
|
|
|
8882
8882
|
}
|
|
8883
8883
|
}
|
|
8884
8884
|
},
|
|
8885
|
+
{
|
|
8886
|
+
"abstract": true,
|
|
8887
|
+
"docs": {
|
|
8888
|
+
"default": "- A new provider is created per builder instance",
|
|
8889
|
+
"remarks": "Use `TokenInjectableDockerBuilderProvider.getOrCreate(this)` to create\na singleton that is shared across all builders in the same stack.\n\nWhen omitted, each builder creates its own Lambdas (original behavior).",
|
|
8890
|
+
"stability": "stable",
|
|
8891
|
+
"summary": "Shared provider for the custom resource Lambdas."
|
|
8892
|
+
},
|
|
8893
|
+
"immutable": true,
|
|
8894
|
+
"locationInModule": {
|
|
8895
|
+
"filename": "src/index.ts",
|
|
8896
|
+
"line": 268
|
|
8897
|
+
},
|
|
8898
|
+
"name": "provider",
|
|
8899
|
+
"optional": true,
|
|
8900
|
+
"type": {
|
|
8901
|
+
"fqn": "token-injectable-docker-builder.TokenInjectableDockerBuilderProvider"
|
|
8902
|
+
}
|
|
8903
|
+
},
|
|
8885
8904
|
{
|
|
8886
8905
|
"abstract": true,
|
|
8887
8906
|
"docs": {
|
|
@@ -8893,7 +8912,7 @@
|
|
|
8893
8912
|
"immutable": true,
|
|
8894
8913
|
"locationInModule": {
|
|
8895
8914
|
"filename": "src/index.ts",
|
|
8896
|
-
"line":
|
|
8915
|
+
"line": 168
|
|
8897
8916
|
},
|
|
8898
8917
|
"name": "securityGroups",
|
|
8899
8918
|
"optional": true,
|
|
@@ -8917,7 +8936,7 @@
|
|
|
8917
8936
|
"immutable": true,
|
|
8918
8937
|
"locationInModule": {
|
|
8919
8938
|
"filename": "src/index.ts",
|
|
8920
|
-
"line":
|
|
8939
|
+
"line": 176
|
|
8921
8940
|
},
|
|
8922
8941
|
"name": "subnetSelection",
|
|
8923
8942
|
"optional": true,
|
|
@@ -8936,7 +8955,7 @@
|
|
|
8936
8955
|
"immutable": true,
|
|
8937
8956
|
"locationInModule": {
|
|
8938
8957
|
"filename": "src/index.ts",
|
|
8939
|
-
"line":
|
|
8958
|
+
"line": 160
|
|
8940
8959
|
},
|
|
8941
8960
|
"name": "vpc",
|
|
8942
8961
|
"optional": true,
|
|
@@ -8946,8 +8965,145 @@
|
|
|
8946
8965
|
}
|
|
8947
8966
|
],
|
|
8948
8967
|
"symbolId": "src/index:TokenInjectableDockerBuilderProps"
|
|
8968
|
+
},
|
|
8969
|
+
"token-injectable-docker-builder.TokenInjectableDockerBuilderProvider": {
|
|
8970
|
+
"assembly": "token-injectable-docker-builder",
|
|
8971
|
+
"base": "constructs.Construct",
|
|
8972
|
+
"docs": {
|
|
8973
|
+
"remarks": "Creates the onEvent and isComplete Lambda functions once per stack.\nEach builder instance registers its CodeBuild project ARN so the\nshared Lambdas have permission to start builds and read logs.",
|
|
8974
|
+
"stability": "stable",
|
|
8975
|
+
"summary": "Shared provider for `TokenInjectableDockerBuilder` instances."
|
|
8976
|
+
},
|
|
8977
|
+
"fqn": "token-injectable-docker-builder.TokenInjectableDockerBuilderProvider",
|
|
8978
|
+
"kind": "class",
|
|
8979
|
+
"locationInModule": {
|
|
8980
|
+
"filename": "src/index.ts",
|
|
8981
|
+
"line": 39
|
|
8982
|
+
},
|
|
8983
|
+
"methods": [
|
|
8984
|
+
{
|
|
8985
|
+
"docs": {
|
|
8986
|
+
"remarks": "All `TokenInjectableDockerBuilder` instances in the same stack\nshare a single pair of Lambda functions.",
|
|
8987
|
+
"stability": "stable",
|
|
8988
|
+
"summary": "Get or create the singleton provider for this stack."
|
|
8989
|
+
},
|
|
8990
|
+
"locationInModule": {
|
|
8991
|
+
"filename": "src/index.ts",
|
|
8992
|
+
"line": 45
|
|
8993
|
+
},
|
|
8994
|
+
"name": "getOrCreate",
|
|
8995
|
+
"parameters": [
|
|
8996
|
+
{
|
|
8997
|
+
"name": "scope",
|
|
8998
|
+
"type": {
|
|
8999
|
+
"fqn": "constructs.Construct"
|
|
9000
|
+
}
|
|
9001
|
+
},
|
|
9002
|
+
{
|
|
9003
|
+
"name": "props",
|
|
9004
|
+
"optional": true,
|
|
9005
|
+
"type": {
|
|
9006
|
+
"fqn": "token-injectable-docker-builder.TokenInjectableDockerBuilderProviderProps"
|
|
9007
|
+
}
|
|
9008
|
+
}
|
|
9009
|
+
],
|
|
9010
|
+
"returns": {
|
|
9011
|
+
"type": {
|
|
9012
|
+
"fqn": "token-injectable-docker-builder.TokenInjectableDockerBuilderProvider"
|
|
9013
|
+
}
|
|
9014
|
+
},
|
|
9015
|
+
"static": true
|
|
9016
|
+
},
|
|
9017
|
+
{
|
|
9018
|
+
"docs": {
|
|
9019
|
+
"stability": "stable",
|
|
9020
|
+
"summary": "Grant the shared Lambdas permission to start builds for a specific CodeBuild project and pull/push to its ECR repository."
|
|
9021
|
+
},
|
|
9022
|
+
"locationInModule": {
|
|
9023
|
+
"filename": "src/index.ts",
|
|
9024
|
+
"line": 100
|
|
9025
|
+
},
|
|
9026
|
+
"name": "registerProject",
|
|
9027
|
+
"parameters": [
|
|
9028
|
+
{
|
|
9029
|
+
"name": "project",
|
|
9030
|
+
"type": {
|
|
9031
|
+
"fqn": "aws-cdk-lib.aws_codebuild.Project"
|
|
9032
|
+
}
|
|
9033
|
+
},
|
|
9034
|
+
{
|
|
9035
|
+
"name": "ecrRepo",
|
|
9036
|
+
"type": {
|
|
9037
|
+
"fqn": "aws-cdk-lib.aws_ecr.Repository"
|
|
9038
|
+
}
|
|
9039
|
+
},
|
|
9040
|
+
{
|
|
9041
|
+
"name": "encryptionKey",
|
|
9042
|
+
"optional": true,
|
|
9043
|
+
"type": {
|
|
9044
|
+
"fqn": "aws-cdk-lib.aws_kms.Key"
|
|
9045
|
+
}
|
|
9046
|
+
}
|
|
9047
|
+
]
|
|
9048
|
+
}
|
|
9049
|
+
],
|
|
9050
|
+
"name": "TokenInjectableDockerBuilderProvider",
|
|
9051
|
+
"properties": [
|
|
9052
|
+
{
|
|
9053
|
+
"docs": {
|
|
9054
|
+
"stability": "stable",
|
|
9055
|
+
"summary": "The service token used by CustomResource instances."
|
|
9056
|
+
},
|
|
9057
|
+
"immutable": true,
|
|
9058
|
+
"locationInModule": {
|
|
9059
|
+
"filename": "src/index.ts",
|
|
9060
|
+
"line": 53
|
|
9061
|
+
},
|
|
9062
|
+
"name": "serviceToken",
|
|
9063
|
+
"type": {
|
|
9064
|
+
"primitive": "string"
|
|
9065
|
+
}
|
|
9066
|
+
}
|
|
9067
|
+
],
|
|
9068
|
+
"symbolId": "src/index:TokenInjectableDockerBuilderProvider"
|
|
9069
|
+
},
|
|
9070
|
+
"token-injectable-docker-builder.TokenInjectableDockerBuilderProviderProps": {
|
|
9071
|
+
"assembly": "token-injectable-docker-builder",
|
|
9072
|
+
"datatype": true,
|
|
9073
|
+
"docs": {
|
|
9074
|
+
"stability": "stable",
|
|
9075
|
+
"summary": "Options for creating a `TokenInjectableDockerBuilderProvider`."
|
|
9076
|
+
},
|
|
9077
|
+
"fqn": "token-injectable-docker-builder.TokenInjectableDockerBuilderProviderProps",
|
|
9078
|
+
"kind": "interface",
|
|
9079
|
+
"locationInModule": {
|
|
9080
|
+
"filename": "src/index.ts",
|
|
9081
|
+
"line": 23
|
|
9082
|
+
},
|
|
9083
|
+
"name": "TokenInjectableDockerBuilderProviderProps",
|
|
9084
|
+
"properties": [
|
|
9085
|
+
{
|
|
9086
|
+
"abstract": true,
|
|
9087
|
+
"docs": {
|
|
9088
|
+
"default": "Duration.seconds(30)",
|
|
9089
|
+
"stability": "stable",
|
|
9090
|
+
"summary": "How often the provider polls for build completion."
|
|
9091
|
+
},
|
|
9092
|
+
"immutable": true,
|
|
9093
|
+
"locationInModule": {
|
|
9094
|
+
"filename": "src/index.ts",
|
|
9095
|
+
"line": 29
|
|
9096
|
+
},
|
|
9097
|
+
"name": "queryInterval",
|
|
9098
|
+
"optional": true,
|
|
9099
|
+
"type": {
|
|
9100
|
+
"fqn": "aws-cdk-lib.Duration"
|
|
9101
|
+
}
|
|
9102
|
+
}
|
|
9103
|
+
],
|
|
9104
|
+
"symbolId": "src/index:TokenInjectableDockerBuilderProviderProps"
|
|
8949
9105
|
}
|
|
8950
9106
|
},
|
|
8951
|
-
"version": "1.
|
|
8952
|
-
"fingerprint": "
|
|
9107
|
+
"version": "1.9.0",
|
|
9108
|
+
"fingerprint": "iUy4UQRv2C4McVNRJmK44WI9+MYQNepqPxoYytrMqDk="
|
|
8953
9109
|
}
|