Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs - awscc_ecr_repository #930

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 85 additions & 2 deletions docs/resources/ecr_repository.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "awscc_ecr_repository Resource - terraform-provider-awscc"
subcategory: ""
description: |-
Expand All @@ -10,7 +9,91 @@ description: |-

The AWS::ECR::Repository resource specifies an Amazon Elastic Container Registry (Amazon ECR) repository, where users can push and pull Docker images. For more information, see https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html

## Example Usage

### ECR Repository with scan on push
To create ECR Repository with scan on push:

```terraform
resource "awscc_ecr_repository" "this" {
repository_name = "example-ecr"
image_tag_mutability = "MUTABLE"
image_scanning_configuration = {
scan_on_push = true
}

}
```

### ECR Repository with lifecycle policy
To create ECR Repository with lifecycle policy that expires untagged images older than 14 days:

```terraform
resource "awscc_ecr_repository" "lifecycle_policy_example" {
repository_name = "example-ecr-lifecycle-policy"
image_tag_mutability = "MUTABLE"

lifecycle_policy = {
lifecycle_policy_text = <<EOF
{
"rules": [
{
"rulePriority": 1,
"description": "Expire images older than 14 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 14
},
"action": {
"type": "expire"
}
}
]
}
EOF
}
}
```

### ECR Repository with repository policy
To create ECR Repository with repository policy that allows AWS CodeBuild access to the Amazon ECR API actions:

```terraform
resource "awscc_ecr_repository" "repo_policy_example" {
repository_name = "example-ecr-repository-policy"
image_tag_mutability = "MUTABLE"

repository_policy_text = jsonencode(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Sid" : "CodeBuildAccess",
"Effect" : "Allow",
"Principal" : {
"Service" : "codebuild.amazonaws.com"
},
"Action" : [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
],
"Condition" : {
"ArnLike" : {
"aws:SourceArn" : "arn:aws:codebuild:region:123456789012:project/project-name"
},
"StringEquals" : {
"aws:SourceAccount" : "123456789012"
}
}
}
]
}
)

}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -78,4 +161,4 @@ Import is supported using the following syntax:

```shell
$ terraform import awscc_ecr_repository.example <resource ID>
```
```
8 changes: 8 additions & 0 deletions examples/resources/awscc_ecr_repository/ecr_repository.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "awscc_ecr_repository" "this" {
repository_name = "example-ecr"
image_tag_mutability = "MUTABLE"
image_scanning_configuration = {
scan_on_push = true
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "awscc_ecr_repository" "lifecycle_policy_example" {
repository_name = "example-ecr-lifecycle-policy"
image_tag_mutability = "MUTABLE"

lifecycle_policy = {
lifecycle_policy_text = <<EOF
{
jackywong-amazon marked this conversation as resolved.
Show resolved Hide resolved
"rules": [
{
"rulePriority": 1,
"description": "Expire images older than 14 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 14
},
"action": {
"type": "expire"
}
}
]
}
EOF
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "awscc_ecr_repository" "repo_policy_example" {
repository_name = "example-ecr-repository-policy"
image_tag_mutability = "MUTABLE"

repository_policy_text = jsonencode(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Sid" : "CodeBuildAccess",
"Effect" : "Allow",
"Principal" : {
"Service" : "codebuild.amazonaws.com"
},
"Action" : [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
],
"Condition" : {
"ArnLike" : {
"aws:SourceArn" : "arn:aws:codebuild:region:123456789012:project/project-name"
},
"StringEquals" : {
"aws:SourceAccount" : "123456789012"
}
}
}
]
}
)

}
38 changes: 38 additions & 0 deletions templates/resources/ecr_repository.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Name}} ({{.Type}})

{{ .Description | trimspace }}

## Example Usage

### ECR Repository with scan on push
To create ECR Repository with scan on push:

{{ tffile (printf "examples/resources/%s/ecr_repository.tf" .Name)}}

### ECR Repository with lifecycle policy
To create ECR Repository with lifecycle policy that expires untagged images older than 14 days:

{{ tffile (printf "examples/resources/%s/ecr_repository_lifecycle_policy.tf" .Name)}}

### ECR Repository with repository policy
To create ECR Repository with repository policy that allows AWS CodeBuild access to the Amazon ECR API actions:

{{ tffile (printf "examples/resources/%s/ecr_repository_repository_policy.tf" .Name)}}

{{ .SchemaMarkdown | trimspace }}
{{- if .HasImport }}

## Import

Import is supported using the following syntax:

{{ codefile "shell" .ImportFile }}

{{- end }}