Skip to content

Commit

Permalink
feat: Add support to lifecycle policy (#3)
Browse files Browse the repository at this point in the history
* feat: Add support to lifecycle policy

* chore(tests): validate ecr policy json

* chore(tests): test policy with multiple rules
  • Loading branch information
cauealvesbraz authored Dec 15, 2022
1 parent bb01804 commit d70289a
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 22 deletions.
11 changes: 10 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ resource "aws_ecr_repository" "this" {
)
}

resource "aws_ecr_lifecycle_policy" "this" {
count = length(var.lifecycle_policy.rules) > 0 ? 1 : 0

repository = aws_ecr_repository.this.name
policy = jsonencode({
"rules" : var.lifecycle_policy.rules
})
}

resource "aws_ecr_registry_scanning_configuration" "this" {
count = try(var.registry_scanning_configuration.scan_type, "") == "" ? 0 : 1

Expand All @@ -30,7 +39,7 @@ resource "aws_ecr_registry_scanning_configuration" "this" {
content {
scan_frequency = rule.value.scan_frequency
repository_filter {
filter = rule.value.repository_filter.filter
filter = rule.value.repository_filter.filter
filter_type = "WILDCARD"
}
}
Expand Down
42 changes: 22 additions & 20 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ module tests
go 1.19

require (
github.com/gruntwork-io/terratest v0.40.24
github.com/stretchr/testify v1.8.0
github.com/gruntwork-io/terratest v0.41.6
github.com/stretchr/testify v1.8.1
)

require (
cloud.google.com/go v0.83.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aws/aws-sdk-go v1.40.56 // indirect
github.com/aws/aws-sdk-go v1.44.161 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/boombuler/barcode v1.0.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0 // indirect
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/gruntwork-io/go-commons v0.8.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/gruntwork-io/go-commons v0.14.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.6.1 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.9.1 // indirect
Expand All @@ -37,26 +37,28 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.13.0 // indirect
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
github.com/mattn/go-zglob v0.0.4 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/otp v1.2.0 // indirect
github.com/pquerna/otp v1.4.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/tmccombs/hcl2json v0.3.3 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/urfave/cli v1.22.2 // indirect
github.com/urfave/cli v1.22.10 // indirect
github.com/urfave/cli/v2 v2.23.7 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/zclconf/go-cty v1.9.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.2 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.47.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
Loading

0 comments on commit d70289a

Please sign in to comment.