Terraform-provider-cloudflare: ID is being passed blank and failed to create the resource cloudflare_access_identity_provider with "error creating Access Identity Provider for ID" error

Created on 15 Jul 2021  Â·  3Comments  Â·  Source: cloudflare/terraform-provider-cloudflare

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

terraform

1.0.0

cloudflare

= 2.23.0

Affected resource(s)

Resource cloudflare_access_identity_provider

Terraform configuration files

resource "cloudflare_access_identity_provider" "ldap" {
  account_id = <cloudfalre account id>
  name    = "LDAP"
  type    = "test"
  config {
    client_id     = <client_id>
    client_secret = <client_secret>
    auth_url      = "${url}/auth"
    token_url     = "${url}/token"
    certs_url     = "${url}/keys"
  }
  lifecycle {
    ignore_changes = all
  }
}

Debug output

2021-07-14T22:00:37.283Z [INFO] Starting apply for cloudflare_access_identity_provider.ldap
2021-07-14T22:00:37.284Z [DEBUG] cloudflare_access_identity_provider.ldap: applying the planned Create change
2021-07-14T22:00:37.284Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: 2021/07/14 22:00:37 [DEBUG] Creating Cloudflare Access Identity Provider from struct: {_ID:_ Name:LDAP Type:test Config:{AppsDomain: Attributes:[] AuthURL: CentrifyAccount: CentrifyAppID: CertsURL:/keys ClientID: ClientSecret: DirectoryID: EmailAttributeName: IdpPublicCert: IssuerURL: OktaAccount: OneloginAccount: RedirectURL: SignRequest:false SsoTargetURL: SupportGroups:false TokenURL:/token}}
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: 2021/07/14 22:00:37 [DEBUG] Cloudflare API Request Details:
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: ---[ REQUEST ]---------------------------------------
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: POST /client/v4/accounts/[MASKED]/access/identity_providers HTTP/1.1
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Host: api.cloudflare.com
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: User-Agent: HashiCorp Terraform/1.0.0 (+https://www.terraform.io) Terraform Plugin SDK/1.17.2 terraform-provider-cloudflare/2.23.0
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Content-Length: 241
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Authorization: Bearer [MASKED]
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Content-Type: application/json
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Accept-Encoding: gzip
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0:
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: {
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "name": "LDAP",
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "type": "test",
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "config": {
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "auth_url": "/auth",
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "certs_url": "/keys",
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "client_id": ,
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "client_secret": "",
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "token_url": "/token"
2021-07-14T22:00:37.285Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: }
2021-07-14T22:00:37.286Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: }
2021-07-14T22:00:37.286Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: -----------------------------------------------------
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: 2021/07/14 22:00:37 [DEBUG] Cloudflare API Response Details:
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: ---[ RESPONSE ]--------------------------------------
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: HTTP/2.0 403 Forbidden
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Cf-Cache-Status: DYNAMIC
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Cf-Ray: 66ee06618de45ea7-IAD
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Content-Type: application/json
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Date: Wed, 14 Jul 2021 22:00:37 GMT
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Server: cloudflare
2021-07-14T22:00:37.834Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Set-Cookie: __cflb=0H28vgHxwvgAQtjUGU56Rb8iNWZVUvXhh38EZrqsu17; SameSite=Lax; path=/; expires=Thu, 15-Jul-21 00:30:38 GMT; HttpOnly
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Set-Cookie: __cfruid=654983f55d16f39db9a40587e66864a6dc17949b-1626300037; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: Vary: Accept-Encoding
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0:
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: {
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "success": false,
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "errors": [
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: {
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "code": 10000,
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: "message": "Authentication error"
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: }
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: ]
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: }
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0:
2021-07-14T22:00:37.835Z [DEBUG] provider.terraform-provider-cloudflare_v2.23.0: -----------------------------------------------------
â•·
│ Error: error creating Access Identity Provider for ID "": HTTP status 403: Authentication error (10000)
│
│ with cloudflare_access_identity_provider.ldap,
│ on access_identity_provider.tf line 23, in resource "cloudflare_access_identity_provider" "ldap":
│ 23: resource "cloudflare_access_identity_provider" "ldap" {
│
╵

Panic output

_No response_

Expected output

The resource cloudflare_access_identity_provider should have been created successfully.

Actual output

There is 403 error saying the Authentication error and in the debug log it seems the ID is sent as blank

Steps to reproduce

  1. Create a resource cloudflare_access_identity_provider.
  2. Give the account_id , name, type in the resource.
  3. Give client_id , client_secret , auth_url , token_url , certs_url in th config {} block.
  4. Run terraform plan and apply.

Additional factoids

In the repo https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/cloudflare/resource_cloudflare_access_identity_provider.go#L193
There seems to be ID is not passed inside the object identityProvider .

Only Name and Type are passed into the object.

References

_No response_

kinbug needs-triage

Most helpful comment

Cloudflare Access doesn't support API tokens consistently at the moment so I'd recommend using the API key instead. The service team is aware and working on adding support. This issue is not a bug in the provider.

All 3 comments

Cloudflare Access doesn't support API tokens consistently at the moment so I'd recommend using the API key instead. The service team is aware and working on adding support. This issue is not a bug in the provider.

@jacobbednarz I mentioend the email and apikey in the provider block and tried creating the same resource again.
The 403 error persists.
provider "cloudflare" {
email =
api_key =
}

The 403 error is because of the permission on cloudflare account.Nothing to do with the API key or provider.
So this issue is closed from my end aswell.

Was this page helpful?
0 / 5 - 0 ratings