Skip to content

Commit 068c8fa

Browse files
Merge pull request #23 from fabi200123/fix-subnetID-schema
Updates IAMInstanceProfile and SubnetID jsonschema
2 parents 01ad16b + 95dd496 commit 068c8fa

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ To this end, this provider supports the following extra specs schema:
102102
"properties": {
103103
"subnet_id": {
104104
"type": "string",
105-
"pattern": "^subnet-[0-9a-fA-F]{17}$"
105+
"pattern": "^subnet-(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{17})$"
106106
},
107107
"ssh_key_name": {
108108
"type": "string",

internal/spec/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func newExtraSpecsFromBootstrapData(data params.BootstrapInstance) (*extraSpecs,
7474
}
7575

7676
type extraSpecs struct {
77-
SubnetID *string `json:"subnet_id,omitempty" jsonschema:"pattern=^subnet-[0-9a-fA-F]{17}$,description=The ID of the subnet formatted as subnet-xxxxxxxxxxxxxxxxx."`
77+
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."`
7878
SSHKeyName *string `json:"ssh_key_name,omitempty" jsonschema:"description=The name of the Key Pair to use for the instance."`
7979
IAMInstanceProfile *string `json:"iam_instance_profile,omitempty" jsonschema:"description=The IAM instance profile to associate with the instance."`
8080
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."`

internal/spec/spec_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) {
7070
},
7171
errString: "",
7272
},
73+
{
74+
name: "specs just with older version of subnet_id",
75+
input: params.BootstrapInstance{
76+
ExtraSpecs: json.RawMessage(`{"subnet_id": "subnet-12345678"}`),
77+
},
78+
expectedOutput: &extraSpecs{
79+
SubnetID: aws.String("subnet-12345678"),
80+
},
81+
errString: "",
82+
},
7383
{
7484
name: "specs just with ssh_key_name",
7585
input: params.BootstrapInstance{
@@ -171,7 +181,7 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) {
171181
ExtraSpecs: json.RawMessage(`{"subnet_id": "subnet-1"}`),
172182
},
173183
expectedOutput: nil,
174-
errString: "subnet_id: Does not match pattern '^subnet-[0-9a-fA-F]{17}$'",
184+
errString: "subnet_id: Does not match pattern '^subnet-(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{17})$'",
175185
},
176186
{
177187
name: "invalid type for subnet_id",

0 commit comments

Comments
 (0)