Error to create a website using terraform

Hello everyone,

I’m trying to create a new website using terraform but an error is occurring:

Attribute api_key API key must be 37 characters long and only contain characters 0-9 and a-f (all lowercased), got: My Token

The token has an _ character.

Can you help me?

Thanks.

The API Key and API Token are different things.

You should use api_token.

See also here:
https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs

3 Likes

Thanks @Laudian

Now, I’m having two others errors:

The first is:

Error: Missing required argument
│
│   with provider["registry.terraform.io/cloudflare/cloudflare"],
│   on provider.tf line 12, in provider "cloudflare":
│   12:   email   = "[email protected]"
│
│ "email": all of `api_key,email` must be specified

The other is when I try to apply:

Error: error creating zone "mydomain.co": Requires permission "com.cloudflare.api.account.zone.create" to create zones for the selected account

The permissions are:

Edit all DNS zones in all zones in my account.

Can you help me again?

Did you have a look at the documentation that I linked?

For your second question, this might help you:

1 Like

Yes, I saw.

I removed the e-mail field. I won’t use this moment.

My API token has the following permissions:

I already deleted and recreated the API but the same error is still occurring:

You need to add the right permission to the token, as shown in the post I linked in my previous reply.

2 Likes

Hi @Laudian

Now it worked. Thank you so much.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.