IS-Labber
IS-Labber

Reputation: 1

Error using aws_ssm_parameter in terraform

What I am intending to do:

Add an AWS SSM parameter containing a range of IPs to be used in terraform

What I've done:

data "aws_ssm_parameter" "range_of_ips" {
  name = "range_of_ips"
  type = "StringList"
}

Then used this later in the terraform code like this (in my locals.tf file):

my_ip_ranges = [data.aws_ssm_parameter.range_of_ips]

I am getting the following error during validation:

type = "StringList" │ │ Can't configure a value for "type": its value will be decided automatically based on the result of applying this configuration.**

this is the latest error as I have tried variations of StringList, "StringList", and adding ARN to the data resource... different errors every time.

What is the correct way to do this? The documentation isn't clear. Is it not possible?

Upvotes: 0

Views: 368

Answers (1)

Marko E
Marko E

Reputation: 18203

You cannot set the type as the error says:

type = "StringList" │ │ Can't configure a value for "type": its value will be decided automatically based on the result of applying this configuration.

The documentation might be a bit confusing if you're just starting, but in this particular case it says the following:

In addition to all arguments above, the following attributes are exported: type - Type of the parameter. Valid types are String, StringList and SecureString.

This attribute gets exported, meaning you can use it later on in your code if needed. Based on the very limited example you have provided, I think the following should work:

data "aws_ssm_parameter" "range_of_ips" {
  name = "range_of_ips"
}

Upvotes: 1

Related Questions