Add terraform log message after resource creation

206 views Asked by At

I have built custom terraform provider, now for the finishing touch I would like to add some message in "STRING" format after resource has done creating.

The problem i am facing is I am using terraform framework and the only way I can add text after resource creation I found was this


 (r *vmResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse){


diags.AddWarning(
            "",
            "Some String message",
        )

}

The problem is that this will result in truncated message for one resource alone,

Resource number one successfully created.

│ (and one more similar warning elsewhere)

Apply complete! Resources: 2 added, 0 changed, 2 destroyed.

I have tried using fmt.Printf() and all other methods fmt offers, even tried using log.Print() but none seem to work. ** I need to handle this in: func (r *vmResource) Create(ctx context.Context, req resource.CreateRequest, resp resource.CreateResponse) ** not in Main.tf

Is there anyone who can help me with this?

I have tried to output resource information after it is being created, however I get a truncated message for only one resource and that message is in form of Warning.

I am expecting to output non Warning message that is not truncated with all I need.

0

There are 0 answers