Skip to content

[Feature request][test]: Allow overriding Block in override_data #37862

@IppX

Description

@IppX

Terraform Version

Terraform v1.13.4
on darwin_arm64

Use Cases

When trying to use override_data in a unit test, if an argument in the underlying data source is implemented with a Block, override_data does not override the argument.

This is silent and leads to a frustrating experience as a developer.

I'm posting this request following a discussion in Discuss (see references section).

Attempted Solutions

Blocks are not considered computed and thus are not overriden in tests.

A workaround is to define an empty block in the source data and then one can override the data block in tests.

Example:

# in root module
data "data_with_block" this {
    my_block {}
}

# and in test
run {
    override_data {
        target = data_with_block.this
        values = {
            my_block = {
                  key = "value"
            }
        }
    }
}

See References for a concrete example from Discuss forums.

Proposal

No response

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions