Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34cb639

Browse files
committed
feat: add ECR
1 parent b41a49a commit 34cb639

File tree

16 files changed

+181
-64
lines changed

16 files changed

+181
-64
lines changed

infra/.terraform.lock.hcl

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/container-registry/ecr.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_ecr_repository" "ecr" {
2+
name = "${lower(var.repo_namespace)}/${var.image_name}"
3+
force_delete = var.ecr_force_delete
4+
image_tag_mutability = var.image_mutability
5+
image_scanning_configuration {
6+
scan_on_push = true
7+
}
8+
}

infra/container-registry/output.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
output "ecr_repository_url" {
3+
value = aws_ecr_repository.ecr.repository_url
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
variable "ecr_force_delete" {
2+
description = "Forces deletion of Docker images before resource is destroyed"
3+
default = true
4+
type = bool
5+
}
6+
7+
8+
variable "repo_namespace" {
9+
default = "ashgw-rg"
10+
type = string
11+
}
12+
13+
variable "image_name" {
14+
type = string
15+
default = "main-site"
16+
}
17+
18+
variable "image_mutability" {
19+
default = "MUTABLE"
20+
type = string
21+
}

infra/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
provider "aws" {
3+
region = var.aws_region
4+
}
5+
6+
module "images_s3_bucket" {
7+
source = "./public-content/images"
8+
}
9+
10+
module "ecr" {
11+
source = "./container-registry"
12+
}
13+

infra/public-content/images/.terraform.lock.hcl

Lines changed: 0 additions & 24 deletions
This file was deleted.

infra/public-content/images/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
output "bucket_url" {
2-
value = "https://${var.bucket_name}.s3.${var.aws_region}.amazonaws.com"
3-
}
1+
output "domain" {
2+
description = "Domain name of the bucket"
3+
value = aws_s3_bucket.public_bucket.website_domain
4+
}

infra/public-content/images/s3.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
provider "aws" {
3-
region = var.aws_region
4-
}
5-
61
resource "aws_s3_bucket" "public_bucket" {
72
bucket = var.bucket_name
83
}

infra/public-content/images/variables.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ variable "bucket_owner" {
99
default = "i-own-ashgw-blog-public-images"
1010
}
1111

12-
variable "aws_region" {
13-
type = string
14-
default = "us-east-2"
15-
}
12+

0 commit comments

Comments
 (0)