Output without resource

Hello,

Is it possible to generate outputs WITHOUT resources?? something like:

# Configure the AWS Provider
provider "aws" {
    alias = "use1"
    version = "~> 2.0"
}

variable "servers" {
    type = map
    default = {
        fs1 = "fs1"
        fs2 = "fs2"
    }
}

output "subnets" {
    value = "David"
}

Thanks!

Yes, you can create an output with a static value.

Thanks for replying!

Can you elaborate maybe with an example?

I’m trying to do something like:

variable "servers" {
    fs1 = {
        ip_address = "1.2.3.4"
        hc_port = "80"
    }
    fs2 = {
        ip_address = "4.3.2.1"
        hc_port = "8080"
    }
}

and then just outputting them to check they are ok:

output "servers" {
    value = {
        for_each = var.servers
        each.value.ip_address
    }
}

This doesn’t work:

provider "aws" {
    alias = "use1"
    version = "~> 2.0"
}

output "subnets" {
    value = "David"
}


#terraform plan                                                                                                                                       Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

OK, it finally worked but creating a dummy resource:

resource "random_pet" "this" {
    count = 1
}

I didn’t know one had to apply to actually get the output

Thanks!