From 044d00045a14026fa66d796c4fc7144047a46f96 Mon Sep 17 00:00:00 2001 From: Josh Hogle Date: Wed, 20 May 2020 13:24:45 -0400 Subject: [PATCH] Fixed missing initialization of IMDS versions --- authority/provisioner/aws.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/authority/provisioner/aws.go b/authority/provisioner/aws.go index 9da6a9f3..52c8a40d 100644 --- a/authority/provisioner/aws.go +++ b/authority/provisioner/aws.go @@ -282,6 +282,22 @@ func (p *AWS) Init(config Config) (err error) { return err } p.audiences = config.Audiences.WithFragment(p.GetID()) + + // validate IMDS versions + if len(p.IMDSVersions) == 0 { + p.IMDSVersions = []string{"v2", "v1"} + } + for _, v := range p.IMDSVersions { + switch v { + case "v1": + // valid + case "v2": + // valid + default: + return errors.Errorf("%s: not a supported AWS Instance Metadata Service version", v) + } + } + return nil }