From 72d9e757368284a8a7e671215baef9852b7ce966 Mon Sep 17 00:00:00 2001 From: Victoria Jeffrey Date: Tue, 5 Mar 2024 13:32:52 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20conflicting=20id=20for=20a?= =?UTF-8?q?ws=20ec2=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/aws/connection/awsec2ebsconn/provider.go | 6 +++--- providers/aws/connection/awsec2ebsconn/types/types.go | 4 ++-- providers/aws/connection/awsec2ebsconn/types_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/providers/aws/connection/awsec2ebsconn/provider.go b/providers/aws/connection/awsec2ebsconn/provider.go index fe3f1e9877..91b7a9d579 100644 --- a/providers/aws/connection/awsec2ebsconn/provider.go +++ b/providers/aws/connection/awsec2ebsconn/provider.go @@ -322,16 +322,16 @@ func NewInstanceId(account string, region string, id string) (*awsec2ebstypes.In func ParseInstanceId(path string) (*awsec2ebstypes.InstanceId, error) { if !IsValidInstanceId(path) { - return nil, errors.New("invalid instance id. expected account//region//instance/") + return nil, errors.New("invalid instance id. expected account//region//instances/") } keyValues := strings.Split(path, "/") if len(keyValues) != 6 { - return nil, errors.New("invalid instance id. expected account//region//instance/") + return nil, errors.New("invalid instance id. expected account//region//instances/") } return NewInstanceId(keyValues[1], keyValues[3], keyValues[5]) } -var VALID_INSTANCE_ID = regexp.MustCompile(`^account/\d{12}/region\/(us(-gov)?|ap|ca|cn|eu|sa)-(central|(north|south)?(east|west)?)-\d\/instance\/.+$`) +var VALID_INSTANCE_ID = regexp.MustCompile(`^account/\d{12}/region\/(us(-gov)?|ap|ca|cn|eu|sa)-(central|(north|south)?(east|west)?)-\d\/instances\/.+$`) func IsValidInstanceId(path string) bool { return VALID_INSTANCE_ID.MatchString(path) diff --git a/providers/aws/connection/awsec2ebsconn/types/types.go b/providers/aws/connection/awsec2ebsconn/types/types.go index 7c45302e37..9d0558a75d 100644 --- a/providers/aws/connection/awsec2ebsconn/types/types.go +++ b/providers/aws/connection/awsec2ebsconn/types/types.go @@ -49,6 +49,6 @@ type VolumeInfo struct { } func (s *InstanceId) String() string { - // e.g. account/999000999000/region/us-east-2/instance/i-0989478343232 - return path.Join("account", s.Account, "region", s.Region, "instance", s.Id) + // e.g. account/999000999000/region/us-east-2/instances/i-0989478343232 + return path.Join("account", s.Account, "region", s.Region, "instances", s.Id) } diff --git a/providers/aws/connection/awsec2ebsconn/types_test.go b/providers/aws/connection/awsec2ebsconn/types_test.go index bfae1c9075..8693169fb1 100644 --- a/providers/aws/connection/awsec2ebsconn/types_test.go +++ b/providers/aws/connection/awsec2ebsconn/types_test.go @@ -11,7 +11,7 @@ import ( ) func TestParseInstanceId(t *testing.T) { - path := "account/185972265011/region/us-east-1/instance/i-07f67838ada5879af" + path := "account/185972265011/region/us-east-1/instances/i-07f67838ada5879af" id, err := ParseInstanceId(path) require.NoError(t, err) assert.Equal(t, id.Account, "185972265011")