Browse Source

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
pull/7082/head
Cristian Klein 4 years ago
committed by GitHub
parent
commit
fd3ebc13f7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 97 additions and 18 deletions
  1. 42
      .gitlab-ci/terraform.yml
  2. 2
      contrib/terraform/aws/create-infrastructure.tf
  3. 6
      contrib/terraform/aws/modules/elb/variables.tf
  4. 8
      contrib/terraform/aws/modules/vpc/variables.tf
  5. 6
      contrib/terraform/aws/variables.tf
  6. 4
      contrib/terraform/openstack/kubespray.tf
  7. 8
      contrib/terraform/openstack/modules/compute/versions.tf
  8. 11
      contrib/terraform/openstack/modules/ips/versions.tf
  9. 8
      contrib/terraform/openstack/modules/network/versions.tf
  10. 6
      contrib/terraform/openstack/variables.tf
  11. 9
      contrib/terraform/openstack/versions.tf
  12. 5
      contrib/terraform/packet/versions.tf

42
.gitlab-ci/terraform.yml

@ -74,6 +74,48 @@ tf-validate-aws:
PROVIDER: aws
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:
# extends: .terraform_apply
# variables:

2
contrib/terraform/aws/create-infrastructure.tf

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

6
contrib/terraform/aws/modules/elb/variables.tf

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

8
contrib/terraform/aws/modules/vpc/variables.tf

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

6
contrib/terraform/aws/variables.tf

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

4
contrib/terraform/openstack/kubespray.tf

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

8
contrib/terraform/openstack/modules/compute/versions.tf

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

11
contrib/terraform/openstack/modules/ips/versions.tf

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

8
contrib/terraform/openstack/modules/network/versions.tf

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

6
contrib/terraform/openstack/variables.tf

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

9
contrib/terraform/openstack/versions.tf

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

5
contrib/terraform/packet/versions.tf

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