Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding cloudflare_access_application import support #705

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading