I am running into some trouble with a `awsx.ecs.Fa...
# aws
l
I am running into some trouble with a
awsx.ecs.FargateService
service:
Copy code
CreateService, https response error StatusCode: 400, InvalidParameterException: Creation of service was not idempotent.
The previous run of pulumi created the service but the deploy failed and triggered the deployment circuit breaker, now the second pass attempts a re-creation of the service. Additionally I can't seem to set
deleteBeforeReplace
on awsx components to make it through as a work around. Anyone else hit issues like that?
l
AWSX provides component resources; if they're not properly implemented, they might be dropping the opts instead of passing it on to the child resources.
If that's the case, you can use a resource transformation to forcibly add it back in.
Or you can manually delete the resource and run a
pulumi refresh
.
l
Got an example of that? I tried something initially but was unable to find deleteBefore inside the transform so I might but using that incorrectly (typescript if you know a reference would be great)
l
It'll be in the docs, onesec I'll see if I can find it.
Ooo, there's a new way to do it: Transforms. The example is using the ignoreChanges opt, but it's the same thing: https://www.pulumi.com/docs/iac/concepts/options/transforms/
l
Oh lovely!
Copy code
transforms: [
        (args: pulumi.ResourceTransformArgs): pulumi.ResourceTransformResult => {
          let opts = args.opts;
          if (args.type === 'aws:ecs/service:Service') {
            opts = pulumi.mergeOptions(args.opts, { deleteBeforeReplace: true });
          }
          return {
            props: args.props,
            opts: opts,
          };
        },
      ],
Hmm that broke other parts of the awsx module but I can work from this, thanks!
Fixed:
Copy code
transforms: [
        (args) => {
          if (args.type === 'aws:ecs/service:Service') {
            return {
              props: args.props,
              opts: pulumi.mergeOptions(args.opts, { deleteBeforeReplace: true }),
            };
          }
          return undefined;
        },
      ],