diff --git a/README.md b/README.md index 16d95be8..1bb4d501 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ To this end, this provider supports the following extra specs schema: "properties": { "subnet_id": { "type": "string", - "pattern": "^subnet-[0-9a-fA-F]{17}$" + "pattern": "^subnet-(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{17})$" }, "ssh_key_name": { "type": "string", diff --git a/internal/spec/spec.go b/internal/spec/spec.go index 05fac38d..972d49a3 100644 --- a/internal/spec/spec.go +++ b/internal/spec/spec.go @@ -74,9 +74,9 @@ func newExtraSpecsFromBootstrapData(data params.BootstrapInstance) (*extraSpecs, } type extraSpecs struct { - SubnetID *string `json:"subnet_id,omitempty" jsonschema:"pattern=^subnet-[0-9a-fA-F]{17}$,description=The ID of the subnet formatted as subnet-xxxxxxxxxxxxxxxxx."` + SubnetID *string `json:"subnet_id,omitempty" jsonschema:"pattern=^subnet-(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{17})$,description=The ID of the subnet formatted as subnet-xxxxxxxxxxxxxxxxx."` SSHKeyName *string `json:"ssh_key_name,omitempty" jsonschema:"description=The name of the Key Pair to use for the instance."` - IAMInstanceProfile *string `json:"iam_instance_profile,omitempty jsonschema:"description=The IAM instance profile to associate with the instance."` + IAMInstanceProfile *string `json:"iam_instance_profile,omitempty" jsonschema:"description=The IAM instance profile to associate with the instance."` Iops *int32 `json:"iops,omitempty" jsonschema:"description=Specifies the number of IOPS (Input/Output Operations Per Second) provisioned for the volume. Required for io1 and io2 volumes. Optional for gp3 volumes."` Throughput *int32 `json:"throughput,omitempty" jsonschema:"description=Specifies the throughput (MiB/s) provisioned for the volume. Valid only for gp3 volumes.,minimum=125,maximum=1000"` VolumeSize *int32 `json:"volume_size,omitempty" jsonschema:"description=Specifies the size of the volume in GiB. Required unless a snapshot ID is provided."` diff --git a/internal/spec/spec_test.go b/internal/spec/spec_test.go index 79e099f3..7dcbbd0c 100644 --- a/internal/spec/spec_test.go +++ b/internal/spec/spec_test.go @@ -70,6 +70,16 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) { }, errString: "", }, + { + name: "specs just with older version of subnet_id", + input: params.BootstrapInstance{ + ExtraSpecs: json.RawMessage(`{"subnet_id": "subnet-12345678"}`), + }, + expectedOutput: &extraSpecs{ + SubnetID: aws.String("subnet-12345678"), + }, + errString: "", + }, { name: "specs just with ssh_key_name", input: params.BootstrapInstance{ @@ -171,7 +181,7 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) { ExtraSpecs: json.RawMessage(`{"subnet_id": "subnet-1"}`), }, expectedOutput: nil, - errString: "subnet_id: Does not match pattern '^subnet-[0-9a-fA-F]{17}$'", + errString: "subnet_id: Does not match pattern '^subnet-(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{17})$'", }, { name: "invalid type for subnet_id",