Skip to content

Commit

Permalink
feat: Allow configuration of auto assign public IP (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
k911 authored and aknysh committed Apr 29, 2019
1 parent e65b6c2 commit d8b29c7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are
## Usage


**IMPORTANT:** The `master` branch is used in `source` just as an example. In your code, do not pin to `master` because there may be breaking changes between releases.
Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest releases](https://github.com/cloudposse/terraform-aws-ecs-alb-service-task/releases).



For a complete example, see [examples/complete](examples/complete)

```hcl
Expand Down Expand Up @@ -147,6 +152,7 @@ Available targets:
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| alb_target_group_arn | The ALB target group ARN for the ECS service | string | - | yes |
| assign_public_ip | Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false. | string | `false` | no |
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
| container_definition_json | The JSON of the task container definition | string | - | yes |
| container_name | The name of the container in task definition to associate with the load balancer | string | - | yes |
Expand All @@ -162,9 +168,9 @@ Available targets:
| name | Solution name, e.g. 'app' or 'cluster' | string | - | yes |
| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes |
| network_mode | The network mode to use for the task. This is required to be awsvpc for `FARGATE` `launch_type` | string | `awsvpc` | no |
| private_subnet_ids | Private subnet IDs | list | - | yes |
| security_group_ids | Security group IDs to allow in Service `network_configuration` | list | - | yes |
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | - | yes |
| subnet_ids | Subnet IDs | list | - | yes |
| tags | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | map | `<map>` | no |
| task_cpu | The number of CPU units used by the task. If using `FARGATE` launch type `task_cpu` must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `256` | no |
| task_memory | The amount of memory (in MiB) used by the task. If using Fargate launch type `task_memory` must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `512` | no |
Expand Down
3 changes: 2 additions & 1 deletion docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| alb_target_group_arn | The ALB target group ARN for the ECS service | string | - | yes |
| assign_public_ip | Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false. | string | `false` | no |
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
| container_definition_json | The JSON of the task container definition | string | - | yes |
| container_name | The name of the container in task definition to associate with the load balancer | string | - | yes |
Expand All @@ -18,9 +19,9 @@
| name | Solution name, e.g. 'app' or 'cluster' | string | - | yes |
| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes |
| network_mode | The network mode to use for the task. This is required to be awsvpc for `FARGATE` `launch_type` | string | `awsvpc` | no |
| private_subnet_ids | Private subnet IDs | list | - | yes |
| security_group_ids | Security group IDs to allow in Service `network_configuration` | list | - | yes |
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | - | yes |
| subnet_ids | Subnet IDs | list | - | yes |
| tags | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | map | `<map>` | no |
| task_cpu | The number of CPU units used by the task. If using `FARGATE` launch type `task_cpu` must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `256` | no |
| task_memory | The amount of memory (in MiB) used by the task. If using Fargate launch type `task_memory` must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `512` | no |
Expand Down
10 changes: 6 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ resource "aws_ecs_service" "ignore_changes_task_definition" {
tags = "${module.default_label.tags}"

network_configuration {
security_groups = ["${var.security_group_ids}", "${aws_security_group.ecs_service.id}"]
subnets = ["${var.private_subnet_ids}"]
security_groups = ["${var.security_group_ids}", "${aws_security_group.ecs_service.id}"]
subnets = ["${var.subnet_ids}"]
assign_public_ip = "${var.assign_public_ip}"
}

load_balancer {
Expand All @@ -217,8 +218,9 @@ resource "aws_ecs_service" "default" {
tags = "${module.default_label.tags}"

network_configuration {
security_groups = ["${var.security_group_ids}", "${aws_security_group.ecs_service.id}"]
subnets = ["${var.private_subnet_ids}"]
security_groups = ["${var.security_group_ids}", "${aws_security_group.ecs_service.id}"]
subnets = ["${var.subnet_ids}"]
assign_public_ip = "${var.assign_public_ip}"
}

load_balancer {
Expand Down
10 changes: 8 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ variable "container_port" {
default = 80
}

variable "private_subnet_ids" {
description = "Private subnet IDs"
variable "subnet_ids" {
description = "Subnet IDs"
type = "list"
}

Expand Down Expand Up @@ -125,3 +125,9 @@ variable "ignore_changes_task_definition" {
description = "Whether to ignore changes in container definition and task definition in the ECS service"
default = "true"
}

variable "assign_public_ip" {
type = "string"
default = "false"
description = "Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false."
}

0 comments on commit d8b29c7

Please sign in to comment.