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

Honor network_mode of "none" #51

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
34 changes: 17 additions & 17 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Using the Repo Source

```hcl
github.com/pbs/terraform-aws-ecs-task-definition-module?ref=2.0.0
github.com/pbs/terraform-aws-ecs-task-definition-module?ref=x.y.z
```

### Alternative Installation Methods
Expand All @@ -22,7 +22,7 @@ Integrate this module like so:

```hcl
module "task" {
source = "github.com/pbs/terraform-aws-ecs-task-definition-module?ref=2.0.0"
source = "github.com/pbs/terraform-aws-ecs-task-definition-module?ref=x.y.z"

# Tagging Parameters
organization = var.organization
Expand All @@ -40,7 +40,7 @@ module "task" {

If this repo is added as a subtree, then the version of the module should be close to the version shown here:

`2.0.0`
`x.y.z`

Note, however that subtrees can be altered as desired within repositories.

Expand All @@ -64,7 +64,7 @@ Below is automatically generated documentation on this Terraform module using [t

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.24.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.42.0 |

## Modules

Expand Down
4 changes: 2 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ locals {
task_execution_role_policy_json = var.task_execution_role_policy_json != null ? var.task_execution_role_policy_json : data.aws_iam_policy_document.task_execution_role_policy_doc[0].json
get_newrelic_secret = var.newrelic_secret_arn == null && var.newrelic_secret_name != null
newrelic_secret_arn = var.newrelic_secret_arn != null ? var.newrelic_secret_arn : local.get_newrelic_secret ? data.aws_secretsmanager_secret.newrelic_secret[0].arn : ""

creator = "terraform"
open_port = var.network_mode != "none" ? var.container_port : null
creator = "terraform"

defaulted_tags = merge(
var.tags,
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_ecs_task_definition" "task_def" {
type = "APPMESH"
container_name = "envoy"
properties = {
AppPorts = var.container_port
AppPorts = local.open_port
EgressIgnoredIPs = "169.254.170.2,169.254.169.254"
IgnoredUID = "1337"
ProxyEgressPort = 15001
Expand Down
9 changes: 5 additions & 4 deletions template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ locals {
"name" : local.container_name,
"image" : "${var.image_repo}:${var.image_tag}",
"environment" : local.env_vars,
"portMappings" : [{
"containerPort" : var.container_port
}],
"essential" : true,
"logConfiguration" : local.app_log_configuration,
},
var.network_mode != "none" ? {
"portMappings" : [{ "containerPort" : local.open_port }],
} : {},
var.network_mode == "none" ? { "disableNetworking" : true, } : {},
length(var.efs_mounts) == 0 ? {} : {
"mountPoints" : [
for mount in var.efs_mounts : {
Expand Down Expand Up @@ -142,7 +143,7 @@ locals {
"user" : "1337",
"portMappings" : [
{
"containerPort" : var.container_port,
"containerPort" : local.open_port,
"protocol" : "tcp"
}
],
Expand Down