Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare DNS Record GET Issues #26

Closed
ben-nagengast opened this issue Jul 22, 2019 · 7 comments
Closed

Cloudflare DNS Record GET Issues #26

ben-nagengast opened this issue Jul 22, 2019 · 7 comments
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec
Milestone

Comments

@ben-nagengast
Copy link

ben-nagengast commented Jul 22, 2019

I think there's an issue with the Cloudflare DNS Record GET function.

Tested on v0.17.1 and v0.17.8

https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/cloudflare/#Record-get

According to https://api.cloudflare.com/#dns-records-for-a-zone-dns-record-details
We need to be generating this URI
/zones/<zone-id>/dns_records/<record-id>

Currently,

const record = cloudflare.Record.get('test.example.com', 'example.com/<recordId>');

Will generate the following error

    error: Preview failed: refreshing 
urn:pulumi:sandbox::Cloudflare::cloudflare:index/record:Record::test.example.com: error from 
makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":7003,
\"message\":\"Could not route to \\/zones\\/<zoneId>\\/dns_records\\/example.com
\\/<recordId> perhaps your object identifier is invalid?\"},{\"code\":7000,\"message\":\"No route 
for that URI\"}],\"messages\":[],\"result\":null}"

It looks like the issue here is that the <zoneId>/<recordId> is being directly passed to the URI as the <record-id> instead of splitting it and resolving the ZoneID and removing it.

@ben-nagengast
Copy link
Author

I'm assuming this is an issue with the Terraform provider and not Pulumi.

Here's resourceCloudflareRecordRead
https://github.com/terraform-providers/terraform-provider-cloudflare/blob/70cc823581cd33376e0647ced55d5dc93dc4c573/cloudflare/resource_cloudflare_record.go#L370

Here's resourceCloudflareRecordImport
https://github.com/terraform-providers/terraform-provider-cloudflare/blob/70cc823581cd33376e0647ced55d5dc93dc4c573/cloudflare/resource_cloudflare_record.go#L508

I'm assuming the issue is to do with the read function - import seems to handle it correctly just glancing at the code. Unfortunately I don't know how this is all wired together well enough to debug resourceCloudflareRecordRead :(

If this issue should instead be made on the TF repo, let me know!

@damianh
Copy link

damianh commented Aug 15, 2019

Just experienced this, while attempting to import a record into a stack. At first I set the import valud to the id of the resource. Using similar to:

new cloudflare.Record("a-record, {
    name: name,
    domain: zone,
    type: "A",
    value: value,
    proxied: proxied,
}, 
{ 
    provider: provider,
    import: "1c2d230b0d7f45ff10961035ad3af3cb",
});

Results in:

cloudflare:index:Record (a-record):
error: Preview failed: importing 1c2d230b0d7f45ff10961035ad3af3cb: invalid id "1c2d230b0d7f45ff10961035ad3af3cb" specified, should be in format "zoneName/recordId" for import

But then specifying the zone name:

new cloudflare.Record("a-record, {
    name: name,
    domain: zone,
    type: "A",
    value: value,
    proxied: proxied,
}, 
{ 
    provider: provider,
    import: "myhost.com/1c2d230b0d7f45ff10961035ad3af3cb",
});

results in...

  cloudflare:index:Record (a-record-wallet):
    error: Preview failed: refreshing urn:pulumi:prod::cloudflare::cloudflare:index/record:Record::a-record: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":7003,\"message\":\"Could not route to \\/zones\\/4eadeb5b264ad5ecefb4a927b44d8935\\/dns_records\\/myhost.com\\/1c2d230b0d7f45ff10961035ad3af3cb, perhaps your object identifier is invalid?\"},{\"code\":7000,\"message\":\"No 
route for that URI\"}],\"messages\":[],\"result\":null}"

It appears to be routing to /zones/4eadeb5b264ad5ecefb4a927b44d8935/dns_records/myhost.com/1c2d230b0d7f45ff10961035ad3af3cb
But is should be routing to /zones/4eadeb5b264ad5ecefb4a927b44d8935/dns_records/1c2d230b0d7f45ff10961035ad3af3cb as per URI templated mentioned by @ben-nagengast

@ben-nagengast
Copy link
Author

@stack72 Just checking in on this, any updates?

@stack72
Copy link
Contributor

stack72 commented Oct 10, 2019

Hi @ben-nagengast

I have updated the provider. The import should be of the format zone_id/record. In your example above, you are using the zone_name which is no longer supported since 1.0 of the provider

Can you try an upgrade and see if that works for you?

P.

@stack72 stack72 added this to the 0.28 milestone Oct 10, 2019
@stack72 stack72 added the bug label Oct 10, 2019
@stack72
Copy link
Contributor

stack72 commented Oct 15, 2019

Hi @damianh

Please can you tell me if this is still a problem for you since the 1.0.0 release of the provider?

P.

@stack72
Copy link
Contributor

stack72 commented Oct 17, 2019

Going to close this out for now - I've not heard if this can be re-created with 1.0.0 of the provider. Please let me know if this is still the case

@stack72 stack72 closed this as completed Oct 17, 2019
@damianh
Copy link

damianh commented Oct 21, 2019

Works here, cheers.

@infin8x infin8x added the kind/bug Some behavior is incorrect or out of spec label Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

4 participants