From e18570a206ef6b0df9cc9f8327916077fe9c093c Mon Sep 17 00:00:00 2001 From: rpoluri <38321430+rpoluri@users.noreply.github.com> Date: Mon, 1 Mar 2021 09:41:49 -0600 Subject: [PATCH] Feature/tf format (#184) * terraform fmt * configure required providers * update changelog Co-authored-by: Raj Poluri --- .gitignore | 1 + CHANGELOG.md | 5 +++ cloudwatch.tf | 26 ++++++------- common.tf | 12 +++--- db.tf | 44 +++++++++++----------- ecs-service-discovery.tf | 20 +++++----- ecs.tf | 62 +++++++++++++++---------------- iam-cross-account-client-roles.tf | 4 +- iam-policy-cloudwatch.tf | 4 +- iam-policy-glue.tf | 2 +- iam-policy-rds.tf | 8 ++-- iam-policy-s3-buckets.tf | 16 ++++---- iam-policy-secretsmanager.tf | 8 ++-- iam-policy-sns.tf | 2 +- iam.tf | 12 +++--- k8s-readonly.tf | 18 ++++----- k8s-readwrite.tf | 22 +++++------ k8s-secrets.tf | 2 +- lb.tf | 36 +++++++++--------- route53.tf | 24 ++++++------ s3-other.tf | 2 +- s3.tf | 6 +-- secretsmanager.tf | 20 +++++----- sg.tf | 8 ++-- templates.tf | 4 +- version.tf | 8 +++- vpc-endpoint-service.tf | 8 ++-- 27 files changed, 198 insertions(+), 186 deletions(-) diff --git a/.gitignore b/.gitignore index a18f5b0..ddd08a6 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ terraform.tfstate.backup *.plan terraform.tfstate .terraform.tfstate.lock.info +.terraform.lock.hcl # Netbeans files nbactions.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 21005bc..458b70f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [6.7.3] - 2021-03-01 +### Changed +- Terraform 0.12+ formatting. +- Add required version(1.x) for kubernetes provider,to fix issues with 2.x provider. + ## [6.7.2] - 2021-01-04 ### Fixed - Fix colliding Grafana dashboard names for multiple Apiary instances. diff --git a/cloudwatch.tf b/cloudwatch.tf index 6918d96..8b8a554 100644 --- a/cloudwatch.tf +++ b/cloudwatch.tf @@ -5,7 +5,7 @@ */ data "template_file" "s3_widgets" { - count = "${length(local.schemas_info)}" + count = length(local.schemas_info) template = < schema } - template = "${file("${path.module}/templates/apiary-bucket-policy.json")}" + template = file("${path.module}/templates/apiary-bucket-policy.json") vars = { #if apiary_shared_schemas is empty or contains current schema, allow customer accounts to access this bucket. @@ -83,8 +83,8 @@ resource "aws_s3_bucket_inventory" "apiary_bucket" { destination { bucket { - format = "${var.s3_inventory_format}" - bucket_arn = "${aws_s3_bucket.apiary_inventory_bucket[0].arn}" + format = var.s3_inventory_format + bucket_arn = aws_s3_bucket.apiary_inventory_bucket[0].arn encryption { sse_s3 {} } diff --git a/secretsmanager.tf b/secretsmanager.tf index 5d28f69..ce56a5b 100644 --- a/secretsmanager.tf +++ b/secretsmanager.tf @@ -5,19 +5,19 @@ */ data "aws_secretsmanager_secret" "db_rw_user" { - name = "${var.db_rw_secret_name == "" ? format("%s-db-rw-user", local.instance_alias) : var.db_rw_secret_name}" + name = var.db_rw_secret_name == "" ? format("%s-db-rw-user", local.instance_alias) : var.db_rw_secret_name } data "aws_secretsmanager_secret" "db_ro_user" { - name = "${var.db_ro_secret_name == "" ? format("%s-db-ro-user", local.instance_alias) : var.db_ro_secret_name}" + name = var.db_ro_secret_name == "" ? format("%s-db-ro-user", local.instance_alias) : var.db_ro_secret_name } data "aws_secretsmanager_secret_version" "db_rw_user" { - secret_id = "${data.aws_secretsmanager_secret.db_rw_user.id}" + secret_id = data.aws_secretsmanager_secret.db_rw_user.id } data "aws_secretsmanager_secret_version" "db_ro_user" { - secret_id = "${data.aws_secretsmanager_secret.db_ro_user.id}" + secret_id = data.aws_secretsmanager_secret.db_ro_user.id } data "external" "db_rw_user" { @@ -29,16 +29,16 @@ data "external" "db_ro_user" { } data "aws_secretsmanager_secret" "ldap_user" { - count = "${var.ldap_url == "" ? 0 : 1}" - name = "${var.ldap_secret_name == "" ? format("%s-ldap-user", local.instance_alias) : var.ldap_secret_name}" + count = var.ldap_url == "" ? 0 : 1 + name = var.ldap_secret_name == "" ? format("%s-ldap-user", local.instance_alias) : var.ldap_secret_name } data "aws_secretsmanager_secret" "ranger_audit" { - count = "${var.ranger_audit_db_url == "" ? 0 : 1}" - name = "${var.ranger_audit_secret_name == "" ? format("%s-ranger-audit", local.instance_alias) : var.ranger_audit_secret_name}" + count = var.ranger_audit_db_url == "" ? 0 : 1 + name = var.ranger_audit_secret_name == "" ? format("%s-ranger-audit", local.instance_alias) : var.ranger_audit_secret_name } data "aws_secretsmanager_secret" "docker_registry" { - count = "${var.docker_registry_auth_secret_name == "" ? 0 : 1}" - name = "${var.docker_registry_auth_secret_name}" + count = var.docker_registry_auth_secret_name == "" ? 0 : 1 + name = var.docker_registry_auth_secret_name } diff --git a/sg.tf b/sg.tf index 422ce43..70dd9f8 100644 --- a/sg.tf +++ b/sg.tf @@ -6,21 +6,21 @@ resource "aws_security_group" "hms_sg" { name = "${local.instance_alias}-hms" - vpc_id = "${var.vpc_id}" - tags = "${var.apiary_tags}" + vpc_id = var.vpc_id + tags = var.apiary_tags ingress { from_port = 22 to_port = 22 protocol = "tcp" - cidr_blocks = "${var.ingress_cidr}" + cidr_blocks = var.ingress_cidr } ingress { from_port = 9083 to_port = 9083 protocol = "tcp" - cidr_blocks = "${var.ingress_cidr}" + cidr_blocks = var.ingress_cidr } ingress { diff --git a/templates.tf b/templates.tf index 483a5d2..f0945fa 100644 --- a/templates.tf +++ b/templates.tf @@ -5,7 +5,7 @@ */ data "template_file" "hms_readwrite" { - template = "${file("${path.module}/templates/apiary-hms-readwrite.json")}" + template = file("${path.module}/templates/apiary-hms-readwrite.json") vars = { mysql_db_host = "${var.external_database_host == "" ? join("", aws_rds_cluster.apiary_cluster.*.endpoint) : var.external_database_host}" @@ -63,7 +63,7 @@ data "template_file" "hms_readwrite" { } data "template_file" "hms_readonly" { - template = "${file("${path.module}/templates/apiary-hms-readonly.json")}" + template = file("${path.module}/templates/apiary-hms-readonly.json") vars = { mysql_db_host = "${var.external_database_host == "" ? join("", aws_rds_cluster.apiary_cluster.*.reader_endpoint) : var.external_database_host}" diff --git a/version.tf b/version.tf index ffa34e3..8345a0e 100644 --- a/version.tf +++ b/version.tf @@ -5,5 +5,11 @@ */ terraform { - required_version = "~> 0.12.0" + required_version = "> 0.12.0" + required_providers { + kubernetes = { + source = "hashicorp/kubernetes" + version = "~> 1.0" + } + } } diff --git a/vpc-endpoint-service.tf b/vpc-endpoint-service.tf index 61b825f..5796d5a 100644 --- a/vpc-endpoint-service.tf +++ b/vpc-endpoint-service.tf @@ -9,13 +9,13 @@ resource "aws_vpc_endpoint_service" "hms_readonly" { network_load_balancer_arns = compact(concat(aws_lb.apiary_hms_ro_lb.*.arn, data.aws_lb.k8s_hms_ro_lb.*.arn)) acceptance_required = false allowed_principals = formatlist("arn:aws:iam::%s:root", var.apiary_customer_accounts) - tags = "${merge(map("Name", "${local.instance_alias}-hms-readonly"), "${var.apiary_tags}")}" + tags = merge(map("Name", "${local.instance_alias}-hms-readonly"), "${var.apiary_tags}") } resource "aws_vpc_endpoint_connection_notification" "hms_readonly" { count = var.enable_vpc_endpoint_services ? 1 : 0 vpc_endpoint_service_id = join("", aws_vpc_endpoint_service.hms_readonly.*.id) - connection_notification_arn = "${aws_sns_topic.apiary_ops_sns.arn}" + connection_notification_arn = aws_sns_topic.apiary_ops_sns.arn connection_events = ["Connect", "Accept", "Reject", "Delete"] } @@ -24,12 +24,12 @@ resource "aws_vpc_endpoint_service" "hms_readwrite" { network_load_balancer_arns = compact(concat(aws_lb.apiary_hms_rw_lb.*.arn, data.aws_lb.k8s_hms_rw_lb.*.arn)) acceptance_required = false allowed_principals = distinct(compact(concat(local.assume_allowed_principals, local.producer_allowed_principals))) - tags = "${merge(map("Name", "${local.instance_alias}-hms-readwrite"), "${var.apiary_tags}")}" + tags = merge(map("Name", "${local.instance_alias}-hms-readwrite"), "${var.apiary_tags}") } resource "aws_vpc_endpoint_connection_notification" "hms_readwrite" { count = var.enable_vpc_endpoint_services ? 1 : 0 vpc_endpoint_service_id = join("", aws_vpc_endpoint_service.hms_readwrite.*.id) - connection_notification_arn = "${aws_sns_topic.apiary_ops_sns.arn}" + connection_notification_arn = aws_sns_topic.apiary_ops_sns.arn connection_events = ["Connect", "Accept", "Reject", "Delete"] }