Skip to content
Open
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
12 changes: 6 additions & 6 deletions terraform-ecs-efs-integration/Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Amazon EFS and Amazon ECS Integration
# Amazon EFS and Amazon ECS Integration

This pattern creates an Amazon EFS file system and integrates with ECS for a persisent file storage in a containerized environment.
This pattern creates an Amazon EFS file system and integrates with ECS for a persistent file storage in a containerized environment.

You will build a container as part of the build, publish it into ECR, and then publish it as an ECS Task in the end. A sample file will be created in the EFS (persistent file system) after the task has been completed. The security component is likewise handled by KMS Keys and IAM Roles.

Expand All @@ -21,10 +21,10 @@ Optionally, you can also specify env and organization (tagging purposes) and tas
terraform init

# terraform plan with sample values for vpc and subnet
terraform plan -var="aws_vpc_id=vpc-xxxx" -var='aws_subnets=["subnet-xxxx","subnet-xxxx","subnet-xxxx"]'
terraform plan -var="aws_vpc_id=vpc-xxxx" -var='aws_subnets=["subnet-xxxx","subnet-xxxx","subnet-xxxx"]'

# terraform apply
terraform apply -var="aws_vpc_id=vpc-xxxx" -var='aws_subnets=["subnet-xxxx","subnet-xxxx","subnet-xxxx"]'
terraform apply -var="aws_vpc_id=vpc-xxxx" -var='aws_subnets=["subnet-xxxx","subnet-xxxx","subnet-xxxx"]'
```

Once deployed you can run the ECS task from the ECS Console or via AWS CLI which will create a sample file on the persistent storage using Amazon EFS
Expand All @@ -45,15 +45,15 @@ aws ecs run-task \
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.24 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 6.0 |
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 2.3 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.24 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 6.0 |
| <a name="provider_external"></a> [external](#provider\_external) | >= 2.3 |
| <a name="provider_null"></a> [null](#provider\_null) | >= 3.2 |

Expand Down
2 changes: 1 addition & 1 deletion terraform-ecs-efs-integration/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ locals {
organization = var.organization
env = var.env
}
region = data.aws_region.current.name
region = data.aws_region.current.region
account_id = data.aws_caller_identity.current.account_id
standard_resource_name = "${var.env}-${var.organization}"
ecr_base_arn = "${local.account_id}.dkr.ecr.${local.region}.amazonaws.com"
Expand Down
2 changes: 1 addition & 1 deletion terraform-ecs-efs-integration/templates/ecs-role.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
],
"Resource": "arn:aws:ecr:*:*:repository/${standard_resource_name}"
"Resource": "arn:aws:ecr:*:*:repository/${standard_resource_name}-efs-updater"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: CannotPullContainerError error occurred because IAM policy referenced wrong ECR repository ARN.

CannotPullContainerError: pull image manifest has been retried 1 time(s): failed to resolve ref 000000000000.dkr.ecr.us-east-1.amazonaws.com/testing-serverlessland-efs-updater:latest: unexpected status from HEAD request to https://000000000000.dkr.ecr.us-east-1.amazonaws.com/v2/testing-serverlessland-efs-updater/manifests/latest: 403 Forbidden

},
{
"Sid": "ECSGrants",
Expand Down
4 changes: 2 additions & 2 deletions terraform-ecs-efs-integration/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.24"
version = "~> 6.0"
}
external = {
source = "hashicorp/external"
Expand All @@ -15,4 +15,4 @@ terraform {
version = ">= 3.2"
}
}
}
}