Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Manage ECR repo in terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
David Smith committed Feb 2, 2022
1 parent c6f2ca2 commit 2f1ed12
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
8 changes: 8 additions & 0 deletions infrastructure/lambda-app/ecr.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aws_ecr_repository" "app_repo" {
name = var.app_name
image_tag_mutability = "IMMUTABLE"

image_scanning_configuration {
scan_on_push = true
}
}
2 changes: 1 addition & 1 deletion infrastructure/lambda-app/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "aws_lambda_function" "app" {

function_name = var.app_name
role = aws_iam_role.iam_for_lambda.arn
image_uri = "${var.docker_image_repo_url}:${var.app_version}"
image_uri = "${data.aws_caller_identity.current.account_id}.dkr.ecr.eu-west-1.amazonaws.com/${var.ecr_repo_name}:${var.app_version}"
package_type = "Image"
publish = true

Expand Down
Empty file removed infrastructure/lambda-app/main.tf
Empty file.
7 changes: 2 additions & 5 deletions infrastructure/lambda-app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ variable "app_name" {
description = "System name that can be used to identify this app"
}

variable "docker_image_repo_url" {
variable "ecr_repo_name" {
type = string
description = "URL of the docker image repository for this app. DO NOT INCLUDE the image tag here. (use app_version)"
default = "246316657840.dkr.ecr.eu-west-1.amazonaws.com/checkout-test-website"
description = "Name of the ECR repository for this app. Must be a private ECR repository."
}

variable "app_domain" {
type = string
description = "Domain on which the app will be publicly available"
default = "checkout.davidsmith.dev"
}

variable "app_path" {
Expand All @@ -29,7 +27,6 @@ variable "app_path" {
variable "cdn_domain" {
type = string
description = "Domain on which static assets will be published to"
default = "checkout-cdn.davidsmith.dev"
}

variable "cdn_path" {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module "lambda_app" {
cdn_domain = var.cdn_domain
app_cert = module.app_cert
cdn_cert = module.cdn_cert
docker_image_repo_url = var.docker_image_repo_url
ecr_repo_name = var.ecr_repo_name

vpc = {
private_subnets = local.vpc.private_subnets
Expand Down
6 changes: 3 additions & 3 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ variable "aws_profile" {
default = "default"
}

variable "docker_image_repo_url" {
variable "ecr_repo_name" {
type = string
description = "URL of the docker image repository for this app. Must be a private ECR repository. DO NOT INCLUDE the image tag here. (use app_version)"
default = "246316657840.dkr.ecr.eu-west-1.amazonaws.com/checkout-test-website"
description = "Name of the ECR repository for this app. Must be a private ECR repository."
default = "checkout-test-website"
}

variable "app_domain" {
Expand Down

0 comments on commit 2f1ed12

Please sign in to comment.