Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update api.yaml * Update api.yaml * Update api.yaml * Update api.yaml * Update terraform.yaml * Create firebase_apple_app_basic.tf.erb * Responding to tylerg-dev's comments * Fixing the failing TestAccFirebaseAppleApp_firebaseAppleAppBasicExample test * Add a handwritten sweeper to hard-delete the AppleApp * Fix typo in update_mask * Fix var name in test * Add delete request body * Change appId to app_id in the sweeper delete url * Use custom_delete for deleting the AppleApp resource * Update api.yaml * Remove the repeated block in terraform.api * Add a 5 sec in the post_delete template * Move the 5 sec delay to the custom delete code * Add "Optional" to the deletion_policy description. * Address melinath@ comments * Add a manual update test * Remove unnecessary randomness. Also, move attributes to the vars section so they show up in docs. * Update mmv1/products/firebase/terraform.yaml Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> * Update mmv1/products/firebase/terraform.yaml Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> * Update mmv1/products/firebase/terraform.yaml Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> * Update mmv1/third_party/terraform/tests/resource_firebase_apple_app_update_test.go.erb Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> * Update mmv1/third_party/terraform/tests/resource_firebase_apple_app_update_test.go.erb Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> * Update mmv1/third_party/terraform/tests/resource_firebase_apple_app_update_test.go.erb Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> * Adding back the test_vars_overrides. Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com> Signed-off-by: Modular Magician <magic-modules@google.com> Signed-off-by: Modular Magician <magic-modules@google.com> Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
- Loading branch information
1 parent
39c6dfe
commit 0759cba
Showing
8 changed files
with
257 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-resource | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** HANDWRITTEN CODE *** Type: MMv1 *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package google | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func init() { | ||
resource.AddTestSweepers("FirebaseAppleApp", &resource.Sweeper{ | ||
Name: "FirebaseAppleApp", | ||
F: testSweepFirebaseAppleApp, | ||
}) | ||
} | ||
|
||
// At the time of writing, the CI only passes us-central1 as the region | ||
func testSweepFirebaseAppleApp(region string) error { | ||
resourceName := "FirebaseAppleApp" | ||
log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) | ||
|
||
config, err := sharedConfigForRegion(region) | ||
if err != nil { | ||
log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) | ||
return err | ||
} | ||
|
||
err = config.LoadAndValidate(context.Background()) | ||
if err != nil { | ||
log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) | ||
return err | ||
} | ||
|
||
t := &testing.T{} | ||
billingId := getTestBillingAccountFromEnv(t) | ||
|
||
// Setup variables to replace in list template | ||
d := &ResourceDataMock{ | ||
FieldsInSchema: map[string]interface{}{ | ||
"project": config.Project, | ||
"region": region, | ||
"location": region, | ||
"zone": "-", | ||
"billing_account": billingId, | ||
}, | ||
} | ||
|
||
listTemplate := strings.Split("https://firebase.googleapis.com/v1beta1/projects/{{project}}/iosApps", "?")[0] | ||
listUrl, err := replaceVars(d, config, listTemplate) | ||
if err != nil { | ||
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) | ||
return nil | ||
} | ||
|
||
res, err := sendRequest(config, "GET", config.Project, listUrl, config.userAgent, nil) | ||
if err != nil { | ||
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) | ||
return nil | ||
} | ||
|
||
resourceList, ok := res["appleApps"] | ||
if !ok { | ||
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") | ||
return nil | ||
} | ||
|
||
rl := resourceList.([]interface{}) | ||
|
||
log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) | ||
// Keep count of items that aren't sweepable for logging. | ||
nonPrefixCount := 0 | ||
for _, ri := range rl { | ||
obj := ri.(map[string]interface{}) | ||
if obj["name"] == nil { | ||
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) | ||
return nil | ||
} | ||
|
||
name := GetResourceNameFromSelfLink(obj["name"].(string)) | ||
// Skip resources that shouldn't be sweeped | ||
if !isSweepableTestResource(name) { | ||
nonPrefixCount++ | ||
continue | ||
} | ||
|
||
deleteTemplate := "https://firebase.googleapis.com/v1beta1/projects/{{project}}/iosApps/{{app_id}}:remove" | ||
deleteUrl, err := replaceVars(d, config, deleteTemplate) | ||
if err != nil { | ||
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) | ||
return nil | ||
} | ||
deleteUrl = deleteUrl + name | ||
|
||
body := make(map[string]interface{}) | ||
body["immediate"] = true | ||
|
||
// Don't wait on operations as we may have a lot to delete | ||
_, err = sendRequest(config, "DELETE", config.Project, deleteUrl, config.userAgent, body) | ||
if err != nil { | ||
log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) | ||
} else { | ||
log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) | ||
} | ||
} | ||
|
||
if nonPrefixCount > 0 { | ||
log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
--- | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
# | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# This file is automatically generated by Magic Modules and manual | ||
# changes will be clobbered when the file is regenerated. | ||
# | ||
# Please read more about how to change this file in | ||
# .github/CONTRIBUTING.md. | ||
# | ||
# ---------------------------------------------------------------------------- | ||
subcategory: "Firebase" | ||
page_title: "Google: google_firebase_apple_app" | ||
description: |- | ||
A Google Cloud Firebase Apple application instance | ||
--- | ||
|
||
# google\_firebase\_apple\_app | ||
|
||
A Google Cloud Firebase Apple application instance | ||
|
||
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. | ||
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. | ||
|
||
To get more information about AppleApp, see: | ||
|
||
* [API documentation](https://firebase.google.com/docs/projects/api/reference/rest/v1beta1/projects.iosApps) | ||
* How-to Guides | ||
* [Official Documentation](https://firebase.google.com/docs/ios/setup) | ||
|
||
## Example Usage - Firebase Apple App Basic | ||
|
||
|
||
```hcl | ||
resource "google_firebase_apple_app" "default" { | ||
provider = google-beta | ||
project = "my-project-name" | ||
display_name = "Display Name Basic" | ||
bundle_id = "apple.app.12345" | ||
} | ||
``` | ||
## Example Usage - Firebase Apple App Full | ||
|
||
|
||
```hcl | ||
resource "google_firebase_apple_app" "full" { | ||
provider = google-beta | ||
project = "my-project-name" | ||
display_name = "Display Name Full" | ||
bundle_id = "apple.app.12345" | ||
app_store_id = "12345" | ||
team_id = "9987654321" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
|
||
* `display_name` - | ||
(Required) | ||
The user-assigned display name of the App. | ||
|
||
|
||
- - - | ||
|
||
|
||
* `bundle_id` - | ||
(Optional) | ||
The canonical bundle ID of the Apple app as it would appear in the Apple AppStore. | ||
|
||
* `app_store_id` - | ||
(Optional) | ||
The automatically generated Apple ID assigned to the Apple app by Apple in the Apple App Store. | ||
|
||
* `team_id` - | ||
(Optional) | ||
The Apple Developer Team ID associated with the App in the App Store. | ||
|
||
* `deletion_policy` - | ||
(Optional) | ||
(Optional) Set to `ABANDON` to allow the AppleApp to be untracked from terraform state | ||
rather than deleted upon `terraform destroy`. This is useful because the AppleApp may be | ||
serving traffic. Set to `DELETE` to delete the AppleApp. Default to `DELETE`. | ||
|
||
* `project` - (Optional) The ID of the project in which the resource belongs. | ||
If it is not provided, the provider project is used. | ||
|
||
|
||
## Attributes Reference | ||
|
||
In addition to the arguments listed above, the following computed attributes are exported: | ||
|
||
* `id` - an identifier for the resource with format `{{name}}` | ||
|
||
* `name` - | ||
The fully qualified resource name of the App, for example: | ||
projects/projectId/iosApps/appId | ||
|
||
* `app_id` - | ||
The globally unique, Firebase-assigned identifier of the App. | ||
This identifier should be treated as an opaque token, as the data format is not specified. | ||
|
||
|
||
## Timeouts | ||
|
||
This resource provides the following | ||
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: | ||
|
||
- `create` - Default is 20 minutes. | ||
- `update` - Default is 20 minutes. | ||
- `delete` - Default is 20 minutes. | ||
|
||
## Import | ||
|
||
|
||
AppleApp can be imported using any of these accepted formats: | ||
|
||
``` | ||
$ terraform import google_firebase_apple_app.default projects/{{project}}/iosApps/{{appId}} | ||
$ terraform import google_firebase_apple_app.default {{project}}/{{appId}} | ||
$ terraform import google_firebase_apple_app.default iosApps/{{appId}} | ||
$ terraform import google_firebase_apple_app.default {{appId}} | ||
``` | ||
|
||
## User Project Overrides | ||
|
||
This resource supports [User Project Overrides](https://www.terraform.io/docs/providers/google/guides/provider_reference.html#user_project_override). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters