/terraform-aws-ecr-custom-domain

Terraform Module to provision a custom domain for AWS ECR 🐳

Primary LanguageHCLApache License 2.0Apache-2.0

AWS ECR custom domain Terraform module

Terraform module to provision a custom domain for AWS ECR.

Usage

module "aws_ecr_custom_domain" {
  source      = "pinge/ecr-custom-domain/aws"
  domain_name = "ecr.example.com"
  zone_id = aws_route53_zone.some_zone.id

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

Why

AWS ECR does not support custom domain names. This module provisions a custom domain for your container registry so you don't have to deal with a 987654321.dkr.ecr.eu-east-1.amazonaws.com registry path.

How

When running docker pull the Docker Registry returns 307 Temporary Redirects to the actual image content.

This module creates a "registry facade" on the custom domain by provisioning an API Gateway that returns a 307 Temporary Redirect when executing docker pull or docker push.

For docker pull/push to work, you will need to authenticate with docker login ecr.example.com

Examples

Contributing

Report issues/questions/feature requests on in the issues section.

Requirements

Name Version
terraform >= 1.0
archive >= 2.0
aws >= 5.0

Providers

Name Version
archive >= 2.0
aws >= 5.0

Modules

No modules.

Resources

Name Type
aws_acm_certificate.this resource
aws_acm_certificate_validation.this resource
aws_apigatewayv2_api.this resource
aws_apigatewayv2_api_mapping.this resource
aws_apigatewayv2_domain_name.this resource
aws_apigatewayv2_integration.this resource
aws_apigatewayv2_route.this resource
aws_apigatewayv2_stage.this resource
aws_iam_role.this resource
aws_lambda_function.this resource
aws_lambda_permission.this resource
aws_route53_record.certificate_validation resource
aws_route53_record.this resource
archive_file.this data source
aws_caller_identity.current data source
aws_region.current data source

Inputs

Name Description Type Default Required
domain_name The custom domain for AWS ECR string n/a yes
lambda_name The name of the Lambda function string null no
region The default AWS region string null no
tags A map of tags to add to all resources map(string) {} no
zone_id The AWS Route 53 zone id of the ECR custom domain string n/a yes

Outputs

Name Description
api_gateway_arn n/a
aws_lambda_function_arn n/a
certificate_arn n/a
records n/a

Authors

This Terraform module is maintained by Nuno Pinge.

License

Apache 2 Licensed. See LICENSE for full details.