terraform-provider: add usage examples (#2713)

* terraform-provider: add usage example for Azure

* terraform-provider: add usage example for AWS

* terraform-provider: add usage example for GCP

* terraform-provider: update usage example for Azure

* terraform-provider: update generated documentation

* docs: adjust creation on Azure and link to examples

* terraform-provider: unify image in-/output (#2725)

* terraform-provider: check for returned error when converting microservices

* terraform-provider: use state values for outputs after creation

* terraform-provider: ignore invalid upgrades (#2728)

---------

Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
Co-authored-by: Thomas Tendyck <51411342+thomasten@users.noreply.github.com>
This commit is contained in:
Moritz Sanft 2023-12-18 10:15:54 +01:00 committed by GitHub
parent 88d626d302
commit af791bd221
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 797 additions and 204 deletions

View file

@ -18,7 +18,7 @@ func TestAccImageDataSource(t *testing.T) {
bazelPreCheck := func() { bazelSetTerraformBinaryPath(t) }
testCases := map[string]resource.TestCase{
"no image_version succeeds": {
"no version succeeds": {
ProtoV6ProviderFactories: testAccProtoV6ProviderFactoriesWithVersion("v2.13.0"),
PreCheck: bazelPreCheck,
Steps: []resource.TestStep{
@ -30,7 +30,11 @@ func TestAccImageDataSource(t *testing.T) {
region = "eu-west-1"
}
`,
Check: resource.TestCheckResourceAttrSet("data.constellation_image.test", "reference"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.constellation_image.test", "image.reference"),
resource.TestCheckResourceAttrSet("data.constellation_image.test", "image.version"),
resource.TestCheckResourceAttrSet("data.constellation_image.test", "image.short_path"),
),
},
},
},
@ -42,13 +46,13 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "aws-sev-snp"
csp = "aws"
region = "eu-west-1"
}
`,
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "reference", "ami-04f8d522b113b73bf"), // should be immutable
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "image.reference", "ami-04f8d522b113b73bf"), // should be immutable
},
},
@ -61,7 +65,7 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "aws-sev-snp"
csp = "aws"
}
@ -78,12 +82,12 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "azure-sev-snp"
csp = "azure"
}
`,
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "reference", "/communityGalleries/ConstellationCVM-b3782fa0-0df7-4f2f-963e-fc7fc42663df/images/constellation/versions/2.13.0"), // should be immutable
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "image.reference", "/communityGalleries/ConstellationCVM-b3782fa0-0df7-4f2f-963e-fc7fc42663df/images/constellation/versions/2.13.0"), // should be immutable
},
},
@ -96,13 +100,13 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "azure-sev-snp"
csp = "azure"
marketplace_image = true
}
`,
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "reference", "constellation-marketplace-image://Azure?offer=constellation&publisher=edgelesssystems&sku=constellation&version=2.13.0"), // should be immutable
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "image.reference", "constellation-marketplace-image://Azure?offer=constellation&publisher=edgelesssystems&sku=constellation&version=2.13.0"), // should be immutable
},
},
@ -115,12 +119,12 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "gcp-sev-es"
csp = "gcp"
}
`,
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "reference", "projects/constellation-images/global/images/v2-13-0-gcp-sev-es-stable"), // should be immutable,
Check: resource.TestCheckResourceAttr("data.constellation_image.test", "image.reference", "projects/constellation-images/global/images/v2-13-0-gcp-sev-es-stable"), // should be immutable,
},
},
},
@ -132,7 +136,7 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "unknown"
csp = "azure"
}
@ -149,7 +153,7 @@ func TestAccImageDataSource(t *testing.T) {
{
Config: testingConfig + `
data "constellation_image" "test" {
image_version = "v2.13.0"
version = "v2.13.0"
attestation_variant = "azure-sev-snp"
csp = "unknown"
}