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

Require AWS provider >= 3.69, allow passing in cpu_architecture for ARM #38

Merged
merged 3 commits into from
Oct 25, 2022
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Terraform Setup
uses: hashicorp/setup-terraform@v1
with:
terraform_version: '1.1.x'
terraform_version: '1.3.x'

- name: Terraform Format
working-directory: "./"
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
terraform: [ '0.12.x', '0.13.x', '0.14.x', '0.15.x', '1.0.x', '1.1.x' ]
terraform: [ '1.3.x' ]
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand Down
111 changes: 56 additions & 55 deletions README.md

Large diffs are not rendered by default.

56 changes: 29 additions & 27 deletions examples/ci/.terraform.lock.hcl

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

4 changes: 2 additions & 2 deletions examples/ci/ci.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.12"
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 3.69"
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions examples/logging/logging.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
terraform {
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.69"
}
}
}

provider "aws" {
version = "~> 3.0"
region = "us-west-2"
region = "us-west-2"
}

module "acs" {
Expand All @@ -14,7 +24,7 @@ data "aws_elb_service_account" "main" {}
// name = "fake-example-cluster"
//}
module "fargate_api" {
source = "github.com/byu-oit/terraform-aws-fargate-api?ref=v4.0.1"
source = "github.com/byu-oit/terraform-aws-fargate-api?ref=v5.0.0"
// source = "../../" // for local testing
app_name = "example-api"
// ecs_cluster_name = aws_ecs_cluster.existing.name
Expand All @@ -29,18 +39,11 @@ module "fargate_api" {
secrets = {
foo = "/super-secret"
}
efs_volume_mounts = null
ulimits = null
}

autoscaling_config = null
codedeploy_test_listener_port = 8443
codedeploy_lifecycle_hooks = {
BeforeInstall = null
AfterInstall = null
AfterAllowTestTraffic = "testLifecycle"
BeforeAllowTraffic = null
AfterAllowTraffic = null
}

hosted_zone = module.acs.route53_zone
Expand Down
25 changes: 14 additions & 11 deletions examples/simple/simple.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
terraform {
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.69"
}
}
}

provider "aws" {
version = "~> 3.0"
region = "us-west-2"
region = "us-west-2"
}

module "acs" {
Expand All @@ -11,8 +21,8 @@ module "acs" {
// name = "fake-example-cluster"
//}
module "fargate_api" {
source = "github.com/byu-oit/terraform-aws-fargate-api?ref=v4.0.1"
// source = "../../" // for local testing
source = "github.com/byu-oit/terraform-aws-fargate-api?ref=v5.0.0"
// source = "../../" // for local testing
app_name = "example-api"
// ecs_cluster_name = aws_ecs_cluster.existing.name
container_port = 8000
Expand All @@ -26,18 +36,11 @@ module "fargate_api" {
secrets = {
foo = "/super-secret"
}
efs_volume_mounts = null
ulimits = null
}

autoscaling_config = null
codedeploy_test_listener_port = 8443
codedeploy_lifecycle_hooks = {
BeforeInstall = null
AfterInstall = null
AfterAllowTestTraffic = "testLifecycle"
BeforeAllowTraffic = null
AfterAllowTraffic = null
}

hosted_zone = module.acs.route53_zone
Expand Down
18 changes: 11 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_version = ">= 0.12.21"
required_version = ">= 1.3.0"
required_providers {
aws = ">= 3.0.0"
aws = ">= 3.69"
}
}

Expand Down Expand Up @@ -423,11 +423,15 @@ resource "aws_iam_role_policy_attachment" "xray_task_policy_attach" {
}
# --- task definition ---
resource "aws_ecs_task_definition" "task_def" {
container_definitions = jsonencode(local.container_definitions)
family = "${var.app_name}-def"
cpu = var.task_cpu
memory = var.task_memory
network_mode = "awsvpc"
container_definitions = jsonencode(local.container_definitions)
family = "${var.app_name}-def"
cpu = var.task_cpu
memory = var.task_memory
network_mode = "awsvpc"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = var.cpu_architecture
}
requires_compatibilities = ["FARGATE"]
execution_role_arn = aws_iam_role.task_execution_role.arn
task_role_arn = aws_iam_role.task_role.arn
Expand Down
40 changes: 23 additions & 17 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ variable "primary_container_definition" {
name = string
image = string
ports = list(number)
environment_variables = map(string)
secrets = map(string)
efs_volume_mounts = list(object({
environment_variables = optional(map(string))
secrets = optional(map(string))
efs_volume_mounts = optional(list(object({
name = string
file_system_id = string
root_directory = string
container_path = string
}))
ulimits = list(object({
})))
ulimits = optional(list(object({
name = string
soft_limit = number
hard_limit = number
}))
})))
})
description = "The primary container definition for your application. This one will be the only container that receives traffic from the ALB, so make sure the 'ports' field contains the same port as the 'image_port'"
}
Expand All @@ -33,19 +33,19 @@ variable "extra_container_definitions" {
name = string
image = string
ports = list(number)
environment_variables = map(string)
secrets = map(string)
efs_volume_mounts = list(object({
environment_variables = optional(map(string))
secrets = optional(map(string))
efs_volume_mounts = optional(list(object({
name = string
file_system_id = string
root_directory = string
container_path = string
}))
ulimits = list(object({
})))
ulimits = optional(list(object({
name = string
soft_limit = number
hard_limit = number
}))
})))
}))
description = "A list of extra container definitions. Defaults to []"
default = []
Expand Down Expand Up @@ -104,6 +104,11 @@ variable "task_memory" {
description = "Memory for the task definition. Defaults to 512."
default = 512
}
variable "cpu_architecture" {
type = string
description = "CPU architecture for the task definition. Defaults to X86_64."
default = "X86_64"
}
variable "security_groups" {
type = list(string)
description = "List of extra security group IDs to attach to the fargate task."
Expand Down Expand Up @@ -156,11 +161,11 @@ variable "codedeploy_test_listener_port" {
}
variable "codedeploy_lifecycle_hooks" {
type = object({
BeforeInstall = string
AfterInstall = string
AfterAllowTestTraffic = string
BeforeAllowTraffic = string
AfterAllowTraffic = string
BeforeInstall = optional(string)
AfterInstall = optional(string)
AfterAllowTestTraffic = optional(string)
BeforeAllowTraffic = optional(string)
AfterAllowTraffic = optional(string)
})
description = "Define Lambda Functions for CodeDeploy lifecycle event hooks. Or set this variable to null to not have any lifecycle hooks invoked. Defaults to null"
default = null
Expand Down Expand Up @@ -211,6 +216,7 @@ variable "autoscaling_config" {
max_capacity = number
})
description = "Configuration for default autoscaling policies and alarms. Set to null if you want to set up your own autoscaling policies and alarms."
default = null
}
variable "scaling_up_policy_config" {
type = object({
Expand Down