Skip to content

Commit

Permalink
terraform fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
reachfh committed Jun 27, 2024
1 parent c4ac202 commit c3503dd
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 109 deletions.
8 changes: 4 additions & 4 deletions terraform/modules/ec2-private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ data "aws_ami" "this" {
}

locals {
name = var.name == "" ? "${var.app_name}-${var.comp}" : var.name
host_name = var.host_name == "" ? var.comp : var.host_name
fqdn = "${local.host_name}.${var.dns_domain}"
ami = var.ami == "" ? data.aws_ami.this.id : var.ami
name = var.name == "" ? "${var.app_name}-${var.comp}" : var.name
host_name = var.host_name == "" ? var.comp : var.host_name
fqdn = "${local.host_name}.${var.dns_domain}"
ami = var.ami == "" ? data.aws_ami.this.id : var.ami
availability_zones = var.availability_zones == [] ? data.aws_availability_zones.available.names : var.availability_zones
}

Expand Down
4 changes: 2 additions & 2 deletions terraform/modules/ec2-private/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variable "ami_filter_name" {
type = list(string)
# default = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-*"]
# default = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-arm64-server-*"]
default = []
default = []
}

variable "ami_filter_architecture" {
Expand All @@ -21,7 +21,7 @@ variable "ami_filter_owners" {
description = "Filter to find AMI owners, e.g. amazon"
type = list(string)
# default = ["amazon"]
default = null
default = null
}

variable "availability_zones" {
Expand Down
36 changes: 18 additions & 18 deletions terraform/modules/ecr-build/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# }

locals {
name = var.name == "" ? "${var.org}/${var.app_name}-${var.comp}" : var.name
name = var.name == "" ? "${var.org}/${var.app_name}-${var.comp}" : var.name
configure_policy = var.allow_codebuild || length(var.cross_accounts) > 0
}

Expand Down Expand Up @@ -53,25 +53,25 @@ data "aws_iam_policy_document" "this" {
dynamic "statement" {
for_each = var.allow_codebuild ? list([1]) : []
content {
sid = "CodeBuildAccess"
sid = "CodeBuildAccess"

actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:BatchImportUpstreamImage",
"ecr:CompleteLayerUpload",
"ecr:CreateRepository",
"ecr:GetAuthorizationToken",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart",
]
actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:BatchImportUpstreamImage",
"ecr:CompleteLayerUpload",
"ecr:CreateRepository",
"ecr:GetAuthorizationToken",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart",
]

principals {
type = "Service"
identifiers = ["codebuild.amazonaws.com"]
}
principals {
type = "Service"
identifiers = ["codebuild.amazonaws.com"]
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions terraform/modules/ecs-service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ resource "aws_ecs_service" "this" {
# }
# }

health_check_grace_period_seconds = var.health_check_grace_period_seconds
iam_role = var.iam_role
launch_type = var.launch_type
health_check_grace_period_seconds = var.health_check_grace_period_seconds
iam_role = var.iam_role
launch_type = var.launch_type

# https://www.terraform.io/docs/providers/aws/r/ecs_service.html#load_balancer-1
dynamic "load_balancer" {
Expand Down Expand Up @@ -113,16 +113,16 @@ resource "aws_ecs_service" "this" {
dynamic "service_connect_configuration" {
for_each = var.service_connect_configuration == null ? [] : tolist([1])
content {
enabled = lookup(service_connect_configuration, "enabled", true)
enabled = lookup(service_connect_configuration, "enabled", true)
namespace = lookup(service_connect_configuration, "namespace", null)

dynamic "service" {
for_each = lookup(service_connect_configuration, "service", [])
content {
client_alias = lookup(service.value, "client_alias", [])
discovery_name = lookup(service.value, "discovery_name", null)
client_alias = lookup(service.value, "client_alias", [])
discovery_name = lookup(service.value, "discovery_name", null)
ingress_port_override = lookup(service.value, "ingress_port_override", null)
port_name = lookup(service.value, "port_name", null)
port_name = lookup(service.value, "port_name", null)
}
}

Expand All @@ -135,7 +135,7 @@ resource "aws_ecs_service" "this" {
dynamic "secret_option" {
for_each = lookup(log_configuration.value, "secret_option", [])
content {
name = lookup(secret_option.value, "name", null)
name = lookup(secret_option.value, "name", null)
value_from = lookup(secret_option.value, "value_from", null)
}
}
Expand Down
56 changes: 28 additions & 28 deletions terraform/modules/ecs-service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ variable "scheduling_strategy" {
variable "service_registries" {
description = "Service discovery registries for the service"
type = object({
registry_arn = string,
registry_arn = string,
# Port of SRV record
port = optional(number),
port = optional(number),
# Container name from task definition
container_name = optional(string),
container_name = optional(string),
# Port from task definition
container_port = optional(number)
container_port = optional(number)
})
default = null
}
Expand All @@ -160,34 +160,34 @@ variable "service_connect_configuration" {
type = object({
enabled = optional(bool), # Default true
log_configuration = optional(object({
# Log driver to use. Valid values: awslogs, fluentd, gelf, journald, json-file, splunk, syslog
log_driver = string,
# Configuration options to send to the log driver. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html
options = optional(map(string)),
# The secrets to pass to the log configuration. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html
secret_option = optional(list(object({
# Name of secret
name = string,
# Secret to expose to the container, either full ARN of the
# AWS Secrets Manager secret or full ARN of parameter in
# AWS Systems Manager Parameter Store.
value_from = string
})))
})),
# Log driver to use. Valid values: awslogs, fluentd, gelf, journald, json-file, splunk, syslog
log_driver = string,
# Configuration options to send to the log driver. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html
options = optional(map(string)),
# The secrets to pass to the log configuration. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html
secret_option = optional(list(object({
# Name of secret
name = string,
# Secret to expose to the container, either full ARN of the
# AWS Secrets Manager secret or full ARN of parameter in
# AWS Systems Manager Parameter Store.
value_from = string
})))
})),
# The namespace name or ARN of aws_service_discovery_http_namespace
namespace = optional(string),
# Service Connect service objects
service = optional(list(object({
# List of client aliases for ths service. Maximum number of aliases is 1.
client_alias = optional(list(string)),
# The name of the new AWS Cloud Map service that ECS creates.
# Must be a valid DNS name, and must be unique in the namespace.
discovery_name = optional(string),
# Port number for the Service Connect proxy to listen on.
ingress_port_override = optional(number),
# Name of one of the portMappings from all the containers in the task definition.
port_name = number
}))),
# List of client aliases for ths service. Maximum number of aliases is 1.
client_alias = optional(list(string)),
# The name of the new AWS Cloud Map service that ECS creates.
# Must be a valid DNS name, and must be unique in the namespace.
discovery_name = optional(string),
# Port number for the Service Connect proxy to listen on.
ingress_port_override = optional(number),
# Name of one of the portMappings from all the containers in the task definition.
port_name = number
}))),
})
default = null
}
Expand Down
6 changes: 3 additions & 3 deletions terraform/modules/iam-ecs-task-role-app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ data "aws_iam_policy_document" "ecs-discovery" {
}

resource "aws_iam_policy" "ecs-discovery" {
count = var.enable_ecs_discovery ? 1 : 0
name = "${local.name}-${var.comp}-ecs-discovery"
count = var.enable_ecs_discovery ? 1 : 0
name = "${local.name}-${var.comp}-ecs-discovery"
description = "Allow ECS service and task discovery"
policy = data.aws_iam_policy_document.ecs-discovery[0].json
}
Expand Down Expand Up @@ -288,7 +288,7 @@ data "aws_iam_policy_document" "sqs" {
}

resource "aws_iam_policy" "sqs" {
count = local.configure_sqs ? 1 : 0
count = local.configure_sqs ? 1 : 0
name_prefix = "${local.name}-${var.comp}-sqs-"
description = "allow sqs actions"
policy = data.aws_iam_policy_document.sqs[0].json
Expand Down
36 changes: 18 additions & 18 deletions terraform/modules/iam-github-action/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,25 @@ locals {
kms_key_id = var.kms_key_id
subs = var.subs == null ? [var.sub] : var.subs

ecs_task_roles = [ for r in var.ecs : r.task_role_arn ]
ecs_execution_roles = [ for r in var.ecs : r.execution_role_arn ]
ecs_service_arns = [ for r in var.ecs : r.service_arn ]
ecs_codedeploy_arns = flatten([ for r in var.ecs :
ecs_task_roles = [for r in var.ecs : r.task_role_arn]
ecs_execution_roles = [for r in var.ecs : r.execution_role_arn]
ecs_service_arns = [for r in var.ecs : r.service_arn]
ecs_codedeploy_arns = flatten([for r in var.ecs :
try(r.codedeploy_application_name, null) != null ?
[
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentgroup:${r.codedeploy_application_name}/${r.codedeploy_deployment_group_name}",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentconfig:*",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:application:${r.codedeploy_application_name}"
] : []
[
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentgroup:${r.codedeploy_application_name}/${r.codedeploy_deployment_group_name}",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentconfig:*",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:application:${r.codedeploy_application_name}"
] : []
])

ec2_codedeploy_arns = flatten([ for r in var.ec2 :
ec2_codedeploy_arns = flatten([for r in var.ec2 :
try(r.codedeploy_application_name, null) != null ?
[
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentgroup:${r.codedeploy_application_name}/${r.codedeploy_deployment_group_name}",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentconfig:*",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:application:${r.codedeploy_application_name}"
] : []
[
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentgroup:${r.codedeploy_application_name}/${r.codedeploy_deployment_group_name}",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:deploymentconfig:*",
"arn:${var.aws_partition}:codedeploy:${var.aws_region}:${local.aws_account_id}:application:${r.codedeploy_application_name}"
] : []
])

enable_codedeploy = length(local.ec2_codedeploy_arns) > 0
Expand Down Expand Up @@ -306,7 +306,7 @@ data "aws_iam_policy_document" "codebuild" {
count = local.enable_codebuild ? 1 : 0

statement {
actions = [
actions = [
# Required to start running builds
"codebuild:StartBuild",
# Required to get information about builds
Expand All @@ -316,7 +316,7 @@ data "aws_iam_policy_document" "codebuild" {
}

statement {
actions = [
actions = [
"logs:GetLogEvents",
]
resources = ["arn:${var.aws_partition}:logs:${var.aws_region}:${local.aws_account_id}:log-group:/aws/codebuild/${var.codebuild_project_name}:*"]
Expand Down Expand Up @@ -511,7 +511,7 @@ data "aws_iam_policy_document" "kms" {
}

resource "aws_iam_policy" "kms" {
count = local.kms_key_id != null ? 1 : 0
count = local.kms_key_id != null ? 1 : 0

name_prefix = "${local.name}-kms-"
description = "Enable access to KMS"
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/iam-instance-profile-app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ locals {

# Send data to to AWS X-Ray and Prometheus
locals {
write_xray = var.xray
write_xray = var.xray
write_prometheus = var.prometheus
}

Expand Down
6 changes: 3 additions & 3 deletions terraform/modules/nat/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data "aws_ami" "fck_nat" {
}

locals {
name = var.name == "" ? var.app_name : var.name
name = var.name == "" ? var.app_name : var.name
image_id = var.image_id == null ? data.aws_ami.fck_nat.id : var.image_id

tags = merge(
Expand All @@ -64,9 +64,9 @@ module "nat" {
private_route_table_ids = var.private_route_table_ids
enabled = var.enabled

image_id = local.image_id
image_id = local.image_id
instance_types = var.instance_types
key_name = var.key_name
key_name = var.key_name

# enable port forwarding (optional)
# user_data_write_files = [
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/nat/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output "eni_id" {

output "eni_private_ip" {
description = "Private IP of the ENI for the NAT instance"
value = module.nat.eni_private_ip
value = module.nat.eni_private_ip
}

output "iam_role_name" {
Expand Down
8 changes: 4 additions & 4 deletions terraform/modules/nat/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ variable "image_id" {

variable "instance_types" {
description = "AMI of NAT instance, default latest Amazon Linux 2"
type = list(string)
default = ["t4g.nano"]
type = list(string)
default = ["t4g.nano"]
}

variable "key_name" {
description = "Name of key pair"
type = string
default = null
type = string
default = null
}

variable "name" {
Expand Down
6 changes: 3 additions & 3 deletions terraform/modules/rds/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Create RDS database instance for app

locals {
name = var.name == "" ? "${var.app_name}-${var.comp}" : var.name
dns_name = var.dns_name == "" ? "${var.comp}-db" : var.dns_name
enable_sd = var.service_discovery_namespace_id == null ? false : true
name = var.name == "" ? "${var.app_name}-${var.comp}" : var.name
dns_name = var.dns_name == "" ? "${var.comp}-db" : var.dns_name
enable_sd = var.service_discovery_namespace_id == null ? false : true
}

# https://www.terraform.io/docs/providers/aws/d/db_instance.html
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/rds/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ variable "publicly_accessible" {

variable "rds_master_pass" {
description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file"
default = null
default = null
}

variable "rds_master_user" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
variable "description" {
description = "Description"
type = string
default = null
type = string
default = null
}

variable "name" {
description = "DNS namespace"
default = ""
default = ""
}

variable "vpc_id" {
Expand Down
Loading

0 comments on commit c3503dd

Please sign in to comment.