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: Allow disabling service creation to support creating just a task definition #176

Merged
merged 2 commits into from
Mar 12, 2024
Merged

feat: Allow disabling service creation to support creating just a task definition #176

merged 2 commits into from
Mar 12, 2024

Conversation

lancedikson
Copy link
Contributor

@lancedikson lancedikson commented Mar 3, 2024

Description

The new create_service_resource variable controls whether a service resource should be created (which is true by default) allowing skipping creation of the service when it's not required.

Motivation and Context

Breaking Changes

No breaking changes were introduced in the PR.

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

@lancedikson lancedikson changed the title feat: added create_service_resource variable support Added create_service_resource variable support Mar 3, 2024
@lancedikson lancedikson changed the title Added create_service_resource variable support feat: Added create_service_resource variable support Mar 3, 2024
Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

can we add an example of how to use this so we can validate it works as intended

@lancedikson
Copy link
Contributor Author

lancedikson commented Mar 3, 2024

@bryantbiggs, sure, I've added an example in the last commit. In this case I haven't tested the example as I don't have a sandbox account I can play around easily with it at the moment, though tf plan shows exactly what I'd expect — cluster + task definition + all supporting resources, without service and autoscaling groups, LBs, etc. Would that be enough for you to test it out and see it this helps? In the meantime, I will apply the proposed change in the development stage over our own resources tomorrow and see how it works for a real use case.

@lancedikson
Copy link
Contributor Author

Getting back to you with an update: the fix worked for our case — an ECS cluster + a standalone task definition for it. Works as expected. We're going to use the branch until it's implemented as a part of the official module. @bryantbiggs waiting for your feedback regarding the example I provided. I'm happy to complete the rest of the change-related routines if you confirm that the solution is aligned with the whole module concept 🙏

@bryantbiggs bryantbiggs marked this pull request as ready for review March 4, 2024 14:13
Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

Looks great, few tweaks to update - make sure to run pre-commit run -a to update docs and format code to pass CI checks

examples/standalone-task/main.tf Outdated Show resolved Hide resolved
examples/standalone-task/main.tf Outdated Show resolved Hide resolved
main.tf Outdated Show resolved Hide resolved
modules/service/main.tf Outdated Show resolved Hide resolved
modules/service/main.tf Outdated Show resolved Hide resolved
modules/service/variables.tf Outdated Show resolved Hide resolved
@bryantbiggs bryantbiggs changed the title feat: Added create_service_resource variable support feat: Allow disabling service creation to support creating just a task definition Mar 4, 2024
@lancedikson
Copy link
Contributor Author

Thanks for the review and sorry for the silence — I've been feeling unwell. Will try to push the necessary changes today 👌

Addressing the issue #162
#162

The new create_service_resource variable controls whether a `service` resource should be created (which is `true` by default), but still allows skipping creation of the service when it's not required.
@lancedikson
Copy link
Contributor Author

@bryantbiggs all checks are now passed, though I haven't tested the Fargate example on a real account. Could you please help out with this? I still don't have a spare sandbox for testing out open-source tools. However, I tested the change in the branch on our dev-account over the resource we configured last week using the proposed change — it still works there.

@bryantbiggs
Copy link
Member

I'll test this tonight/early tomorrow - there are a few minor tweaks we'll need to make, if you enable us to contribute to your PR we can push them directly here, otherwise I'll cut a PR against your PR (meta!)

@lancedikson
Copy link
Contributor Author

Thanks! Sure, I've added you to our fork — feel free to modify the branch of this PR

@@ -114,6 +114,7 @@ module "ecs_service" {

linux_parameters = {
capabilities = {
add = []
Copy link
Member

Choose a reason for hiding this comment

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

just to quiet the diff

@@ -60,7 +60,7 @@ locals {
secrets = length(var.secrets) > 0 ? var.secrets : null
startTimeout = var.start_timeout
stopTimeout = var.stop_timeout
systemControls = length(var.system_controls) > 0 ? var.system_controls : null
systemControls = length(var.system_controls) > 0 ? var.system_controls : []
Copy link
Member

Choose a reason for hiding this comment

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

this was also to quiet the diff

@@ -59,6 +59,11 @@ output "task_definition_family" {
value = try(aws_ecs_task_definition.this[0].family, null)
}

output "task_definition_family_revision" {
Copy link
Member

Choose a reason for hiding this comment

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

seems like this could come in handy for others

Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

thank you! (feel free to remove my access to your fork at your convenience, thanks again!)

@bryantbiggs bryantbiggs merged commit 94c992a into terraform-aws-modules:master Mar 12, 2024
11 checks passed
@bryantbiggs bryantbiggs deleted the feat/standalone-task-definition branch March 12, 2024 00:23
antonbabenko pushed a commit that referenced this pull request Mar 12, 2024
## [5.10.0](v5.9.3...v5.10.0) (2024-03-12)

### Features

* Allow disabling service creation to support creating just a task definition ([#176](#176)) ([94c992a](94c992a)), closes [#162](#162)
@antonbabenko
Copy link
Member

This PR is included in version 5.10.0 🎉

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 Apr 13, 2024
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.

Support for scheduled tasks/standalone task definitions and container definitions
3 participants