File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ provider "aws" {
2+ region = var. aws_region
3+
4+ ignore_tags {
5+ key_prefixes = [" gsfc-ngap" ]
6+ }
7+ }
8+ data "aws_caller_identity" "current" {}
9+
10+ locals {
11+ account_id = data. aws_caller_identity . current . account_id
12+ }
13+
14+
15+ resource "aws_ecr_repository" "repo" {
16+ name = var. ecr_repo_name
17+ image_tag_mutability = " IMMUTABLE"
18+ encryption_configuration {
19+ encryption_type = " AES256"
20+ }
21+ }
22+
23+ output "ecr_repo_url" {
24+ value = aws_ecr_repository. repo . repository_url
25+ }
26+
27+ resource "null_resource" "docker_pull_push" {
28+ provisioner "local-exec" {
29+ command = << EOT
30+ aws ecr get-login-password --region ${ var . aws_region } | docker login --username AWS --password-stdin ${ aws_ecr_repository . repo . repository_url }
31+ docker pull --platform=linux/amd64 ${ var . github_image_url } :${ var . image_tag }
32+ docker tag ${ var . github_image_url } :${ var . image_tag } ${ aws_ecr_repository . repo . repository_url } :${ var . image_tag }
33+ docker push ${ aws_ecr_repository . repo . repository_url } :${ var . image_tag }
34+ EOT
35+ }
36+ depends_on = [aws_ecr_repository . repo ]
37+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ backend "s3" {
3+ region = "us-west-2"
4+ bucket = "am-uds-dev-cumulus-tf-state"
5+ key = "am-uds-dev-cumulus/ds_img_to_ecr/unity/terraform.tfstate"
6+ dynamodb_table = "am-uds-dev-cumulus-tf-locks"
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ tags = {
2+ Venue = "venue-dev",
3+ ServiceArea = "ds",
4+ CapVersion = "18.0.0"
5+ Component = "Cumulus",
6+ Proj = "Unity",
7+ CreatedBy = "ds",
8+ Env = "venue-dev",
9+ Stack = "Cumulus"
10+ }
11+ aws_region = "us-west-2"
12+ image_tag="9.6.0"
Original file line number Diff line number Diff line change 1+ variable "aws_region" {
2+ type = string
3+ default = " us-west-2"
4+ }
5+ variable "tags" {
6+ description = " Tags to be applied to Cumulus resources that support tags"
7+ type = map (string )
8+ default = {}
9+ }
10+
11+ variable "github_image_url" {
12+ description = " The full URL of the public Docker image on GitHub (e.g., ghcr.io/user/repo)"
13+ default = " ghcr.io/unity-sds/unity-data-services"
14+ type = string
15+ }
16+
17+ variable "image_tag" {
18+ description = " The tag of the image to pull from GitHub"
19+ type = string
20+ }
21+
22+ variable "ecr_repo_name" {
23+ description = " The name of the ECR repository"
24+ default = " unity-data-services"
25+ type = string
26+ }
You can’t perform that action at this time.
0 commit comments