From 840ce21aa176a626bafcd04742e57df02ec819b8 Mon Sep 17 00:00:00 2001 From: badra001 Date: Mon, 22 Aug 2022 16:20:24 -0400 Subject: [PATCH] add docs --- README.md | 74 ++++++++++++++++++++++++++- examples/{ => simple}/copy-images.tf | 0 main.tf | 76 +++++++++++++++++++++++++++- 3 files changed, 147 insertions(+), 3 deletions(-) rename examples/{ => simple}/copy-images.tf (100%) diff --git a/README.md b/README.md index 915cae6..56f4cab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,79 @@ -# aws-ecr-copy-images +# About aws-ecr-copy-images +This module will create ECR repositories with the prefix of `_application_name_` for the list of +repositories in `_application_list_`. This allows for a project to upload their images into +/{application\_name}/{sub\_app}/\_image\_:\_tag\_. + +Also, if provided a list of source image configurations, it will download them from their location +and upload them to the prefix of `_application_name_` followed by the _name_ in the `image_config` +object. # Usage +```hcl +locals { + image_config = [ + { + enabled = true + dest_path = null + name = "openjdk-8" + source_image = "ubi8/openjdk-8" + source_registry = "registry.access.redhat.com" + source_tag = null + tag = "latest" + }, + { + enabled = true + name = "nginx-118" + dest_path = null + source_image = "ubi8/nginx-118" + source_registry = "registry.access.redhat.com" + source_tag = null + tag = "latest" + }, + { + enabled = true + name = "nodejs-14" + dest_path = null + source_image = "ubi8/nodejs-14" + source_registry = "registry.access.redhat.com" + source_tag = null + tag = "latest" + }, + ] +} + +module "images" { + source = "git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git" + + application_list = ["app1", "app2"] + application_name = "org-project" + image_config = local.image_config + tags = {} + + ### optional + ## account_alias = "" + ## account_id = "" + ## destination_password = "" + ## destination_username = "" + ## override_prefixes = {} + ## region = "" + ## source_password = "" + ## source_username = "" +} +``` + +This creates the following ECR images + +``` +Repository name URI Created at Tag immutability Scan on push Encryption type + +org-project/app1 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/app1 August 22, 2022, 13:12:06 (UTC-04) Enabled Enabled KMS +org-project/app2 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/app2 August 22, 2022, 13:12:06 (UTC-04) Enabled Enabled KMS +org-project/nginx-118 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/nginx-118 August 22, 2022, 12:43:57 (UTC-04) Enabled Enabled KMS +org-project/nodejs-14 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/nodejs-14 August 22, 2022, 12:43:57 (UTC-04) Enabled Enabled KMS +org-project/openjdk-8 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/openjdk-8 August 22, 2022, 12:43:57 (UTC-04) Enabled Enabled KMS +``` + ## Requirements No requirements. diff --git a/examples/copy-images.tf b/examples/simple/copy-images.tf similarity index 100% rename from examples/copy-images.tf rename to examples/simple/copy-images.tf diff --git a/main.tf b/main.tf index 4934ff0..f761ade 100644 --- a/main.tf +++ b/main.tf @@ -1,8 +1,80 @@ /* -* # aws-ecr-copy-images +* # About aws-ecr-copy-images +* This module will create ECR repositories with the prefix of `_application_name_` for the list of +* repositories in `_application_list_`. This allows for a project to upload their images into +* /{application_name}/{sub_app}/_image_:_tag_. +* +* Also, if provided a list of source image configurations, it will download them from their location +* and upload them to the prefix of `_application_name_` followed by the _name_ in the `image_config` +* object. * * # Usage -# +* +* ```hcl +* locals { +* image_config = [ +* { +* enabled = true +* dest_path = null +* name = "openjdk-8" +* source_image = "ubi8/openjdk-8" +* source_registry = "registry.access.redhat.com" +* source_tag = null +* tag = "latest" +* }, +* { +* enabled = true +* name = "nginx-118" +* dest_path = null +* source_image = "ubi8/nginx-118" +* source_registry = "registry.access.redhat.com" +* source_tag = null +* tag = "latest" +* }, +* { +* enabled = true +* name = "nodejs-14" +* dest_path = null +* source_image = "ubi8/nodejs-14" +* source_registry = "registry.access.redhat.com" +* source_tag = null +* tag = "latest" +* }, +* ] +* } +* +* module "images" { +* source = "git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git" +* +* application_list = ["app1", "app2"] +* application_name = "org-project" +* image_config = local.image_config +* tags = {} +* +* ### optional +* ## account_alias = "" +* ## account_id = "" +* ## destination_password = "" +* ## destination_username = "" +* ## override_prefixes = {} +* ## region = "" +* ## source_password = "" +* ## source_username = "" +* } +* ``` +* +* This creates the following ECR images +* +* ``` +* Repository name URI Created at Tag immutability Scan on push Encryption type +* +* org-project/app1 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/app1 August 22, 2022, 13:12:06 (UTC-04) Enabled Enabled KMS +* org-project/app2 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/app2 August 22, 2022, 13:12:06 (UTC-04) Enabled Enabled KMS +* org-project/nginx-118 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/nginx-118 August 22, 2022, 12:43:57 (UTC-04) Enabled Enabled KMS +* org-project/nodejs-14 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/nodejs-14 August 22, 2022, 12:43:57 (UTC-04) Enabled Enabled KMS +* org-project/openjdk-8 817869416306.dkr.ecr.us-gov-east-1.amazonaws.com/org-project/openjdk-8 August 22, 2022, 12:43:57 (UTC-04) Enabled Enabled KMS +* ``` +* */ locals {