https://kotlinlang.org logo
#kotless
Title
# kotless
c

Christian Schwoerer

03/12/2021, 10:41 AM
Hi there, we’re having problems with the generated terraform file. And have no clue what we have to change, perhaps someone here has a hint. The Gradle error when running e.g.
plan
is:
Copy code
Error: Invalid resource name

  on <http://breakeven.tf|breakeven.tf> line 77, in resource "aws_iam_role" "0":
  77: resource "aws_iam_role" "0" {

A name must start with a letter or underscore and may contain only letters,
digits, underscores, and dashes.
The corresponding part of the terraform script looks like this:
Copy code
resource "aws_iam_role" "0" {
  name = "0"
  assume_role_policy = data.aws_iam_policy_document.0_assume.json
}
The part of the
build.gradle.kts
like this:
Copy code
kotless {
    config {
        bucket = "our-bucket-name"

        terraform {
            profile = "my-aws-user"
            region = "eu-central-1"
        }
    }
    webapp {
        lambda {
            kotless {
                packages = setOf("info.novatec")
            }
        }
    }
}
We’ve tried different Kotless versions (0.1.6, 0.1.7-beta-4, 0.1.7-beta-5). Anyone an idea what we’re doing wrong?
t

TanVD

03/12/2021, 10:46 AM
Could you try adding
prefix
?)
Would it help?
c

Christian Schwoerer

03/12/2021, 10:53 AM
You mean like this:
Copy code
kotless {
    config {
        bucket = "our-bucket-name"
        prefix = "dev"

        terraform {
            profile = "my-aws-user"
            region = "eu-central-1"
        }
    }
    webapp {
        lambda {
            kotless {
                packages = setOf("info.novatec")
            }
        }
    }
}
Unfortunately the error still exist. 😞
The resource name seems to have the prefix but the resource itself not:
Copy code
resource "aws_iam_role" "0" {
  name = "dev-0"
  assume_role_policy = data.aws_iam_policy_document.0_assume.json
}
t

TanVD

03/12/2021, 11:17 AM
Hm, really interesting, I will have to check
c

Christian Schwoerer

03/12/2021, 11:18 AM
We’ve seen this in the
GenerationContext
class
Aren’t parts of line 64 just missing in line 58? We will try to have a closer look at it…
t

TanVD

03/12/2021, 11:26 AM
Yep, but I am not sure from where
0
did occur
18 Views