mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-22 16:19:19 -04:00
terraform-provider: support AWS marketplace images
This commit is contained in:
parent
0605f44a38
commit
5e182127b7
@ -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.
|
||||
|
@ -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())
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user