-
Notifications
You must be signed in to change notification settings - Fork 139
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
add support for cloudflare_web_analytics_site #632
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ var resourceImportStringFormats = map[string]string{ | |
"cloudflare_turnstile_widget": ":account_id/:id", | ||
"cloudflare_waf_override": ":zone_id/:id", | ||
"cloudflare_waiting_room": ":zone_id/:id", | ||
"cloudflare_web_analytics_site": ":account_id/:id", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll have to manually test this; i'm unsure what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...or are import docs wrong and you should use |
||
"cloudflare_worker_route": ":zone_id/:id", | ||
"cloudflare_workers_kv_namespace": ":id", | ||
"cloudflare_zone_lockdown": ":zone_id/:id", | ||
|
@@ -437,6 +438,16 @@ func runImport() func(cmd *cobra.Command, args []string) { | |
if err != nil { | ||
log.Fatal(err) | ||
} | ||
case "cloudflare_web_analytics_site": | ||
jsonPayload, _, err := api.ListWebAnalyticsSites(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListWebAnalyticsSitesParams{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
m, _ := json.Marshal(jsonPayload) | ||
err = json.Unmarshal(m, &jsonStructData) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
case "cloudflare_workers_kv_namespace": | ||
jsonPayload, _, err := api.ListWorkersKVNamespaces(context.Background(), identifier, cloudflare.ListWorkersKVNamespacesParams{}) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/rum/site_info/list?page=1&per_page=10 | ||
method: GET | ||
response: | ||
body: | | ||
{ | ||
"success": true, | ||
"errors": [], | ||
"messages": [], | ||
"result_info": { | ||
"page": 1, | ||
"per_page": 10, | ||
"count": 1, | ||
"total_count": 1, | ||
"total_pages": 1 | ||
}, | ||
"result": [ | ||
{ | ||
"site_tag": "1a091d3b85d76e2384d0e153747c7a84", | ||
"site_token": "b40e25e5fc304ed31ee72bf5370dbcc7", | ||
"created": "2023-08-28T20:08:56.719351Z", | ||
"snippet": "\u003c!-- Cloudflare Web Analytics --\u003e\u003cscript defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{\"token\": \"b40e25e5fc304ed31ee72bf5370dbcc7\"}'\u003e\u003c/script\u003e\u003c!-- End Cloudflare Web Analytics --\u003e", | ||
"auto_install": true, | ||
"ruleset": { | ||
"zone_tag": "0da42c8d2132a9ddaf714f9e7c920711", | ||
"zone_name": "example.com", | ||
"enabled": true, | ||
"id": "81568f25-8f05-4368-98c3-bbd40846d217" | ||
} | ||
} | ||
] | ||
} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
Vary: | ||
- Accept-Encoding | ||
status: 200 OK | ||
code: 200 | ||
duration: "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
terraform { | ||
required_providers { | ||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "cloudflare_web_analytics_site" "terraform_managed_resource" { | ||
account_id = "f037e56e89293a057740de681ac9abbe" | ||
auto_install = true | ||
zone_tag = "0da42c8d2132a9ddaf714f9e7c920711" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this to include the remapping as
site_tag
doesn't exist at the top level in the API response but it does in the resource.