Skip to content

tonygyerr/terraform-aws-container

Repository files navigation

Module ECR

module "ecr" {
  source    = "git::https://github.com/tonygyerr/terraform-aws-container.git"
  app_name  = var.app_name
  tags      = merge(map("Name", local.environment_name != local.tf_workspace ? "${local.tf_workspace}-${var.app_name}-ecr" : "${var.app_name}-ecr"), merge(var.tags, var.acn_tags))
}

How to build dockerfile

  1. Build your Docker Image
cd docker/Dockerfile
docker build -f Dockerfile -t sagemaker-ecr:v1 .

How to build Dockerfile using Makefile process

make docker-build

How to deploy Docker Container

docker run sagemaker-ecr:v1 /bin/bash

How to Authenticate against AWS ECR

  1. Authenticate against the AWS ECR
aws ecr get-login --no-include-email --region us-east-1
  1. You will see a long string of output like below
docker login -u AWS -p eyJwYXlsb2Fk***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
  1. Run the output command to log in to docker ECR
docker login -u AWS -p *********ejj********

How to commit docker container and push Image to AWS ECR

docker commit -m "sagemaker-ecr" -a "stanley.petaway" 9e2e7ad50b82 "123456789012.dkr.ecr.us-east-1.amazonaws.com/sagemaker-ecr:v1"
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/sagemaker-ecr:v1

Docker Maintenance Commands

docker rm $(docker ps -a -q)
docker system prune -a --volumes

Requirements

Name Version
aws ~> 2.0

Providers

Name Version
aws ~> 2.0

Inputs

Name Description Type Default Required
app_name Application Name string "" no
attributes Additional attributes (e.g. policy or role) list(string) [] no
delimiter Delimiter to be used between name, namespace, stage, etc. string "-" no
enable_lifecycle_policy Set to false to prevent the module from adding any lifecycle policies to any repositories bool true no
enabled Set to false to prevent the module from creating any resources bool true no
image_names List of Docker local image names, used as repository names for AWS ECR list(string) [] no
image_tag_mutability The tag mutability setting for the repository. Must be one of: MUTABLE or IMMUTABLE string "MUTABLE" no
max_image_count How many Docker Image versions AWS ECR will store number 500 no
principals_full_access Principal ARNs to provide with full access to the ECR list(string) [] no
principals_readonly_access Principal ARNs to provide with readonly access to the ECR list(string) [] no
protected_tags Name of image tags prefixes that should not be destroyed. Useful if you tag images with names like dev, staging, and prod set(string) [] no
regex_replace_chars Regex to replace chars with empty string in namespace, environment, stage and name. By default only letters, digits, dash, slash, and underscore are allowed, all other chars are removed string "/[^a-z/A-Z_0-9-]/" no
scan_images_on_push Indicates whether images are scanned after being pushed to the repository (true) or not (false) bool false no
tags Additional tags (e.g. map('BusinessUnit','XYZ')) map(string) {} no
use_fullname Set 'true' to use namespace-stage-name for ecr repository name, else name bool true no
vpc_config configuration option for vpc map(string) {} no

Outputs

Name Description
registry_id Registry ID
repository_arn ARN of first repository created
repository_arn_map Map of repository names to repository ARNs
repository_name Name of first repository created
repository_url URL of first repository created
repository_url_map Map of repository names to repository URLs

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published