|
| 1 | +# Build Docker Image module |
| 2 | + |
| 3 | +Terraform module that builds Docker image from `Dockerfile` and pushes it to ECR repository. Lambda can deploy container images from private ECR. |
| 4 | + |
| 5 | +This Terraform module is the part of [serverless.tf framework](https://github.com/antonbabenko/serverless.tf), which aims to simplify all operations when working with the serverless in Terraform. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +### Complete example of Lambda Function deployment via AWS CodeDeploy |
| 10 | + |
| 11 | +```hcl |
| 12 | +module "lambda_function" { |
| 13 | + source = "terraform-aws-modules/lambda/aws" |
| 14 | +
|
| 15 | + function_name = "my-lambda1" |
| 16 | + create_package = false |
| 17 | +
|
| 18 | + image_uri = module.docker_image.image_uri |
| 19 | + package_type = "Image" |
| 20 | +} |
| 21 | +
|
| 22 | +module "docker_image" { |
| 23 | + source = "terraform-aws-modules/lambda/aws//modules/docker-build" |
| 24 | +
|
| 25 | + create_ecr_repo = true |
| 26 | + ecr_repo = "my-cool-ecr-repo" |
| 27 | + image_tag = "1.0" |
| 28 | + source_path = "context" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +## Examples |
| 33 | + |
| 34 | +* [Container Image](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/container-image) - Creates Docker Image and deploy Lambda Function using it. |
| 35 | + |
| 36 | + |
| 37 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 38 | +## Requirements |
| 39 | + |
| 40 | +| Name | Version | |
| 41 | +|------|---------| |
| 42 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 | |
| 43 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.35 | |
| 44 | +| <a name="requirement_docker"></a> [docker](#requirement\_docker) | >= 2.8.0 | |
| 45 | + |
| 46 | +## Providers |
| 47 | + |
| 48 | +| Name | Version | |
| 49 | +|------|---------| |
| 50 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.35 | |
| 51 | +| <a name="provider_docker"></a> [docker](#provider\_docker) | >= 2.8.0 | |
| 52 | + |
| 53 | +## Modules |
| 54 | + |
| 55 | +No modules. |
| 56 | + |
| 57 | +## Resources |
| 58 | + |
| 59 | +| Name | Type | |
| 60 | +|------|------| |
| 61 | +| [aws_ecr_repository.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository) | resource | |
| 62 | +| [docker_registry_image.this](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/registry_image) | resource | |
| 63 | +| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | |
| 64 | +| [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | |
| 65 | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | |
| 66 | + |
| 67 | +## Inputs |
| 68 | + |
| 69 | +| Name | Description | Type | Default | Required | |
| 70 | +|------|-------------|------|---------|:--------:| |
| 71 | +| <a name="input_create_ecr_repo"></a> [create\_ecr\_repo](#input\_create\_ecr\_repo) | Controls whether ECR repository for Lambda image should be created | `bool` | `false` | no | |
| 72 | +| <a name="input_docker_file_path"></a> [docker\_file\_path](#input\_docker\_file\_path) | Path to Dockerfile in source package | `string` | `"Dockerfile"` | no | |
| 73 | +| <a name="input_ecr_repo"></a> [ecr\_repo](#input\_ecr\_repo) | Name of ECR repository to use or to create | `string` | `null` | no | |
| 74 | +| <a name="input_image_tag"></a> [image\_tag](#input\_image\_tag) | Image tag to use. If not specified current timestamp in format 'YYYYMMDDhhmmss' will be used. This can lead to unnecessary rebuilds. | `string` | `null` | no | |
| 75 | +| <a name="input_source_path"></a> [source\_path](#input\_source\_path) | Path to folder containing application code | `string` | `null` | no | |
| 76 | + |
| 77 | +## Outputs |
| 78 | + |
| 79 | +| Name | Description | |
| 80 | +|------|-------------| |
| 81 | +| <a name="output_image_uri"></a> [image\_uri](#output\_image\_uri) | The ECR image URI for deploying lambda | |
| 82 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 83 | + |
| 84 | +## Authors |
| 85 | + |
| 86 | +Module managed by [Anton Babenko](https://github.com/antonbabenko). Check out [serverless.tf](https://serverless.tf) to learn more about doing serverless with Terraform. |
| 87 | + |
| 88 | +Please reach out to [Betajob](https://www.betajob.com/) if you are looking for commercial support for your Terraform, AWS, or serverless project. |
| 89 | + |
| 90 | + |
| 91 | +## License |
| 92 | + |
| 93 | +Apache 2 Licensed. See LICENSE for full details. |
0 commit comments