diff --git a/README.md b/README.md index e69de29..79aa47b 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,58 @@ +# aws-ecr-copy-images + +# Usage + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | +| [null](#provider\_null) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_ecr_repository.apps_repos](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository) | resource | +| [null_resource.copy_images](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | +| [aws_availability_zone.zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source | +| [aws_availability_zones.zones](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | +| [aws_iam_account_alias.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no | +| [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no | +| [application\_list](#input\_application\_list) | List of application repositories to create for /{application\_name}/{image\_name} for those not in image\_config | `list(string)` | `[]` | no | +| [application\_name](#input\_application\_name) | Appliication name, usually {org}-{project}, which is likely a prefix to the EKS cluster name | `string` | n/a | yes | +| [destination\_password](#input\_destination\_password) | OCI destination repository password | `string` | `null` | no | +| [destination\_username](#input\_destination\_username) | OCI destination repository username | `string` | `null` | no | +| [image\_config](#input\_image\_config) | List of image configuration objects to copy from SOURCE to DESTINATION |
list(object({
name = string,
tag = string,
dest_path = string,
source_registry = string,
source_image = string,
source_tag = string,
enabled = bool,
})) | `[]` | no |
+| [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no |
+| [region](#input\_region) | Region in which to create the ECR repositories (default of current region) | `string` | `null` | no |
+| [source\_password](#input\_source\_password) | OCI source repository password | `string` | `null` | no |
+| [source\_username](#input\_source\_username) | OCI source repository username | `string` | `null` | no |
+| [tags](#input\_tags) | AWS Tags to apply to appropriate resources | `map(string)` | `{}` | no |
+
+## Outputs
+
+| Name | Description |
+|------|-------------|
+| [availability\_zone\_ids](#output\_availability\_zone\_ids) | VPC Availability zone id list (3) |
+| [availability\_zone\_names](#output\_availability\_zone\_names) | VPC Availability zone name list (3) |
+| [availability\_zone\_suffixes](#output\_availability\_zone\_suffixes) | VPC Availability zone suffix list (3) |
+| [images](#output\_images) | Final full merge of images with extra details |
diff --git a/create-apps-ecr.tf b/create-apps-ecr.tf
deleted file mode 100644
index 098a8c1..0000000
--- a/create-apps-ecr.tf
+++ /dev/null
@@ -1,28 +0,0 @@
-locals {
- application_list = var.application_list
- ecr_repo_list = { for app in local.application_list : app => format("%v/%v", var.application_name, app) }
-}
-
-resource "aws_ecr_repository" "apps_repos" {
- for_each = local.ecr_repo_list
- name = each.value
-
- image_tag_mutability = "IMMUTABLE"
- image_scanning_configuration {
- scan_on_push = true
- }
-
- encryption_configuration {
- encryption_type = "KMS"
- }
-
- tags = merge(
- local.common_tags,
- local.base_tags,
- var.application_tags,
- tomap({
- "Name" = format("ecr_%v/%v", var.application_name, each.key)
- "Environment" = "application"
- }),
- )
-}
diff --git a/copy_images.tf b/main.tf
similarity index 75%
rename from copy_images.tf
rename to main.tf
index 4b707a3..2ce79da 100644
--- a/copy_images.tf
+++ b/main.tf
@@ -1,3 +1,46 @@
+/*
+* # aws-ecr-copy-images
+*
+* # Usage
+#
+*/
+
+locals {
+ application_list = var.application_list
+ ecr_repo_list = { for app in local.application_list : app => format("%v/%v", var.application_name, app) }
+}
+
+#---
+# craete reposs if list present
+#---
+resource "aws_ecr_repository" "apps_repos" {
+ for_each = local.ecr_repo_list
+ name = each.value
+
+ image_tag_mutability = "IMMUTABLE"
+ image_scanning_configuration {
+ scan_on_push = true
+ }
+
+ encryption_configuration {
+ encryption_type = "KMS"
+ }
+
+ tags = merge(
+ local.common_tags,
+ local.base_tags,
+ var.application_tags,
+ tomap({
+ "Name" = format("ecr_%v/%v", var.application_name, each.key)
+ "Environment" = "application"
+ }),
+ )
+}
+
+#---
+# copy images
+#---
+
data "aws_ecr_authorization_token" "token" {}
# ECR format
@@ -46,9 +89,3 @@ resource "null_resource" "copy_images" {
}
}
}
-
-
-output "images" {
- description = "Final full merge of images with extra details"
- value = local.images
-}
diff --git a/outputs.tf b/outputs.tf
new file mode 100644
index 0000000..a1f7ad2
--- /dev/null
+++ b/outputs.tf
@@ -0,0 +1,4 @@
+output "images" {
+ description = "Final full merge of images with extra details"
+ value = local.images
+}