Skip to content

Action fails if attribute is configured to be WriteOnly #37978

@fox-md

Description

@fox-md

Terraform Version

Terraform v1.15.0-alpha20251203

Terraform Configuration Files

ephemeral "foxcon_schema_credentials" "test" {}

action "foxcon_set_subject_mode" "ro" {
  config {
    subject_name = var.subject_name
    mode = "READONLY"
    rest_endpoint = ephemeral.foxcon_schema_credentials.test.rest_endpoint
  }
}

Debug Output

╷
│ Error: WriteOnly Attribute Not Allowed
│
│   with action.foxcon_set_subject_mode.ro,
│   on main.tf line 114, in action "foxcon_set_subject_mode" "ro":
│  114:     rest_endpoint = ephemeral.foxcon_schema_credentials.test.rest_endpoint
│
│ The resource contains a non-null value for WriteOnly attribute rest_endpoint. Write-only attributes are only supported in Terraform 1.11 and later.
╵

Expected Behavior

I was expecting to be able to use ephemeral resources attribute in action since action`s attribute is Write-Only. Terraform versions is the latest available.

Actual Behavior

I am getting a weird error saying I should be using terraform 1.11 or later.

Steps to Reproduce

  1. Create an action with Write-Only attributes
  2. Configure the write-only attribute with output from ephemeral resource
  3. Run terraform plan

Additional Context

ATM it is not possible to set sensitive parameter for an action attribute. I am trying to use ephemeral resource output with actions having write-only attribute.

action schema:

func (a *subjectModeAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
	resp.Schema = schema.Schema{
		Attributes: map[string]schema.Attribute{
			"rest_endpoint": schema.StringAttribute{
				Optional:    true,
				WriteOnly:   true,
				Description: "Schema registry rest endpoint",
			},
			"subject_name": schema.StringAttribute{
				Required:    true,
				Description: "Name of the subject",
			},
			"mode": schema.StringAttribute{
				Required:    true,
				Description: "Subject mode",
			},
		},
		Blocks: map[string]schema.Block{
			"credentials": schema.SingleNestedBlock{
				Attributes: map[string]schema.Attribute{
					"key": schema.StringAttribute{
						Optional:  true,
						WriteOnly: true,
					},
					"secret": schema.StringAttribute{
						Optional:  true,
						WriteOnly: true,
					},
				},
			},
		},
	}
}

As soon as I set a value to the rest_endpoint terraform starts to fail with the below error:

The resource contains a non-null value for WriteOnly attribute rest_endpoint. Write-only attributes are only supported in Terraform 1.11 and later.

References

No response

Generative AI / LLM assisted development?

N/A

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