Fix terraform0.13 errors (#7077)

* [terraform/aws] Fix Terraform >=0.13 warnings

Terraform >=0.13 gives the following warning:

```
Warning: Interpolation-only expressions are deprecated
```

The fix was tested as follows:
```
rm -rf .terraform && terraform0.12.26 init && terraform0.12.26 validate
rm -rf .terraform && terraform0.13.5 init && terraform0.13.5 validate
rm -rf .terraform && terraform0.14.3 init && terraform0.14.3 validate
```
which gave no errors nor warnings.

* [terraform/openstack] Fixes for Terraform >=0.13

Terraform >=0.13 gives the following error:
```
Error: Failed to install providers
Could not find required providers, but found possible alternatives:
  hashicorp/openstack -> terraform-provider-openstack/openstack
```

This patch fixes these errors.

This fix was tested as follows:
```
rm -rf .terraform && terraform0.12.26 init && terraform0.12.26 validate
rm -rf .terraform && terraform0.13.5 init && terraform0.13.5 validate
rm -rf .terraform && terraform0.14.3 init && terraform0.14.3 validate
```
which gave no errors nor warnings for Terraform 0.13.5 and Terraform
0.14.3. Unfortunately, 0.12.x gives a harmless warning, but
with 0.14.3 out the door, I guess we need to move on.

* [terraform/packet] Fixes for Terraform >=0.13

This fix was tested as follows:
```
export PACKET_AUTH_TOKEN=blah-blah
rm -rf .terraform && terraform0.12.26 init && terraform0.12.26 validate
rm -rf .terraform && terraform0.13.5 init && terraform0.13.5 validate
rm -rf .terraform && terraform0.14.3 init && terraform0.14.3 validate
```

Errors are gone, but warnings still remain. It is impossible to please
all three versions of Terraform.

* Add tests for Terraform >=0.13
This commit is contained in:
Cristian Klein 2020-12-23 14:08:26 +01:00 committed by GitHub
parent 9db4b949f2
commit fd3ebc13f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 97 additions and 18 deletions

View file

@ -74,6 +74,48 @@ tf-validate-aws:
PROVIDER: aws PROVIDER: aws
CLUSTER: $CI_COMMIT_REF_NAME CLUSTER: $CI_COMMIT_REF_NAME
tf-0.13.x-validate-openstack:
extends: .terraform_validate
variables:
TF_VERSION: 0.13.5
PROVIDER: openstack
CLUSTER: $CI_COMMIT_REF_NAME
tf-0.13.x-validate-packet:
extends: .terraform_validate
variables:
TF_VERSION: 0.13.5
PROVIDER: packet
CLUSTER: $CI_COMMIT_REF_NAME
tf-0.13.x-validate-aws:
extends: .terraform_validate
variables:
TF_VERSION: 0.13.5
PROVIDER: aws
CLUSTER: $CI_COMMIT_REF_NAME
tf-0.14.x-validate-openstack:
extends: .terraform_validate
variables:
TF_VERSION: 0.14.3
PROVIDER: openstack
CLUSTER: $CI_COMMIT_REF_NAME
tf-0.14.x-validate-packet:
extends: .terraform_validate
variables:
TF_VERSION: 0.14.3
PROVIDER: packet
CLUSTER: $CI_COMMIT_REF_NAME
tf-0.14.x-validate-aws:
extends: .terraform_validate
variables:
TF_VERSION: 0.14.3
PROVIDER: aws
CLUSTER: $CI_COMMIT_REF_NAME
# tf-packet-ubuntu16-default: # tf-packet-ubuntu16-default:
# extends: .terraform_apply # extends: .terraform_apply
# variables: # variables:

View file

@ -63,7 +63,7 @@ resource "aws_instance" "bastion-server" {
tags = merge(var.default_tags, map( tags = merge(var.default_tags, map(
"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}"
)) ))
} }

View file

@ -16,15 +16,15 @@ variable "k8s_secure_api_port" {
variable "aws_avail_zones" { variable "aws_avail_zones" {
description = "Availability Zones Used" description = "Availability Zones Used"
type = "list" type = list(string)
} }
variable "aws_subnet_ids_public" { variable "aws_subnet_ids_public" {
description = "IDs of Public Subnets" description = "IDs of Public Subnets"
type = "list" type = list(string)
} }
variable "default_tags" { variable "default_tags" {
description = "Tags for all resources" description = "Tags for all resources"
type = "map" type = map(string)
} }

View file

@ -8,20 +8,20 @@ variable "aws_cluster_name" {
variable "aws_avail_zones" { variable "aws_avail_zones" {
description = "AWS Availability Zones Used" description = "AWS Availability Zones Used"
type = "list" type = list(string)
} }
variable "aws_cidr_subnets_private" { variable "aws_cidr_subnets_private" {
description = "CIDR Blocks for private subnets in Availability zones" description = "CIDR Blocks for private subnets in Availability zones"
type = "list" type = list(string)
} }
variable "aws_cidr_subnets_public" { variable "aws_cidr_subnets_public" {
description = "CIDR Blocks for public subnets in Availability zones" description = "CIDR Blocks for public subnets in Availability zones"
type = "list" type = list(string)
} }
variable "default_tags" { variable "default_tags" {
description = "Default tags for all resources" description = "Default tags for all resources"
type = "map" type = map(string)
} }

View file

@ -44,12 +44,12 @@ variable "aws_vpc_cidr_block" {
variable "aws_cidr_subnets_private" { variable "aws_cidr_subnets_private" {
description = "CIDR Blocks for private subnets in Availability Zones" description = "CIDR Blocks for private subnets in Availability Zones"
type = "list" type = list(string)
} }
variable "aws_cidr_subnets_public" { variable "aws_cidr_subnets_public" {
description = "CIDR Blocks for public subnets in Availability Zones" description = "CIDR Blocks for public subnets in Availability Zones"
type = "list" type = list(string)
} }
//AWS EC2 Settings //AWS EC2 Settings
@ -101,7 +101,7 @@ variable "k8s_secure_api_port" {
variable "default_tags" { variable "default_tags" {
description = "Default tags for all resources" description = "Default tags for all resources"
type = "map" type = map(string)
} }
variable "inventory_file" { variable "inventory_file" {

View file

@ -1,7 +1,3 @@
provider "openstack" {
version = "~> 1.17"
}
module "network" { module "network" {
source = "./modules/network" source = "./modules/network"

View file

@ -0,0 +1,8 @@
terraform {
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
}
}
required_version = ">= 0.12.26"
}

View file

@ -0,0 +1,11 @@
terraform {
required_providers {
null = {
source = "hashicorp/null"
}
openstack = {
source = "terraform-provider-openstack/openstack"
}
}
required_version = ">= 0.12.26"
}

View file

@ -0,0 +1,8 @@
terraform {
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
}
}
required_version = ">= 0.12.26"
}

View file

@ -152,7 +152,7 @@ variable "subnet_cidr" {
variable "dns_nameservers" { variable "dns_nameservers" {
description = "An array of DNS name server names used by hosts in this subnet." description = "An array of DNS name server names used by hosts in this subnet."
type = list type = list(string)
default = [] default = []
} }
@ -211,13 +211,13 @@ variable "k8s_allowed_egress_ips" {
} }
variable "master_allowed_ports" { variable "master_allowed_ports" {
type = list type = list(any)
default = [] default = []
} }
variable "worker_allowed_ports" { variable "worker_allowed_ports" {
type = list type = list(any)
default = [ default = [
{ {

View file

@ -0,0 +1,9 @@
terraform {
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.17"
}
}
required_version = ">= 0.12.26"
}

View file

@ -1,4 +1,9 @@
terraform { terraform {
required_version = ">= 0.12" required_version = ">= 0.12"
required_providers {
packet = {
source = "terraform-providers/packet"
}
}
} }