Skip to content

Commit

Permalink
Update provider dependencies
Browse files Browse the repository at this point in the history
- Major update of the kreuzwerker/docker dependency.
- That was a breaking change which required some changes, but all in all the Docker image handling code looks much better now.
  • Loading branch information
cristim committed Feb 15, 2023
1 parent 2b70c14 commit 0704393
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
39 changes: 20 additions & 19 deletions modules/lambda/docker.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

locals {
src_image = "${var.lambda_source_ecr}/${var.lambda_source_image}:${var.lambda_source_image_tag}"
dst_image = "${aws_ecr_repository.autospotting.repository_url}:${var.lambda_source_image_tag}"
}
resource "aws_ecr_repository" "autospotting" {
name = "autospotting-${module.label.id}"
image_tag_mutability = "MUTABLE"
Expand All @@ -13,36 +16,34 @@ resource "aws_ecr_repository" "autospotting" {

data "aws_ecr_authorization_token" "source" {
registry_id = split(".", var.lambda_source_ecr)[0]

}

data "aws_ecr_authorization_token" "destination" {}

provider "docker" {
registry_auth {
address = var.lambda_source_ecr
username = data.aws_ecr_authorization_token.source.user_name
password = data.aws_ecr_authorization_token.source.password
}
registry_auth {
address = split("/", aws_ecr_repository.autospotting.repository_url)[0]
username = data.aws_ecr_authorization_token.destination.user_name
password = data.aws_ecr_authorization_token.destination.password
}
}

resource "local_file" "Dockerfile" {
content = "FROM ${var.lambda_source_ecr}/${var.lambda_source_image}:${var.lambda_source_image_tag}"
filename = "${path.module}/docker/Dockerfile"
resource "docker_image" "base_image" {
name = local.src_image
}

resource "docker_tag" "image" {
source_image = docker_image.base_image.name
target_image = local.dst_image
}

resource "docker_registry_image" "destination" {
name = "${aws_ecr_repository.autospotting.repository_url}:${var.lambda_source_image_tag}"
name = local.dst_image
keep_remotely = false
build {
context = "${path.module}/docker"

auth_config {
host_name = var.lambda_source_ecr
user_name = data.aws_ecr_authorization_token.source.user_name
password = data.aws_ecr_authorization_token.source.password
}
}
depends_on = [
local_file.Dockerfile,
]
}
depends_on = [docker_tag.image]
}
1 change: 0 additions & 1 deletion modules/lambda/docker/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion modules/lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 2.15.0"
version = "~> 3.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/regional/resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down

0 comments on commit 0704393

Please sign in to comment.