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

add interface attribute to google_compute_disk #4116

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2909,6 +2909,15 @@ objects:
are 4096 and 16384, other sizes may be added in the future.
If an unsupported value is requested, the error message will list
the supported values for the caller's project.
- !ruby/object:Api::Type::Enum
name: 'interface'
min_version: 'beta'
description: |
Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI.
default_value: :SCSI
values:
- :SCSI
- :NVME
- !ruby/object:Api::Type::ResourceRef
name: 'type'
resource: 'DiskType'
Expand Down
41 changes: 41 additions & 0 deletions third_party/terraform/tests/resource_compute_disk_test.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,29 @@ func TestAccComputeDisk_resourcePolicies(t *testing.T) {
}
<% end -%>

<% unless version == 'ga' -%>
func TestAccComputeDisk_interface(t *testing.T) {
t.Parallel()

diskName := fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccComputeDisk_interface(diskName),
},
{
ResourceName: "google_compute_disk.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
<% end -%>

func testAccCheckComputeDiskExists(t *testing.T, n, p string, disk *compute.Disk) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -774,4 +797,22 @@ resource "google_compute_disk" "foobar" {
}
`, policyName, diskName)
}

func testAccComputeDisk_interface(diskName string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_disk" "foobar" {
name = "%s"
image = data.google_compute_image.my_image.self_link
size = 50
type = "pd-ssd"
zone = "us-central1-a"
interface = "NVME"
}
`, diskName)
}
<% end -%>