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

suppress diff on website #13069

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6827.txt
@@ -0,0 +1,3 @@
```release-note:bug
storage: fixed permdiff when `website`, `website.main_page_suffix`, `website.not_found_page` are removed on `google_storage_bucket`
```
7 changes: 7 additions & 0 deletions google/resource_storage_bucket.go
Expand Up @@ -251,19 +251,26 @@ func resourceStorageBucket() *schema.Resource {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"main_page_suffix": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: []string{"website.0.not_found_page", "website.0.main_page_suffix"},
Description: `Behaves as the bucket's directory index where missing objects are treated as potential directories.`,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return old != "" && new == ""
},
},
"not_found_page": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: []string{"website.0.main_page_suffix", "website.0.not_found_page"},
Description: `The custom object to return when a requested resource is not found.`,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return old != "" && new == ""
},
},
},
},
Expand Down
44 changes: 44 additions & 0 deletions google/resource_storage_bucket_test.go
Expand Up @@ -1016,6 +1016,15 @@ func TestAccStorageBucket_website(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
{
Config: testAccStorageBucket_websiteOneAttributeUpdate(bucketSuffix),
},
{
ResourceName: "google_storage_bucket.website",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
{
Config: testAccStorageBucket_website(bucketSuffix),
},
Expand All @@ -1025,6 +1034,15 @@ func TestAccStorageBucket_website(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
{
Config: testAccStorageBucket_websiteRemoved(bucketSuffix),
},
{
ResourceName: "google_storage_bucket.website",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
},
})
}
Expand Down Expand Up @@ -1939,6 +1957,17 @@ resource "google_storage_bucket" "website" {
`, bucketName)
}

func testAccStorageBucket_websiteRemoved(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "website" {
name = "%s.gcp.tfacc.hashicorptest.com"
location = "US"
storage_class = "STANDARD"
force_destroy = true
}
`, bucketName)
}

func testAccStorageBucket_websiteOneAttribute(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "website" {
Expand All @@ -1954,6 +1983,21 @@ resource "google_storage_bucket" "website" {
`, bucketName)
}

func testAccStorageBucket_websiteOneAttributeUpdate(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "website" {
name = "%s.gcp.tfacc.hashicorptest.com"
location = "US"
storage_class = "STANDARD"
force_destroy = true

website {
main_page_suffix = "default.html"
}
}
`, bucketName)
}

func testAccStorageBucket_forceDestroy(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "bucket" {
Expand Down