diff --git a/terraform-provider-constellation/docs/data-sources/image.md b/terraform-provider-constellation/docs/data-sources/image.md index 6d0370eaf..8eb48929e 100644 --- a/terraform-provider-constellation/docs/data-sources/image.md +++ b/terraform-provider-constellation/docs/data-sources/image.md @@ -37,7 +37,7 @@ See the [full list of CSPs](https://docs.edgeless.systems/constellation/overview ### Optional -- `marketplace_image` (Boolean) Whether a marketplace image should be used. Currently only supported for Azure and GCP. +- `marketplace_image` (Boolean) Whether a marketplace image should be used. - `region` (String) Region to retrieve the image for. Only required for AWS. The Constellation OS image must be [replicated to the region](https://docs.edgeless.systems/constellation/workflows/config),and the region must [support AMD SEV-SNP](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/snp-requirements.html), if it is used for Attestation. - `version` (String) Version of the Constellation OS image to use. (e.g. `v2.13.0`). If not set, the provider version value is used. diff --git a/terraform-provider-constellation/internal/provider/image_data_source.go b/terraform-provider-constellation/internal/provider/image_data_source.go index 44262c20e..5e97bdcb4 100644 --- a/terraform-provider-constellation/internal/provider/image_data_source.go +++ b/terraform-provider-constellation/internal/provider/image_data_source.go @@ -87,8 +87,8 @@ func (d *ImageDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, }, "csp": newCSPAttributeSchema(), "marketplace_image": schema.BoolAttribute{ - Description: "Whether a marketplace image should be used. Currently only supported for Azure and GCP.", - MarkdownDescription: "Whether a marketplace image should be used. Currently only supported for Azure and GCP.", + Description: "Whether a marketplace image should be used.", + MarkdownDescription: "Whether a marketplace image should be used.", Optional: true, }, "region": schema.StringAttribute{ @@ -128,14 +128,6 @@ func (d *ImageDataSource) ValidateConfig(ctx context.Context, req datasource.Val ) } - // Marketplace image is only supported for Azure and GCP - if data.CSP.Equal(types.StringValue("aws")) && !data.MarketplaceImage.IsNull() { - resp.Diagnostics.AddAttributeError( - path.Root("marketplace_image"), - "Marketplace images are currently only supported on Azure and GCP", "When another CSP than Azure or GCP is used, marketplace images are unavailable.", - ) - } - // Version should be a valid semver or short path, if set if !data.Version.IsNull() { _, semverErr := semver.New(data.Version.ValueString()) diff --git a/terraform-provider-constellation/internal/provider/image_data_source_test.go b/terraform-provider-constellation/internal/provider/image_data_source_test.go index 8e79986d9..787b7aacf 100644 --- a/terraform-provider-constellation/internal/provider/image_data_source_test.go +++ b/terraform-provider-constellation/internal/provider/image_data_source_test.go @@ -72,6 +72,24 @@ func TestAccImageDataSource(t *testing.T) { }, }, }, + "aws marketplace success": { + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + PreCheck: bazelPreCheck, + Steps: []resource.TestStep{ + { + Config: testingConfig + ` + data "constellation_image" "test" { + version = "v2.13.0" + attestation_variant = "aws-sev-snp" + csp = "aws" + marketplace_image = true + region = "eu-west-1" + } + `, + Check: resource.TestCheckResourceAttr("data.constellation_image.test", "image.reference", "resolve:ssm:/aws/service/marketplace/prod-77ylkenlkgufs/v2.13.0"), // should be immutable, + }, + }, + }, "azure success": { ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, PreCheck: bazelPreCheck, @@ -171,6 +189,23 @@ func TestAccImageDataSource(t *testing.T) { }, }, }, + "gcp marketplace success": { + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + PreCheck: bazelPreCheck, + Steps: []resource.TestStep{ + { + Config: testingConfig + ` + data "constellation_image" "test" { + version = "v2.13.0" + attestation_variant = "gcp-sev-es" + csp = "gcp" + marketplace_image = true + } + `, + Check: resource.TestCheckResourceAttr("data.constellation_image.test", "image.reference", "projects/mpi-edgeless-systems-public/global/images/v2-13-0-gcp-sev-es-stable"), // should be immutable, + }, + }, + }, } for name, tc := range testCases {