Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
breathingdust committed Dec 24, 2020
1 parent a0d28af commit 19c54b1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aws/resource_aws_ecrpublic_repository_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ func testAccCheckAwsEcrPublicRepositoryPolicyExists(name string) resource.TestCh
func testAccAwsEcrPublicRepositoryPolicy(randString string) string {
return fmt.Sprintf(`
resource "aws_ecrpublic_repository" "foo" {
name = "tf-acc-test-ecr-%s"
repository_name = "tf-acc-test-ecr-%s"
}
resource "aws_ecrpublic_repository_policy" "default" {
repository = aws_ecrpublic_repository.foo.name
repository = aws_ecrpublic_repository.foo.repository_name
policy = <<EOF
{
Expand Down Expand Up @@ -129,7 +129,7 @@ EOF
func testAccAwsEcrPublicRepositoryPolicyWithIAMRole(randString string) string {
return fmt.Sprintf(`
resource "aws_ecrpublic_repository" "foo" {
name = "tf-acc-test-ecr-%s"
repository_name = "tf-acc-test-ecr-%s"
}
resource "aws_iam_role" "foo" {
Expand All @@ -152,7 +152,7 @@ EOF
}
resource "aws_ecrpublic_repository_policy" "default" {
repository = aws_ecrpublic_repository.foo.name
repository = aws_ecrpublic_repository.foo.repository_name
policy = <<EOF
{
Expand Down
76 changes: 76 additions & 0 deletions website/docs/r/ecrpublic_repository_policy.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
subcategory: "ECR"
layout: "aws"
page_title: "AWS: aws_ecrpublic_repository_policy"
description: |-
Provides an Elastic Container Registry Public Repository Policy.
---

# Resource: aws_ecrpublic_repository_policy

Provides an Elastic Container Registry Public Repository Policy.

Note that currently only one policy may be applied to a repository.

## Example Usage

```hcl
resource "aws_ecrpublic_repository" "foo" {
repository_name = "bar"
}
resource "aws_ecr_repository_policy" "foopolicy" {
repository = aws_ecrpublic_repository.foo.repository_name
policy = <<EOF
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "new policy",
"Effect": "Allow",
"Principal": "*",
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:DescribeRepositories",
"ecr:GetRepositoryPolicy",
"ecr:ListImages",
"ecr:DeleteRepository",
"ecr:BatchDeleteImage",
"ecr:SetRepositoryPolicy",
"ecr:DeleteRepositoryPolicy"
]
}
]
}
EOF
}
```

## Argument Reference

The following arguments are supported:

* `repository` - (Required) Name of the repository to apply the policy.
* `policy` - (Required) The policy document. This is a JSON formatted string. For more information about building IAM policy documents with Terraform, see the [AWS IAM Policy Document Guide](https://learn.hashicorp.com/terraform/aws/iam-policy)

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `repository` - The name of the repository.
* `registry_id` - The registry ID where the repository was created.

## Import

ECR Public Repository Policy can be imported using the repository name, e.g.

```
$ terraform import aws_ecrpublic_repository_policy.example example
```

0 comments on commit 19c54b1

Please sign in to comment.