Skip to content

Commit

Permalink
fix: update github acton and terraform latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
mamrajyadav committed Sep 7, 2023
1 parent 5c06cd1 commit f187348
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 37 deletions.
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# EditorConfig is awesome: http://EditorConfig.org
# Uses editorconfig to maintain consistent coding styles

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.{tf,tfvars}]
indent_size = 2
indent_style = space

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

[Makefile]
tab_width = 2
indent_style = tab

[COMMIT_EDITMSG]
max_line_length = 0
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# These owners will be the default owners for everything in the repo.
* @anmolnagpal @clouddrove/approvers @clouddrove-ci
12 changes: 12 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## what
* Describe high-level what changed as a result of these commits (i.e. in plain-english, what do these changes mean?)
* Use bullet points to be concise and to the point.

## why
* Provide the justifications for the changes (e.g. business case).
* Describe why these changes were made (e.g. why do these commits fix the problem?)
* Use bullet points to be concise and to the point.

## references
* Link to any supporting jira issues or helpful documentation to add some context (e.g. stackoverflow).
* Use `closes #123`, if this PR closes a Jira issue `#123`
29 changes: 15 additions & 14 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ github_repo: clouddrove/terraform-aws-ecr
# Badges to display
badges:
- name: "Latest Release"
image: "https://img.shields.io/github/release/clouddrove/terraform-aws-subnet.svg"
url: "https://github.com/clouddrove/terraform-aws-subnet/releases/latest"
image: "https://img.shields.io/github/release/clouddrove/terraform-aws-ecr.svg"
url: "https://github.com/clouddrove/terraform-aws-ecr/releases/latest"
- name: "tfsec"
image: "https://github.com/clouddrove/terraform-aws-subnet/actions/workflows/tfsec.yml/badge.svg"
url: "https://github.com/clouddrove/terraform-aws-subnet/actions/workflows/tfsec.yml"
image: "https://github.com/clouddrove/terraform-aws-ecr/actions/workflows/tfsec.yml/badge.svg"
url: "https://github.com/clouddrove/terraform-aws-ecr/actions/workflows/tfsec.yml"
- name: "Licence"
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
url: "LICENSE.md"

prerequesties:
- name: Terraform 1.5.4
url: https://learn.hashicorp.com/terraform/getting-started/install.html

# description of this project
description: |-
This terraform module is used to create ECR on AWS.
Expand All @@ -43,28 +44,28 @@ usage : |-
```hcl
module "privat_-ecr" {
source = "clouddrove/ecr/aws"
version = "1.3.0"
version = "1.3.2"
enable_private_ecr = true
name = "private-ecr"
environment = "test"
name = local.name
environment = local.environment
scan_on_push = true
max_image_count = 7
}
}
```
### Public ECR
```hcl
module "public_ecr" {
source = "clouddrove/ecr/aws"
version = "1.3.0"
version = "1.3.2"
enable_public_ecr = true
name = "public-ecr"
environment = "test"
name = local.name
environment = local.environment
max_untagged_image_count = 1
max_image_count = 7
public_repository_catalog_data = {
description = "Docker container for some things"
operating_systems = ["Linux"]
architectures = ["x86"]
description = "Docker container for some things"
operating_systems = ["Linux"]
architectures = ["x86"]
}
}
```
14 changes: 11 additions & 3 deletions _example/private_ecr/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ provider "aws" {
region = "us-east-1"
}

locals {
name = "private-ecr"
environment = "test"
}

##-----------------------------------------------------------------------------
## private_ecr module call.
##-----------------------------------------------------------------------------
module "private_ecr" {
source = "./../../"
enable_private_ecr = true
name = "private-ecr"
environment = "test"
name = local.name
environment = local.environment
scan_on_push = true
max_image_count = 7
}
}
2 changes: 1 addition & 1 deletion _example/private_ecr/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "private_ecr_arn" {
value = module.private_ecr.*.arn
value = module.private_ecr[*].arn
description = "Registry name."
}

Expand Down
11 changes: 11 additions & 0 deletions _example/private_ecr/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.5"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.13.1"
}
}
}
13 changes: 10 additions & 3 deletions _example/public_ecr/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ provider "aws" {
region = "us-east-1"
}

locals {
name = "public_ecr"
environment = "test"
}

##-----------------------------------------------------------------------------
## public_ecr module call.
##-----------------------------------------------------------------------------
module "public_ecr" {
source = "./../../"
enable_public_ecr = true
name = "public-ecr"
environment = "test"
name = local.name
environment = local.environment
max_untagged_image_count = 1
max_image_count = 7
public_repository_catalog_data = {
description = "Docker container for some things"
operating_systems = ["Linux"]
architectures = ["x86"]
}
}
}
4 changes: 2 additions & 2 deletions _example/public_ecr/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "public_ecr_arn" {
value = module.public_ecr.*.arn
value = module.public_ecr[*].arn
description = "Registry name."
}

Expand All @@ -16,4 +16,4 @@ output "public_ecr_registry_id" {
output "public_ecr_registry_url" {
value = module.public_ecr.registry_url
description = "The URL of the repository (in the form."
}
}
11 changes: 11 additions & 0 deletions _example/public_ecr/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.5"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.13.1"
}
}
}
20 changes: 10 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ resource "aws_ecr_repository" "default" {

resource "aws_ecr_lifecycle_policy" "private" {
count = var.enable_private_ecr ? 1 : 0
repository = join("", aws_ecr_repository.default.*.name)
repository = join("", aws_ecr_repository.default[*].name)

policy = <<EOF
{
Expand Down Expand Up @@ -170,14 +170,14 @@ data "aws_iam_policy_document" "resource_full_access_private" {
}

data "aws_iam_policy_document" "resource_private" {
source_policy_documents = [local.principals_readonly_access_non_empty ? join("", data.aws_iam_policy_document.resource_readonly_access_private.*.json) : join("", data.aws_iam_policy_document.empty.*.json)]
override_policy_documents = [local.principals_full_access_non_empty ? join("", data.aws_iam_policy_document.resource_full_access_private.*.json) : join("", data.aws_iam_policy_document.empty.*.json)]
source_policy_documents = [local.principals_readonly_access_non_empty ? join("", data.aws_iam_policy_document.resource_readonly_access_private[*].json) : join("", data.aws_iam_policy_document.empty[*].json)]
override_policy_documents = [local.principals_full_access_non_empty ? join("", data.aws_iam_policy_document.resource_full_access_private[*].json) : join("", data.aws_iam_policy_document.empty[*].json)]
}

resource "aws_ecr_repository_policy" "private" {
count = local.ecr_need_policy && var.enable_private_ecr ? 1 : 0
repository = join("", aws_ecr_repository.default.*.name)
policy = join("", data.aws_iam_policy_document.resource_private.*.json)
repository = join("", aws_ecr_repository.default[*].name)
policy = join("", data.aws_iam_policy_document.resource_private[*].json)
}

################################################################################
Expand Down Expand Up @@ -228,14 +228,14 @@ data "aws_iam_policy_document" "resource_full_access_public" {


data "aws_iam_policy_document" "resource_public" {
source_policy_documents = [local.principals_readonly_access_non_empty ? join("", data.aws_iam_policy_document.resource_readonly_access_public.*.json) : join("", data.aws_iam_policy_document.empty.*.json)]
override_policy_documents = [local.principals_full_access_non_empty ? join("", data.aws_iam_policy_document.resource_full_access_public.*.json) : join("", data.aws_iam_policy_document.empty.*.json)]
source_policy_documents = [local.principals_readonly_access_non_empty ? join("", data.aws_iam_policy_document.resource_readonly_access_public[*].json) : join("", data.aws_iam_policy_document.empty[*].json)]
override_policy_documents = [local.principals_full_access_non_empty ? join("", data.aws_iam_policy_document.resource_full_access_public[*].json) : join("", data.aws_iam_policy_document.empty[*].json)]
}

resource "aws_ecr_repository_policy" "public" {
count = local.ecr_need_policy && var.enable_public_ecr ? 1 : 0
repository = join("", aws_ecrpublic_repository.default.*.name)
policy = join("", data.aws_iam_policy_document.resource_public.*.json)
repository = join("", aws_ecrpublic_repository.default[*].repository_name)
policy = join("", data.aws_iam_policy_document.resource_public[*].json)
}

data "aws_iam_policy_document" "empty" {}
data "aws_iam_policy_document" "empty" {}
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ output "registry_url" {
}

output "repository_name" {
value = join("", aws_ecr_repository.default.*.name)
value = join("", aws_ecr_repository.default[*].name)
description = "Registry name."
}

Expand Down
6 changes: 3 additions & 3 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"
required_version = ">= 1.5.5"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.5.0"
version = ">= 5.13.1"
}
}
}
}

0 comments on commit f187348

Please sign in to comment.