Replace map in Terraform scripts with tomap (#7576) (#7578)

* Replace map in Terraform scripts with tomap (#7576)

* Fix Terraform linter warnings (#7576)
pull/7612/head
tkob 2021-05-12 23:34:17 +09:00 committed by GitHub
parent 6c3d1649a6
commit b1b407a0b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 48 deletions

View File

@ -61,11 +61,11 @@ resource "aws_instance" "bastion-server" {
key_name = var.AWS_SSH_KEY_NAME key_name = var.AWS_SSH_KEY_NAME
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-bastion-${count.index}", Name = "kubernetes-${var.aws_cluster_name}-bastion-${count.index}"
"Cluster", var.aws_cluster_name, Cluster = var.aws_cluster_name
"Role", "bastion-${var.aws_cluster_name}-${count.index}" Role = "bastion-${var.aws_cluster_name}-${count.index}"
)) }))
} }
/* /*
@ -87,11 +87,11 @@ resource "aws_instance" "k8s-master" {
iam_instance_profile = module.aws-iam.kube_control_plane-profile iam_instance_profile = module.aws-iam.kube_control_plane-profile
key_name = var.AWS_SSH_KEY_NAME key_name = var.AWS_SSH_KEY_NAME
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-master${count.index}", Name = "kubernetes-${var.aws_cluster_name}-master${count.index}"
"kubernetes.io/cluster/${var.aws_cluster_name}", "member", "kubernetes.io/cluster/${var.aws_cluster_name}" = "member"
"Role", "master" Role = "master"
)) }))
} }
resource "aws_elb_attachment" "attach_master_nodes" { resource "aws_elb_attachment" "attach_master_nodes" {
@ -113,11 +113,11 @@ resource "aws_instance" "k8s-etcd" {
key_name = var.AWS_SSH_KEY_NAME key_name = var.AWS_SSH_KEY_NAME
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-etcd${count.index}", Name = "kubernetes-${var.aws_cluster_name}-etcd${count.index}"
"kubernetes.io/cluster/${var.aws_cluster_name}", "member", "kubernetes.io/cluster/${var.aws_cluster_name}" = "member"
"Role", "etcd" Role = "etcd"
)) }))
} }
resource "aws_instance" "k8s-worker" { resource "aws_instance" "k8s-worker" {
@ -134,11 +134,11 @@ resource "aws_instance" "k8s-worker" {
iam_instance_profile = module.aws-iam.kube-worker-profile iam_instance_profile = module.aws-iam.kube-worker-profile
key_name = var.AWS_SSH_KEY_NAME key_name = var.AWS_SSH_KEY_NAME
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-worker${count.index}", Name = "kubernetes-${var.aws_cluster_name}-worker${count.index}"
"kubernetes.io/cluster/${var.aws_cluster_name}", "member", "kubernetes.io/cluster/${var.aws_cluster_name}" = "member"
"Role", "worker" Role = "worker"
)) }))
} }
/* /*

View File

@ -2,9 +2,9 @@ resource "aws_security_group" "aws-elb" {
name = "kubernetes-${var.aws_cluster_name}-securitygroup-elb" name = "kubernetes-${var.aws_cluster_name}-securitygroup-elb"
vpc_id = var.aws_vpc_id vpc_id = var.aws_vpc_id
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-securitygroup-elb" Name = "kubernetes-${var.aws_cluster_name}-securitygroup-elb"
)) }))
} }
resource "aws_security_group_rule" "aws-allow-api-access" { resource "aws_security_group_rule" "aws-allow-api-access" {
@ -51,7 +51,7 @@ resource "aws_elb" "aws-elb-api" {
connection_draining = true connection_draining = true
connection_draining_timeout = 400 connection_draining_timeout = 400
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-elb-api" Name = "kubernetes-${var.aws_cluster_name}-elb-api"
)) }))
} }

View File

@ -5,9 +5,9 @@ resource "aws_vpc" "cluster-vpc" {
enable_dns_support = true enable_dns_support = true
enable_dns_hostnames = true enable_dns_hostnames = true
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-vpc" Name = "kubernetes-${var.aws_cluster_name}-vpc"
)) }))
} }
resource "aws_eip" "cluster-nat-eip" { resource "aws_eip" "cluster-nat-eip" {
@ -18,9 +18,9 @@ resource "aws_eip" "cluster-nat-eip" {
resource "aws_internet_gateway" "cluster-vpc-internetgw" { resource "aws_internet_gateway" "cluster-vpc-internetgw" {
vpc_id = aws_vpc.cluster-vpc.id vpc_id = aws_vpc.cluster-vpc.id
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-internetgw" Name = "kubernetes-${var.aws_cluster_name}-internetgw"
)) }))
} }
resource "aws_subnet" "cluster-vpc-subnets-public" { resource "aws_subnet" "cluster-vpc-subnets-public" {
@ -29,10 +29,10 @@ resource "aws_subnet" "cluster-vpc-subnets-public" {
availability_zone = element(var.aws_avail_zones, count.index) availability_zone = element(var.aws_avail_zones, count.index)
cidr_block = element(var.aws_cidr_subnets_public, count.index) cidr_block = element(var.aws_cidr_subnets_public, count.index)
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-${element(var.aws_avail_zones, count.index)}-public", Name = "kubernetes-${var.aws_cluster_name}-${element(var.aws_avail_zones, count.index)}-public"
"kubernetes.io/cluster/${var.aws_cluster_name}", "member" "kubernetes.io/cluster/${var.aws_cluster_name}" = "member"
)) }))
} }
resource "aws_nat_gateway" "cluster-nat-gateway" { resource "aws_nat_gateway" "cluster-nat-gateway" {
@ -47,9 +47,9 @@ resource "aws_subnet" "cluster-vpc-subnets-private" {
availability_zone = element(var.aws_avail_zones, count.index) availability_zone = element(var.aws_avail_zones, count.index)
cidr_block = element(var.aws_cidr_subnets_private, count.index) cidr_block = element(var.aws_cidr_subnets_private, count.index)
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-${element(var.aws_avail_zones, count.index)}-private" Name = "kubernetes-${var.aws_cluster_name}-${element(var.aws_avail_zones, count.index)}-private"
)) }))
} }
#Routing in VPC #Routing in VPC
@ -64,9 +64,9 @@ resource "aws_route_table" "kubernetes-public" {
gateway_id = aws_internet_gateway.cluster-vpc-internetgw.id gateway_id = aws_internet_gateway.cluster-vpc-internetgw.id
} }
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-routetable-public" Name = "kubernetes-${var.aws_cluster_name}-routetable-public"
)) }))
} }
resource "aws_route_table" "kubernetes-private" { resource "aws_route_table" "kubernetes-private" {
@ -78,9 +78,9 @@ resource "aws_route_table" "kubernetes-private" {
nat_gateway_id = element(aws_nat_gateway.cluster-nat-gateway.*.id, count.index) nat_gateway_id = element(aws_nat_gateway.cluster-nat-gateway.*.id, count.index)
} }
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-routetable-private-${count.index}" Name = "kubernetes-${var.aws_cluster_name}-routetable-private-${count.index}"
)) }))
} }
resource "aws_route_table_association" "kubernetes-public" { resource "aws_route_table_association" "kubernetes-public" {
@ -101,9 +101,9 @@ resource "aws_security_group" "kubernetes" {
name = "kubernetes-${var.aws_cluster_name}-securitygroup" name = "kubernetes-${var.aws_cluster_name}-securitygroup"
vpc_id = aws_vpc.cluster-vpc.id vpc_id = aws_vpc.cluster-vpc.id
tags = merge(var.default_tags, map( tags = merge(var.default_tags, tomap({
"Name", "kubernetes-${var.aws_cluster_name}-securitygroup" Name = "kubernetes-${var.aws_cluster_name}-securitygroup"
)) }))
} }
resource "aws_security_group_rule" "allow-all-ingress" { resource "aws_security_group_rule" "allow-all-ingress" {