Skip to content

Commit

Permalink
Merge pull request #705 from hhkumar/add-cloudflare-access-applicatio…
Browse files Browse the repository at this point in the history
…n-import-support

Adding cloudflare_access_application import support
  • Loading branch information
jacobbednarz committed May 16, 2024
2 parents 328c0e4 + 4467517 commit aaca82b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/app/cf-terraforming/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
// resourceImportStringFormats contains a mapping of the resource type to the
// composite ID that is compatible with performing an import.
var resourceImportStringFormats = map[string]string{
"cloudflare_access_application": ":account_id/:id",
"cloudflare_access_group": ":account_id/:id",
"cloudflare_access_rule": ":identifier_type/:identifier_value/:id",
"cloudflare_account_member": ":account_id/:id",
Expand Down Expand Up @@ -79,6 +80,17 @@ func runImport() func(cmd *cobra.Command, args []string) {
resources := strings.Split(resourceType, ",")
for _, resourceType := range resources {
switch resourceType {
case "cloudflare_access_application":
jsonPayload, _, err := api.ListAccessApplications(context.Background(), identifier, cloudflare.ListAccessApplicationsParams{})
if err != nil {
log.Fatal(err)
}

m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
case "cloudflare_access_group":
jsonPayload, _, err := api.ListAccessGroups(context.Background(), identifier, cloudflare.ListAccessGroupsParams{})
if err != nil {
Expand Down

0 comments on commit aaca82b

Please sign in to comment.