pulumi-cloudflare
pulumi-cloudflare copied to clipboard
Creating an R2 resource with a Location hint will error on subsequent runs
What happened?
When creating an R2 resource with a Location hint, the resource it created fine the first time. But in subsequent runs, Pulumi will try to replace the R2 resource. This ends with the error message: failed to create R2 bucket: The bucket you tried to create already exists, and you own it. (10004)
If you don't have a Location hint, the resource will not be replaced in subsequent runs.
Expected Behavior
The R2 resource should not be replaced.
Steps to reproduce
- Create a C# Pulumi project with the following code
using System.Collections.Generic;
using Pulumi;
using Pulumi.Cloudflare;
return await Deployment.RunAsync(() =>
{
var apiToken = "uqtiSyipZtn6Tr2I-RbZUl3_NeZfZ_GzG_Bh3Kqd";
var accountId = "43384b2dacb3c8d5a846f9eb53ef3aef";
var provider = new Provider("my-cloudflare-provider", new ProviderArgs
{
ApiToken = apiToken
});
var name = "my-bucket";
var bucket = new R2Bucket(name, new()
{
Name = name,
AccountId = accountId,
Location = "enam",
}, new CustomResourceOptions
{
Provider = provider
});
return new Dictionary<string, object?>();
});
- Update the
apiToken
andaccountId
variables - Add a reference to the
Pulumi.Cloudflare
NuGet, version 5.8.0 - Run
pulumi up
. Everything will be created correctly - Run
pulumi up
again. The preview will say the R2 resource will be replaced. If you choose to run it anyway after the preview, the above mentioned error message will appear.
Output of pulumi about
CLI
Version 3.77.1
Go Version go1.20.6
Go Compiler gc
Plugins
NAME VERSION
cloudflare 5.8.0
dotnet unknown
Host
OS Microsoft Windows 11 Home
Version 10.0.22621 Build 22621
Arch x86_64
This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='7.0.400'
Current Stack: ProgrammerAl/pulumi-cloudflare-r2-bug/dev
TYPE URN
pulumi:pulumi:Stack urn:pulumi:dev::pulumi-cloudflare-r2-bug::pulumi:pulumi:Stack::pulumi-cloudflare-r2-bug-dev
pulumi:providers:cloudflare urn:pulumi:dev::pulumi-cloudflare-r2-bug::pulumi:providers:cloudflare::my-cloudflare-provider
cloudflare:index/r2Bucket:R2Bucket urn:pulumi:dev::pulumi-cloudflare-r2-bug::cloudflare:index/r2Bucket:R2Bucket::my-bucket
Found no pending operations associated with dev
Backend
Name pulumi.com
URL https://app.pulumi.com/ProgrammerAl
User ProgrammerAl
Organizations ProgrammerAl
Dependencies:
NAME VERSION
Pulumi 3.56.0
Pulumi.Cloudflare 5.8.0
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
Hi @ProgrammerAL , thanks for opening this issue. Can you confirm that the resource is recorded in state correctly – just want to confirm that it somehow wasn't corrupted.
Also, as a workaround for now, you may be able to use the ignoreChanges
property (https://www.pulumi.com/docs/concepts/options/ignorechanges/).
Hi @aq17 , I think the resource state is correct (screenshot below). I noticed it doesn't have a property for the Location hint field, so I'm guessing that's why this is happening. I assume it's not there because the Location hint is still in preview for R2.
I am able to work around this, so it's not a blocker. But that's for the suggestion.
This sounds like this upstream issue: https://github.com/cloudflare/terraform-provider-cloudflare/issues/2608
Unfortunately, it has been closed with no action. But I'm curious @ProgrammerAL - does it help if you capitalize the location when initially creating the resource? Also, could you show the exact diff that you are seeing on update?