Skip to content

Commit

Permalink
Merge pull request #20 from trussworks/lockdown_ecr
Browse files Browse the repository at this point in the history
Lockdown ECR
  • Loading branch information
pjdufour-truss authored May 20, 2019
2 parents 6d0ca00 + 2dd5f11 commit 6aaa9f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module "app_ecs_service" {
| container\_health\_check\_port | An additional port on which the container can receive a health check. Zero means the container port can only receive a health check on the port set by the container_port variable. | string | `"0"` | no |
| container\_image | The image of the container. | string | `"golang:1.12.5-alpine"` | no |
| container\_port | The port on which the container will receive traffic. | string | `"80"` | no |
| ecr\_repo\_arn | The ARN of the ECR repo. By default, allows all repositories. | string | `"*"` | no |
| ecs\_cluster\_arn | The ARN of the ECS cluster. | string | n/a | yes |
| ecs\_instance\_role | The name of the ECS instance role. | string | `""` | no |
| ecs\_subnet\_ids | Subnet IDs for the ECS tasks. | list | n/a | yes |
Expand Down
18 changes: 16 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,19 @@ data "aws_iam_policy_document" "instance_role_policy_doc" {
statement {
actions = [
"ecr:GetAuthorizationToken",
]

resources = ["*"]
}

statement {
actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
]

resources = ["*"]
resources = ["${var.ecr_repo_arn}"]
}
}

Expand Down Expand Up @@ -298,12 +305,19 @@ data "aws_iam_policy_document" "task_execution_role_policy_doc" {
statement {
actions = [
"ecr:GetAuthorizationToken",
]

resources = ["*"]
}

statement {
actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
]

resources = ["*"]
resources = ["${var.ecr_repo_arn}"]
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ variable "logs_cloudwatch_group" {
type = "string"
}

variable "ecr_repo_arn" {
description = "The ARN of the ECR repo. By default, allows all repositories."
type = "string"
default = "*"
}

variable "ecs_use_fargate" {
description = "Whether to use Fargate for the task definition."
default = false
Expand Down

0 comments on commit 6aaa9f3

Please sign in to comment.