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

feat!: Add support for creating ECS service and container definition #76

Merged
merged 41 commits into from
Apr 21, 2023

Conversation

bryantbiggs
Copy link
Member

@bryantbiggs bryantbiggs commented Mar 12, 2023

Description

  • Add support for creating cluster CloudWatch log group
  • Add support for ECS service connect
  • Add support for creating task execution from cluster module; this is for scenarios where you wish to create one task execution role shared across tasks within the cluster (there is also support for individual task execution role at the service level)
  • Add support for creating container definition within HCL; this is consumed by the service sub-module

Motivation and Context

Breaking Changes

  • No

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

⚠️ Note - the changes here have been tested and validated on a number of examples since its used by the ECS Blueprints project. Once these changes are merged, the ECS Blueprints project will be updated to use this module and this copy will be archived/deleted

bryantbiggs and others added 30 commits January 27, 2023 15:43
…ask definition, add support for service alarms
@bryantbiggs
Copy link
Member Author

@antonbabenko I made some updates and provided some responses/feedback - please take another look when you have some time and let me know what your thoughts are. I also added a design doc to capture a lot of the information that went into the current proposal. Hopefully that is useful for both the review and future users

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Looks very good. The only big thing is related to the submodule for ECS Cluster, and we are good to go!

docs/DESIGN.md Outdated Show resolved Hide resolved
docs/DESIGN.md Outdated Show resolved Hide resolved
docs/DESIGN.md Outdated Show resolved Hide resolved
docs/DESIGN.md Outdated Show resolved Hide resolved
docs/DESIGN.md Outdated Show resolved Hide resolved
modules/service/variables.tf Show resolved Hide resolved
variable "memory" {
description = "Amount (in MiB) of memory used by the task. If the `requires_compatibilities` is `FARGATE` this field is required"
type = number
default = 2048
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Why not 4096? Trying to understand the logic in the default value :)

variables.tf Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.0
rev: v1.77.1
Copy link
Member

Choose a reason for hiding this comment

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

Please add this hook after terraform_fmt:

      - id: terraform_wrapper_module_for_each

@antonbabenko antonbabenko changed the title feat: Add support for creating ECS service and container definition feat!: Add support for creating ECS service and container definition Apr 7, 2023
README.md Outdated Show resolved Hide resolved
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

LGTM! Great work (as usual)!

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

I hit approved a bit too early :) Let's make a submodule for the ECS cluster.

@bryantbiggs
Copy link
Member Author

@antonbabenko I've moved the container-definition up to the service module. I added the wrapper pre-commit hook as requested but it seems to be fighting with the format hook
image

@bryantbiggs
Copy link
Member Author

I'm not really digging this influence terragrunt is having over the modules. It seems to be more complexity than value

@antonbabenko
Copy link
Member

Fixed in antonbabenko/pre-commit-terraform#503 , please use v1.77.2 in this pull-request and rerun it. I couldn't push to your fork:

To github.com:terraform-aws-modules/terraform-aws-ecs.git
 ! [remote rejected] clowdhaus/master -> refs/pull/76/head (deny updating a hidden ref)
error: failed to push some refs to 'github.com:terraform-aws-modules/terraform-aws-ecs.git'

@antonbabenko
Copy link
Member

I'm not really digging this influence terragrunt is having over the modules. It seems to be more complexity than value

Terragrunt is one of the tools, but the overall suggestion I have is to have both options:

  1. composable ECS units (Cluster, Service, Container-Definition) as submodules
  2. root module, which combines calls to Cluster and Service submodules

It will allow users to achieve flexibility as they need regardless of the wrapper tool they use.


I see you merged the container-definition submodule into the service. I think it was good to have it as a submodule, though. This way users may use it completely separately from the rest of the ECS resources we manage in this repository.

@bryantbiggs
Copy link
Member Author

@antonbabenko I think I captured all of the changes, please take another look when you get a chance

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Looks very good. It was hard to review in GitHub UI. Minor comments related to docs mostly.

README.md Outdated

```hcl
module "ecs" {
source = "terraform-aws-modules/ecs/aws"
source = "terraform-aws-modules/ecs"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
source = "terraform-aws-modules/ecs"
source = "terraform-aws-modules/ecs/aws"

This is in many places throughout the docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in c6fef3b

main.tf Outdated
task_exec_iam_role_permissions_boundary = var.task_exec_iam_role_permissions_boundary
task_exec_iam_role_tags = var.task_exec_iam_role_tags
task_exec_iam_role_policies = var.task_exec_iam_role_policies
create_task_exec_policy = var.create_task_exec_policy
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a new line before create_... and comments like you do in the service module to separate blocks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in c6fef3b

@@ -0,0 +1,214 @@
# AWS ECS Terraform module
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# AWS ECS Terraform module
# AWS ECS Cluster Terraform module

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in c6fef3b

outputs.tf Outdated
output "services" {
description = "Map of services created and their attributes"
value = module.service
sensitive = true
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately. I really dislike this feature of Terraform... :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! See below (its now removed)


output "container_definition" {
description = "Container definition"
value = local.container_definition
Copy link
Member

Choose a reason for hiding this comment

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

Should this output be marked as sensitive? I see that in modules/service/outputs.tf it is marked so, so here it should probably be also marked?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was my bad - in the examples I was using an SSM parameter data source to pull a container image and the second you use that, it requires outputs to be marked as sensitive. So for now, I removed that and used a static string and will leave this up to users to mark the output as sensitive (if they need to)

@rajibahmed
Copy link

great work !! I am trying to use this module, really need this to make my billion dollar app work.

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

👍👍👍

@bryantbiggs bryantbiggs merged commit 57244e6 into terraform-aws-modules:master Apr 21, 2023
antonbabenko pushed a commit that referenced this pull request Apr 21, 2023
## [5.0.0](v4.1.3...v5.0.0) (2023-04-21)

### ⚠ BREAKING CHANGES

* Add support for creating ECS service and container definition (#76)

### Features

* Add support for creating ECS service and container definition ([#76](#76)) ([57244e6](57244e6))
@antonbabenko
Copy link
Member

This PR is included in version 5.0.0 🎉

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for volumes in task definitions
7 participants