Skip to content

Commit

Permalink
Merge pull request #10 from pbs/feature/adding_arm_support
Browse files Browse the repository at this point in the history
Adding ARM Support
  • Loading branch information
yhakbar authored Nov 2, 2022
2 parents 06cfe3f + 543173f commit 145cdb8
Show file tree
Hide file tree
Showing 24 changed files with 270 additions and 121 deletions.
2 changes: 2 additions & 0 deletions README-HEADER.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ To make the service provisioned here private, set `public_service` to `false`. T

To switch the kind of load balancer used from an application load balancer to a network load balancer, set `load_balancer_type` to `network`.

To run an ECS service on ARM architecture, set `runtime_platform` accordingly. The `cpu_architecture` object property being set to `ARM64` is what adjusts the task definition such that the tasks run on Graviton hardware for Fargate tasks.

Integrate this module like so:

```hcl
Expand Down
13 changes: 8 additions & 5 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-service-module?ref=2.1.4
github.com/pbs/terraform-aws-ecs-service-module?ref=x.y.z
```

### Alternative Installation Methods
Expand All @@ -20,11 +20,13 @@ To make the service provisioned here private, set `public_service` to `false`. T

To switch the kind of load balancer used from an application load balancer to a network load balancer, set `load_balancer_type` to `network`.

To run an ECS service on ARM architecture, set `runtime_platform` accordingly. The `cpu_architecture` object property being set to `ARM64` is what adjusts the task definition such that the tasks run on Graviton hardware for Fargate tasks.

Integrate this module like so:

```hcl
module "service" {
source = "github.com/pbs/terraform-aws-ecs-service-module?ref=2.1.4"
source = "github.com/pbs/terraform-aws-ecs-service-module?ref=x.y.z"
# Required
primary_hosted_zone = "example.com"
Expand All @@ -45,7 +47,7 @@ module "service" {

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

`2.1.4`
`x.y.z`

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

Expand Down Expand Up @@ -74,8 +76,8 @@ Below is automatically generated documentation on this Terraform module using [t

| Name | Source | Version |
|------|--------|---------|
| <a name="module_cluster"></a> [cluster](#module\_cluster) | github.com/pbs/terraform-aws-ecs-cluster-module | 0.0.1 |
| <a name="module_task"></a> [task](#module\_task) | github.com/pbs/terraform-aws-ecs-task-definition-module | 0.1.1 |
| <a name="module_cluster"></a> [cluster](#module\_cluster) | github.com/pbs/terraform-aws-ecs-cluster-module | 0.0.2 |
| <a name="module_task"></a> [task](#module\_task) | github.com/pbs/terraform-aws-ecs-task-definition-module | 0.2.0 |

## Resources

Expand Down Expand Up @@ -197,6 +199,7 @@ Below is automatically generated documentation on this Terraform module using [t
| <a name="input_restricted_cidr_blocks"></a> [restricted\_cidr\_blocks](#input\_restricted\_cidr\_blocks) | CIDR blocks to receive restricted service access. If empty, no CIDRs will be allowed to connect. | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
| <a name="input_restricted_sg"></a> [restricted\_sg](#input\_restricted\_sg) | SG to receive restricted service access. If null, no sg will be configured to connect | `string` | `null` | no |
| <a name="input_role_policy_json"></a> [role\_policy\_json](#input\_role\_policy\_json) | the policy to apply for this service. Defaults to a valid ECS role policy if null. | `string` | `null` | no |
| <a name="input_runtime_platform"></a> [runtime\_platform](#input\_runtime\_platform) | (optional) Runtime platform for the task. Defaults to LINUX operating system family w/ CPU architecture x86\_64. | <pre>object({<br> operating_system_family = optional(string, "LINUX")<br> cpu_architecture = optional(string, "X86_64")<br> })</pre> | <pre>{<br> "cpu_architecture": "X86_64",<br> "operating_system_family": "LINUX"<br>}</pre> | no |
| <a name="input_scale_down_adjustment"></a> [scale\_down\_adjustment](#input\_scale\_down\_adjustment) | Tasks to add on scale up | `number` | `-1` | no |
| <a name="input_scale_down_cooldown"></a> [scale\_down\_cooldown](#input\_scale\_down\_cooldown) | Scale down cooldown in minutes | `number` | `5` | no |
| <a name="input_scale_down_cpu_threshold"></a> [scale\_down\_cpu\_threshold](#input\_scale\_down\_cpu\_threshold) | Threshold at which CPU utilization triggers a scale down event | `number` | `20` | no |
Expand Down
2 changes: 1 addition & 1 deletion cluster.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "cluster" {
count = var.cluster == null ? 1 : 0
source = "github.com/pbs/terraform-aws-ecs-cluster-module?ref=0.0.1"
source = "github.com/pbs/terraform-aws-ecs-cluster-module?ref=0.0.2"

organization = var.organization
environment = var.environment
Expand Down
26 changes: 13 additions & 13 deletions examples/am/.terraform.lock.hcl

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

10 changes: 4 additions & 6 deletions examples/am/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ module "service_v1" {

name = "${var.product}-v1"

mesh_name = module.mesh.id
virtual_node = "ex-service-v1"
virtual_service = module.virtual_service.name
mesh_name = module.mesh.id
virtual_node = "ex-service-v1"

namespace = var.product
namespace_id = module.namespace.id
Expand All @@ -170,9 +169,8 @@ module "service_v2" {

name = "${var.product}-v2"

mesh_name = module.mesh.id
virtual_node = "ex-service-v2"
virtual_service = module.virtual_service.name
mesh_name = module.mesh.id
virtual_node = "ex-service-v2"

namespace = var.product
namespace_id = module.namespace.id
Expand Down
2 changes: 2 additions & 0 deletions examples/arm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
backend.tf
provider.tf
22 changes: 22 additions & 0 deletions examples/arm/.terraform.lock.hcl

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

14 changes: 14 additions & 0 deletions examples/arm/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module "service" {
source = "../.."

primary_hosted_zone = var.primary_hosted_zone

runtime_platform = {
cpu_architecture = "ARM64"
}

organization = var.organization
environment = var.environment
product = var.product
repo = var.repo
}
3 changes: 3 additions & 0 deletions examples/arm/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "domain_name" {
value = module.service.domain_name
}
9 changes: 9 additions & 0 deletions examples/arm/sample-backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# terraform {
# backend "s3" {
# bucket = "my-bucket-tfstate"
# key = "example-terraform-aws-ecs-service-arm"
# profile = "my-profile"
# region = "us-east-1"
# dynamodb_table = "terraform-lock"
# }
# }
12 changes: 12 additions & 0 deletions examples/arm/sample-provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# provider "aws" {
# region = "us-east-1"
# profile = "my-profile"
# default_tags {
# tags = {
# product = var.product
# environment = var.environment
# repo = var.repo
# organization = var.organization
# }
# }
# }
45 changes: 45 additions & 0 deletions examples/arm/tags.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
variable "environment" {
description = "Environment (sharedtools, dev, staging, prod)"
type = string

default = "sharedtools"

validation {
condition = contains(["sharedtools", "dev", "staging", "prod"], var.environment)
error_message = "The environment variable must be one of [sharedtools, dev, staging, prod]."
}
}

variable "product" {
description = "Tag used to group resources according to application"

default = "example-tf-ecs-service-arm"

validation {
condition = can(regex("[a-z\\-]+", var.product))
error_message = "The product variable violates approved regex."
}
}

variable "repo" {
description = "Tag used to point to the repo using this module"

default = "https://github.com/pbs/terraform-ecs-service-module.git"

validation {
condition = can(regex("(?:git|ssh|https?|git@[-\\w.]+):(\\/\\/)?(.*?)(\\.git)(\\/?|\\#[-\\d\\w._]+?)$", var.repo))
error_message = "The repo variable violates approved regex."
}
}

variable "organization" {
description = "Organization using this module. Used to prefix tags so that they are easily identified as being from your organization"
type = string

default = "example"

validation {
condition = can(regex("[a-z\\-]+", var.organization))
error_message = "The organization variable violates approved regex."
}
}
4 changes: 4 additions & 0 deletions examples/arm/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "primary_hosted_zone" {
type = string
description = "Primary hosted zone for this service. Populate `TF_VAR_primary_hosted_zone` before running any tests to have this value populated."
}
27 changes: 13 additions & 14 deletions examples/basic/.terraform.lock.hcl

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

26 changes: 13 additions & 13 deletions examples/efs/.terraform.lock.hcl

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

26 changes: 13 additions & 13 deletions examples/image/.terraform.lock.hcl

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

26 changes: 13 additions & 13 deletions examples/nlb/.terraform.lock.hcl

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

Loading

0 comments on commit 145cdb8

Please sign in to comment.