https://pulumi.com logo
#dotnet
Title
# dotnet
f

flat-bear-83490

06/24/2020, 4:02 PM
Hi, I'm following the example code in the docs for
tranformations
at https://www.pulumi.com/docs/intro/concepts/programming-model/#transformations and I'm finding that ResourceOptions.Merge doesn't seem to be available - I wondered if anyone had any pointers on this? Thanks!
Copy code
var vpc = new MyVpcComponent("vpc", new ComponentResourceOptions
{
    Transformations =
    {
        args =>
        {
            if (args.Resource.GetResourceType() == "aws:ec2/vpc:Vpc" ||
                args.Resource.GetResourceType() === "aws:ec2/subnet:Subnet")
            {
                return new ResourceTransformationResult
                {
                    Args: args.Args,
                    Options: ResourceOptions.Merge( // Not available
                        args.Options,
                        new CustomResourceOptions { IgnoreChanges =  { "tags" } }),
                };
            }

            return null;
        }
    },
});
f

faint-table-42725

06/24/2020, 6:49 PM
It should exist on the concrete type, e.g.
CustomResourceOptions
or
ComponentResourceOptions
depending on which type of resource it is
f

flat-bear-83490

06/24/2020, 6:57 PM
Thanks @faint-table-42725
Copy code
ResourceTransformationArgs.Options
is a ResourceOptions whereas
Copy code
CustomResourceOptions.Merge
takes CustomResourceOptions Would you suggest creating a CustomResourceOptions based on the ResourceOptions from ResourceTransformationArgs.Options?
I haven't spotted part of the public API to convert ResourceOptions into CustomResourceOptions
t

tall-librarian-49374

06/24/2020, 7:43 PM
Copy code
if (options is CustomResourceOptions customOptions)
{
  customOptions.Merge(…);
}
something like this?