#terraform-0_12 (2019-12)

terraform

Discuss upgrading to terraform 0.12

Archive: https://archive.sweetops.com/terraform-0_12/

2019-12-10

curious deviant avatar
curious deviant

Hello, I am trying to install nginx-ingress helm chart to a fresh EKS cluster using TF, but the apply times out everytime with the error Error: timeout while waiting for state to become 'Running' (last state: 'Pending', timeout: 5m0s). I have tried increasing the timeout to 3000 but seems to have no effect.

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

You don’t have nodes in the cluster

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

kubectl get nodes

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

Try that ^

curious deviant avatar
curious deviant

thanks @Andriy Knysh (Cloud Posse) .. tiller wasn’t deployed to the cluster..should have checked that..my bad

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

In case of issues, you can also try:

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

kubectl cluster-info dump

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

Kubectl describe pod xxxxxx

curious deviant avatar
curious deviant

sure..thank you

2019-12-12

Gabe avatar

Does anyone know if it’s possible to use for_each or dynamic values for a provider block? If not, do you have a way to make the same resource across many accounts?

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

dynamic blocks are supported inside resource, data, provider, and provisioner blocks

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)
Expressions - Configuration Language - Terraform by HashiCorp

The Terraform language allows the use of expressions to access data exported by resources and to transform and combine that data to produce other values.

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

we use assume_role to re-use code for diff accounts https://www.terraform.io/docs/providers/aws/index.html#assume-role

Provider: AWS - Terraform by HashiCorp

The Amazon Web Services (AWS) provider is used to interact with the many resources supported by AWS. The provider needs to be configured with the proper credentials before it can be used.

Gabe avatar

yeah that’s what we have for our providers… in this case we want to make an AWS Config rule across all of our accounts so we need to make the same resource with each provider

Gabe avatar

it seems like we need to either have X number of modules with a different provider or one module with X number of resources that reference a list of providers

Gabe avatar

was wondering if there is a way to clean this up using a loop in TF 12

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

you can have one module that accepts a list of account IDs (or a map, if you want to use for_each)

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

in it, you use provider block with count or for_each (for which you need to provide a map)

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

in each resource in the module, you use count (or for_each) and specify the provider by index

Gabe avatar

ah okay… let me give that a try

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

The user that executes the code must have permissions to assume all those roles that are generated in the provider assume_role block

Gabe avatar

Seems like they haven’t implemented this functionality yet. Using this config:

provider "aws" {
  for_each = var.aws_account_ids

  dynamic "assume_role" {
    for_each = var.aws_account_ids
    content {
      role_arn     = "arn:aws:iam::${each.value}:role/super-user"
      session_name = "terraform"
    }
  }
  profile = "sts"
  region  = "us-west-2"
  version = "2.41.0"
}

Returns :

Error: Reserved argument name in provider block

  on ../../../modules/site/all-accounts-aws-config-rule/v3/main.tf line 14, in provider "aws":
  14:   for_each = var.aws_account_ids

The provider argument name "for_each" is reserved for use by Terraform in a
future version.

I also tried the for_each or the provider block as well with the same result

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

what about count in provider block?

Gabe avatar

Same

Error: Reserved argument name in provider block

  on ../../../modules/site/all-accounts-aws-config-rule/v3/main.tf line 14, in provider "aws":
  14:   count = length(var.aws_account_ids)

The provider argument name "count" is reserved for use by Terraform in a
future version.
Gabe avatar

So realized there was a mistake in my attempt with for_each, I needed to delete the resource level for_each statement. However, this still doesn’t seem possible because you can’t dynamically specify the provider in a resource or the alias in a provider

2019-12-16

Gabe avatar

also using terraform 0.12.18 which is the newest

    keyboard_arrow_up