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

WIP: Add cloudflare_access_group data source #3072

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paulbehrisch
Copy link

@paulbehrisch paulbehrisch commented Jan 19, 2024

I am using the Terraform provider and have to retrieve the cloudflare_access_group by name.

I did a quick test and this worked, but it's only exposing the ID and the Name.

I got a deprecation warning for MAXIMUM_ALLOWED_SDKV2_DATASOURCES = 20 and I haven't added any tests yet.
I haven't written Go or a Terraform provider before and only tried to get this working.

With valid access groups:

data.cloudflare_access_group.group1: Reading...
data.cloudflare_access_group.group2: Reading...
data.cloudflare_access_group.group1: Read complete after 0s [id=18238aca-9195-4f1d-b083-83f2b6e866b9]
data.cloudflare_access_group.group2: Read complete after 0s [id=eb21cc8e-da27-4453-bb23-f678f32db63f]

Changes to Outputs:
  + group1_id = {
      + account_id = "123425d31ae24a27770d5fe81341fdd9"
      + id         = "18238aca-9195-4f1d-b083-83f2b6e866b9"
      + name       = "abc"
      + zone_id    = null
    }
  + group2_id = {
      + account_id = "123425d31ae24a27770d5fe81341fdd9"
      + id         = "eb21cc8e-da27-4453-bb23-f678f32db63f"
      + name       = "def"
      + zone_id    = null
    }

With invalid access group:

data.cloudflare_access_group.group2: Reading...
data.cloudflare_access_group.group1: Reading...
data.cloudflare_access_group.group1: Read complete after 0s [id=18238aca-9195-4f1d-b083-83f2b6e866b9]

Changes to Outputs:
  + group1_id = {
      + account_id = "123425d31ae24a27770d5fe81341fdd9"
      + id         = "18238aca-9195-4f1d-b083-83f2b6e866b9"
      + name       = "abc"
      + zone_id    = null
    }

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
╷
│ Error: no Access Groups matching name "def1"
│
│   with data.cloudflare_access_group.group2,
│   on data.tf line 7, in data "cloudflare_access_group" "group2":
│    7: data "cloudflare_access_group" "group2" {
│

There are also other data sources missing as for device_settings_policy_id. Is this currently on the roadmap of being added?

Copy link
Contributor

Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/contributing/changelog-process.md.

Example:

```release-note:TYPE
Release note
```

If you do not require a release note to be included and you have permission, please add the workflow/skip-changelog-entry label. Otherwise, a maintainer will add the label or ask you for one when they review the PR.

Copy link
Member

@jacobbednarz jacobbednarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the effort you've take thus far however, as the error points out, we are no longer accepting resources or data source that rely on the SDKv2 internals. if you want to land this, you'll need to submit it using the framework plugin. you can see an example of this in the api_token_permission_groups data source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants