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

Remove manual S3 copy stage #4

Merged
merged 2 commits into from
Jul 21, 2021
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
47 changes: 26 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!-- markdownlint-disable -->
# terraform-aws-mobius3 [![Latest Release](https://img.shields.io/github/release/zeroae/terraform-aws-mobius3.svg)](https://github.com/zeroae/terraform-aws-mobius3/releases/latest)
<!-- markdownlint-restore -->
Expand Down Expand Up @@ -29,7 +30,6 @@

The `terraform-aws-mobius3` module creates the a container definition that syncs an ECS task volumes to S3.


---

This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
Expand Down Expand Up @@ -60,7 +60,6 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are




## Security & Compliance [<img src="https://cloudposse.com/wp-content/uploads/2020/11/bridgecrew.svg" width="250" align="right" />](https://bridgecrew.io/)

Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance.
Expand Down Expand Up @@ -133,36 +132,43 @@ Available targets:

| Name | Version |
|------|---------|
| terraform | >= 0.12.0, < 0.14.0 |
| local | ~> 1.2 |
| random | ~> 2.2 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |

## Providers

No provider.
No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_mobius3"></a> [mobius3](#module\_mobius3) | git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git | tags/0.57.0 |
| <a name="module_volume_label"></a> [volume\_label](#module\_volume\_label) | git::https://github.com/cloudposse/terraform-null-label.git | tags/0.24.1 |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| awscli\_image | The AWSCLI Compatible Image | `string` | `"docker.io/amazon/aws-cli:2.0.52"` | no |
| bucket\_id | Bucket Name (aka ID) | `any` | n/a | yes |
| bucket\_key\_prefix | The key prefix to use for the bucket objects. | `any` | n/a | yes |
| bucket\_region | Bucket Region | `any` | n/a | yes |
| log\_configuration | Log configuration options to send to a custom log driver for the container. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html | `any` | `null` | no |
| mobius3\_image | The Mobius3 Image for S3<->FS synchronization | `string` | `"ghcr.io/zeroae/terraform-aws-mobius3:0.0.34"` | no |
| user | The user that owns the volume. Can be any of these formats: uid, uid:gid. The default is (0:0). | `string` | `"0:0"` | no |
| volume\_name | The volume name. | `string` | `"data"` | no |
| <a name="input_bucket_id"></a> [bucket\_id](#input\_bucket\_id) | Bucket Name (aka ID) | `any` | n/a | yes |
| <a name="input_bucket_key_prefix"></a> [bucket\_key\_prefix](#input\_bucket\_key\_prefix) | The key prefix to use for the bucket objects. | `any` | n/a | yes |
| <a name="input_bucket_region"></a> [bucket\_region](#input\_bucket\_region) | Bucket Region | `any` | n/a | yes |
| <a name="input_log_configuration"></a> [log\_configuration](#input\_log\_configuration) | Log configuration options to send to a custom log driver for the container. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html | `any` | `null` | no |
| <a name="input_mobius3_image"></a> [mobius3\_image](#input\_mobius3\_image) | The Mobius3 Image for S3<->FS synchronization | `string` | `"ghcr.io/zeroae/terraform-aws-mobius3:0.0.34"` | no |
| <a name="input_user"></a> [user](#input\_user) | The user that owns the volume. Can be any of these formats: uid, uid:gid. The default is (0:0). | `string` | `"0:0"` | no |
| <a name="input_volume_name"></a> [volume\_name](#input\_volume\_name) | The volume name. | `string` | `"data"` | no |

## Outputs

| Name | Description |
|------|-------------|
| container\_depends\_on | n/a |
| container\_depends\_on\_list | n/a |
| json\_map\_objects | n/a |
| source\_volume | The volume name to use in container definition mount point |

| <a name="output_container_depends_on"></a> [container\_depends\_on](#output\_container\_depends\_on) | n/a |
| <a name="output_container_depends_on_list"></a> [container\_depends\_on\_list](#output\_container\_depends\_on\_list) | n/a |
| <a name="output_json_map_objects"></a> [json\_map\_objects](#output\_json\_map\_objects) | n/a |
| <a name="output_source_volume"></a> [source\_volume](#output\_source\_volume) | The volume name to use in container definition mount point |
<!-- markdownlint-restore -->


Expand All @@ -174,6 +180,7 @@ Like this project? Please give it a ★ on [our GitHub](https://github.com/zeroa
Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)



## Related Projects

Check out these related projects.
Expand All @@ -182,8 +189,6 @@ Check out these related projects.
- [terraform-null-label](https://github.com/cloudposse/terraform-null-label) - Terraform module designed to generate consistent names and tags for resources. Use terraform-null-label to implement a strict naming convention.




## References

For additional context, refer to some of these links.
Expand Down
41 changes: 24 additions & 17 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,41 @@

| Name | Version |
|------|---------|
| terraform | >= 0.12.0, < 0.14.0 |
| local | ~> 1.2 |
| random | ~> 2.2 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |

## Providers

No provider.
No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_mobius3"></a> [mobius3](#module\_mobius3) | git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git | tags/0.57.0 |
| <a name="module_volume_label"></a> [volume\_label](#module\_volume\_label) | git::https://github.com/cloudposse/terraform-null-label.git | tags/0.24.1 |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| awscli\_image | The AWSCLI Compatible Image | `string` | `"docker.io/amazon/aws-cli:2.0.52"` | no |
| bucket\_id | Bucket Name (aka ID) | `any` | n/a | yes |
| bucket\_key\_prefix | The key prefix to use for the bucket objects. | `any` | n/a | yes |
| bucket\_region | Bucket Region | `any` | n/a | yes |
| log\_configuration | Log configuration options to send to a custom log driver for the container. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html | `any` | `null` | no |
| mobius3\_image | The Mobius3 Image for S3<->FS synchronization | `string` | `"ghcr.io/zeroae/terraform-aws-mobius3:0.0.34"` | no |
| user | The user that owns the volume. Can be any of these formats: uid, uid:gid. The default is (0:0). | `string` | `"0:0"` | no |
| volume\_name | The volume name. | `string` | `"data"` | no |
| <a name="input_bucket_id"></a> [bucket\_id](#input\_bucket\_id) | Bucket Name (aka ID) | `any` | n/a | yes |
| <a name="input_bucket_key_prefix"></a> [bucket\_key\_prefix](#input\_bucket\_key\_prefix) | The key prefix to use for the bucket objects. | `any` | n/a | yes |
| <a name="input_bucket_region"></a> [bucket\_region](#input\_bucket\_region) | Bucket Region | `any` | n/a | yes |
| <a name="input_log_configuration"></a> [log\_configuration](#input\_log\_configuration) | Log configuration options to send to a custom log driver for the container. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html | `any` | `null` | no |
| <a name="input_mobius3_image"></a> [mobius3\_image](#input\_mobius3\_image) | The Mobius3 Image for S3<->FS synchronization | `string` | `"ghcr.io/zeroae/terraform-aws-mobius3:0.0.34"` | no |
| <a name="input_user"></a> [user](#input\_user) | The user that owns the volume. Can be any of these formats: uid, uid:gid. The default is (0:0). | `string` | `"0:0"` | no |
| <a name="input_volume_name"></a> [volume\_name](#input\_volume\_name) | The volume name. | `string` | `"data"` | no |

## Outputs

| Name | Description |
|------|-------------|
| container\_depends\_on | n/a |
| container\_depends\_on\_list | n/a |
| json\_map\_objects | n/a |
| source\_volume | The volume name to use in container definition mount point |

| <a name="output_container_depends_on"></a> [container\_depends\_on](#output\_container\_depends\_on) | n/a |
| <a name="output_container_depends_on_list"></a> [container\_depends\_on\_list](#output\_container\_depends\_on\_list) | n/a |
| <a name="output_json_map_objects"></a> [json\_map\_objects](#output\_json\_map\_objects) | n/a |
| <a name="output_source_volume"></a> [source\_volume](#output\_source\_volume) | The volume name to use in container definition mount point |
<!-- markdownlint-restore -->
38 changes: 0 additions & 38 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,6 @@ module "volume_label" {
label_order = ["name"]
}

module "copy_from_s3" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.57.0"
container_name = "copy_from_s3"
container_image = var.awscli_image
essential = false

user = var.user

entrypoint = [
"/bin/sh"
]
command = [
"-c",
join(";", [
"set -e",
"aws s3 sync s3://${var.bucket_id}/${local.key_prefix}/${module.volume_label.id}/ /srv/data",
"chown -R ${var.user} /srv/data",
])
]

mount_points = [
{
containerPath = "/srv/data"
sourceVolume = module.volume_label.id
readOnly = false
}
]

log_configuration = var.log_configuration
}

# TODO: Implement a health check
# TODO: Support multiple volumes
module "mobius3" {
Expand All @@ -48,13 +17,6 @@ module "mobius3" {
container_image = var.mobius3_image
essential = true

container_depends_on = [
{
containerName = module.copy_from_s3.json_map_object["name"]
condition = "SUCCESS"
},
]

user = var.user

command = [
Expand Down
1 change: 0 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ output "container_depends_on_list" {

output "json_map_objects" {
value = [
module.copy_from_s3.json_map_object,
module.mobius3.json_map_object
]
}
6 changes: 0 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ variable "user" {
default = "0:0"
}

variable "awscli_image" {
description = "The AWSCLI Compatible Image"
type = string
default = "docker.io/amazon/aws-cli:2.0.52"
}

variable "mobius3_image" {
description = "The Mobius3 Image for S3<->FS synchronization"
type = string
Expand Down