From 1327659bb4f3a144fcd7aa0b61c75f007ee04d19 Mon Sep 17 00:00:00 2001 From: mrrishi Date: Sun, 8 Dec 2024 17:17:44 +0530 Subject: [PATCH] add validation for aws ami type --- cmd/aws/command.go | 11 +++ cmd/aws/create.go | 158 +++++++++++++++++++++++++++++++----- go.mod | 36 ++++---- go.sum | 40 +++++++-- internal/types/flags.go | 1 + internal/utilities/flags.go | 7 ++ 6 files changed, 213 insertions(+), 40 deletions(-) diff --git a/cmd/aws/command.go b/cmd/aws/command.go index f011c82a2..6567c0187 100644 --- a/cmd/aws/command.go +++ b/cmd/aws/command.go @@ -9,6 +9,7 @@ package aws import ( "fmt" + "github.com/konstructio/kubefirst-api/pkg/constants" "github.com/konstructio/kubefirst/internal/common" "github.com/konstructio/kubefirst/internal/progress" @@ -37,11 +38,20 @@ var ( nodeCountFlag string installCatalogApps string installKubefirstProFlag bool + amiType string // Supported argument arrays supportedDNSProviders = []string{"aws", "cloudflare"} supportedGitProviders = []string{"github", "gitlab"} supportedGitProtocolOverride = []string{"https", "ssh"} + supportedAMITypes = []string{ + "AL2_x86_64", + "AL2_ARM_64", + "BOTTLEROCKET_ARM_64", + "BOTTLEROCKET_x86_64", + "BOTTLEROCKET_ARM_64_NVIDIA", + "BOTTLEROCKET_x86_64_NVIDIA", + } ) func NewCommand() *cobra.Command { @@ -99,6 +109,7 @@ func Create() *cobra.Command { createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry") createCmd.Flags().BoolVar(&ecrFlag, "ecr", false, "whether or not to use ecr vs the git provider") createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro") + createCmd.Flags().StringVar(&amiType, "ami-type", "AL2_x86_64", fmt.Sprintf("the ami type for node group - one of: %q", supportedAMITypes)) return createCmd } diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 80c194817..9603dd510 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -7,12 +7,17 @@ See the LICENSE file for more details. package aws import ( + "context" "fmt" "os" "strings" - "github.com/aws/aws-sdk-go/aws" - awsinternal "github.com/konstructio/kubefirst-api/pkg/aws" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ssm" + "github.com/aws/aws-sdk-go-v2/service/sts" + bl "github.com/charmbracelet/log" internalssh "github.com/konstructio/kubefirst-api/pkg/ssh" pkg "github.com/konstructio/kubefirst-api/pkg/utils" "github.com/konstructio/kubefirst/internal/catalog" @@ -41,7 +46,7 @@ func createAws(cmd *cobra.Command, _ []string) error { return fmt.Errorf("invalid catalog apps: %w", err) } - err = ValidateProvidedFlags(cliFlags.GitProvider) + err = ValidateProvidedFlags(cliFlags.GitProvider, cliFlags.AmiType, cliFlags.CloudRegion) if err != nil { progress.Error(err.Error()) return fmt.Errorf("failed to validate provided flags: %w", err) @@ -57,15 +62,7 @@ func createAws(cmd *cobra.Command, _ []string) error { return nil } - // Validate aws region - config, err := awsinternal.NewAwsV2(cloudRegionFlag) - if err != nil { - progress.Error(err.Error()) - return fmt.Errorf("failed to validate AWS region: %w", err) - } - - awsClient := &awsinternal.Configuration{Config: config} - creds, err := awsClient.Config.Credentials.Retrieve(aws.BackgroundContext()) + creds, err := ValidateAWSRegionAndRetrieveCredentials(cloudRegionFlag) if err != nil { progress.Error(err.Error()) return fmt.Errorf("failed to retrieve AWS credentials: %w", err) @@ -78,12 +75,6 @@ func createAws(cmd *cobra.Command, _ []string) error { return fmt.Errorf("failed to write config: %w", err) } - _, err = awsClient.CheckAvailabilityZones(cliFlags.CloudRegion) - if err != nil { - progress.Error(err.Error()) - return fmt.Errorf("failed to check availability zones: %w", err) - } - gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup) if err != nil { progress.Error(err.Error()) @@ -136,7 +127,7 @@ func createAws(cmd *cobra.Command, _ []string) error { return nil } -func ValidateProvidedFlags(gitProvider string) error { +func ValidateProvidedFlags(gitProvider, amiType, cloudRegion string) error { progress.AddStep("Validate provided flags") // Validate required environment variables for dns provider @@ -161,7 +152,136 @@ func ValidateProvidedFlags(gitProvider string) error { log.Info().Msgf("%q %s", "gitlab.com", key.Type()) } + if err := ValidateAMIType(amiType, cloudRegion); err != nil { + progress.Error(err.Error()) + return fmt.Errorf("failed to validte ami type for node group: %w", err) + } + progress.CompleteStep("Validate provided flags") return nil } + +func ValidateAWSRegionAndRetrieveCredentials(cloudRegion string) (*aws.Credentials, error) { + // Load AWS configuration + cfg, err := config.LoadDefaultConfig(context.TODO(), + config.WithRegion(cloudRegion), + ) + if err != nil { + return nil, fmt.Errorf("failed to load AWS configuration: %w", err) + } + + // Validate region by creating a client + stsClient := sts.NewFromConfig(cfg) + _, err = stsClient.GetCallerIdentity(context.TODO(), &sts.GetCallerIdentityInput{}) + if err != nil { + return nil, fmt.Errorf("failed to validate AWS region: %w", err) + } + + // Retrieve credentials + creds, err := cfg.Credentials.Retrieve(context.TODO()) + if err != nil { + return nil, fmt.Errorf("failed to retrieve AWS credentials: %w", err) + } + + return &creds, nil +} + +func ValidateAMIType(amiType, region string) error { + ssm_types := map[string]string{ + "AL2_x86_64": "/aws/service/eks/optimized-ami/1.29/amazon-linux-2/recommended/image_id", + "AL2_ARM_64": "/aws/service/eks/optimized-ami/1.29/amazon-linux-2-arm64/recommended/image_id", + "BOTTLEROCKET_ARM_64": "/aws/service/bottlerocket/aws-k8s-1.29/arm64/latest/image_id", + "BOTTLEROCKET_x86_64": "/aws/service/bottlerocket/aws-k8s-1.29/x86_64/latest/image_id", + "BOTTLEROCKET_ARM_64_NVIDIA": "/aws/service/bottlerocket/aws-k8s-1.29-nvidia/arm64/latest/image_id", + "BOTTLEROCKET_x86_64_NVIDIA": "/aws/service/bottlerocket/aws-k8s-1.29-nvidia/x86_64/latest/image_id", + } + + _, ok := ssm_types[amiType] + if !ok { + return fmt.Errorf("not a valid ami type") + } + cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region)) + if err != nil { + return fmt.Errorf("unable to load AWS SDK config: %w", err) + } + ec2Client := ec2.NewFromConfig(cfg) + ssmClient := ssm.NewFromConfig(cfg) + ssmParameterName := ssm_types["BOTTLEROCKET_x86_64_NVIDIA"] + + amiID, err := GetLatestAMIFromSSM(ssmClient, ssmParameterName) + if err != nil { + return fmt.Errorf("failed to get AMI ID from SSM: %w", err) + } + bl.Info("Retrieved AMI ID: %s\n", amiID) + + architecture, err := GetAMIArchitecture(ec2Client, amiID) + if err != nil { + return fmt.Errorf("failed to get AMI architecture: %w", err) + } + fmt.Printf("AMI Architecture: %s\n", architecture) + + instanceTypes, err := GetSupportedInstanceTypes(ec2Client, architecture) + if err != nil { + return fmt.Errorf("failed to get supported instance types: %w", err) + } + + fmt.Println("Supported Instance Types:") + for _, instanceType := range instanceTypes { + fmt.Println(instanceType) + } + + return nil +} + +func GetLatestAMIFromSSM(ssmClient *ssm.Client, parameterName string) (string, error) { + + input := &ssm.GetParameterInput{ + Name: aws.String(parameterName), + } + output, err := ssmClient.GetParameter(context.TODO(), input) + if err != nil { + return "", err + } + + return *output.Parameter.Value, nil +} + +func GetAMIArchitecture(ec2Client *ec2.Client, amiID string) (string, error) { + input := &ec2.DescribeImagesInput{ + ImageIds: []string{amiID}, + } + output, err := ec2Client.DescribeImages(context.TODO(), input) + if err != nil { + return "", err + } + + if len(output.Images) == 0 { + return "", fmt.Errorf("no images found for AMI ID: %s", amiID) + } + + val := output.Images[0] + return string(val.Architecture), nil +} + +func GetSupportedInstanceTypes(ec2Client *ec2.Client, architecture string) ([]string, error) { + input := &ec2.DescribeInstanceTypesInput{} + + var instanceTypes []string + paginator := ec2.NewDescribeInstanceTypesPaginator(ec2Client, input) + + for paginator.HasMorePages() { + page, err := paginator.NextPage(context.TODO()) + if err != nil { + return nil, err + } + + for _, instanceType := range page.InstanceTypes { + if string(instanceType.ProcessorInfo.SupportedArchitectures[0]) == architecture { + instanceTypes = append(instanceTypes, string(instanceType.InstanceType)) + } + } + } + + return instanceTypes, nil +} diff --git a/go.mod b/go.mod index 596301519..17c88fe9a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,9 @@ go 1.23.0 require ( github.com/argoproj/argo-cd/v2 v2.9.3 github.com/atotto/clipboard v0.1.4 - github.com/aws/aws-sdk-go v1.55.5 + github.com/aws/aws-sdk-go-v2/config v1.28.6 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.91.0 + github.com/aws/aws-sdk-go-v2/service/ssm v1.56.1 github.com/charmbracelet/bubbles v0.16.1 github.com/charmbracelet/bubbletea v0.24.2 github.com/charmbracelet/glamour v0.8.0 @@ -34,6 +36,11 @@ require ( k8s.io/client-go v11.0.1-0.20190816222228-6d55c1b1f1ca+incompatible ) +require ( + github.com/aws/aws-sdk-go v1.44.317 // indirect + github.com/go-logfmt/logfmt v0.6.0 // indirect +) + require ( cloud.google.com/go v0.112.1 // indirect cloud.google.com/go/compute v1.24.0 // indirect @@ -65,32 +72,30 @@ require ( github.com/alecthomas/chroma/v2 v2.14.0 // indirect github.com/argoproj/gitops-engine v0.7.3 // indirect github.com/argoproj/pkg v0.13.7-0.20230627120311-a4dd357b057e // indirect - github.com/aws/aws-sdk-go-v2 v1.17.8 // indirect + github.com/aws/aws-sdk-go-v2 v1.32.6 github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect - github.com/aws/aws-sdk-go-v2/config v1.18.19 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.18 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.47 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 // indirect - github.com/aws/aws-sdk-go-v2/service/ec2 v1.91.0 // indirect github.com/aws/aws-sdk-go-v2/service/ecr v1.18.7 // indirect github.com/aws/aws-sdk-go-v2/service/eks v1.27.10 // indirect github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.15.6 // indirect github.com/aws/aws-sdk-go-v2/service/iam v1.19.8 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.6 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0 // indirect github.com/aws/aws-sdk-go-v2/service/kms v1.20.8 // indirect github.com/aws/aws-sdk-go-v2/service/route53 v1.27.5 // indirect github.com/aws/aws-sdk-go-v2/service/s3 v1.31.0 // indirect github.com/aws/aws-sdk-go-v2/service/servicequotas v1.14.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.6 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 // indirect - github.com/aws/smithy-go v1.13.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.24.7 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.6 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 + github.com/aws/smithy-go v1.22.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -102,6 +107,7 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/gettext-go v0.1.0 // indirect + github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.4.5 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/cloudflare/cloudflare-go v0.73.0 // indirect diff --git a/go.sum b/go.sum index e5ea72793..4fc3e8002 100644 --- a/go.sum +++ b/go.sum @@ -166,27 +166,38 @@ github.com/aws/aws-sdk-go v1.35.24/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9 github.com/aws/aws-sdk-go v1.38.49/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.44.213/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.290/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU= -github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= +github.com/aws/aws-sdk-go v1.44.317 h1:+8XWrLmGMwPPXSRSLPzhgcGnzJ2mYkgkrcB9C/GnSOU= +github.com/aws/aws-sdk-go v1.44.317/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.17.8 h1:GMupCNNI7FARX27L7GjCJM8NgivWbRgpjNI/hOQjFS8= github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.32.6 h1:7BokKRgRPuGmKkFMhEg/jSul+tB9VvXhcViILtfG8b4= +github.com/aws/aws-sdk-go-v2 v1.32.6/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= github.com/aws/aws-sdk-go-v2/config v1.18.19 h1:AqFK6zFNtq4i1EYu+eC7lcKHYnZagMn6SW171la0bGw= github.com/aws/aws-sdk-go-v2/config v1.18.19/go.mod h1:XvTmGMY8d52ougvakOv1RpiTLPz9dlG/OQHsKU/cMmY= +github.com/aws/aws-sdk-go-v2/config v1.28.6 h1:D89IKtGrs/I3QXOLNTH93NJYtDhm8SYa9Q5CsPShmyo= +github.com/aws/aws-sdk-go-v2/config v1.28.6/go.mod h1:GDzxJ5wyyFSCoLkS+UhGB0dArhb9mI+Co4dHtoTxbko= github.com/aws/aws-sdk-go-v2/credentials v1.13.18 h1:EQMdtHwz0ILTW1hoP+EwuWhwCG1hD6l3+RWFQABET4c= github.com/aws/aws-sdk-go-v2/credentials v1.13.18/go.mod h1:vnwlwjIe+3XJPBYKu1et30ZPABG3VaXJYr8ryohpIyM= +github.com/aws/aws-sdk-go-v2/credentials v1.17.47 h1:48bA+3/fCdi2yAwVt+3COvmatZ6jUDNkDTIsqDiMUdw= +github.com/aws/aws-sdk-go-v2/credentials v1.17.47/go.mod h1:+KdckOejLW3Ks3b0E3b5rHsr2f9yuORBum0WPnE5o5w= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1 h1:gt57MN3liKiyGopcqgNzJb2+d9MJaKT/q1OksHNXVE4= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1/go.mod h1:lfUx8puBRdM5lVVMQlwt2v+ofiG/X6Ms+dy0UkG/kXw= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 h1:AmoU1pziydclFT/xRV+xXE/Vb8fttJCLRPv8oAkprc0= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21/go.mod h1:AjUdLYe4Tgs6kpH4Bv7uMZo7pottoyHMn4eTcIcneaY= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 h1:dpbVNUjczQ8Ae3QKHbpHBpfvaVkRdesxpTOe9pTouhU= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32/go.mod h1:RudqOgadTWdcS3t/erPQo24pcVEoYyqj/kKW5Vya21I= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25 h1:s/fF4+yDQDoElYhfIVvSNyeCydfbuTKzhxSXDXCPasU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25/go.mod h1:IgPfDv5jqFIzQSNbUEMoitNooSMXjRSDkhXv8jiROvU= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26 h1:QH2kOS3Ht7x+u0gHCh06CXL/h6G8LQJFpZfFBYBNboo= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26/go.mod h1:vq86l7956VgFr0/FWQ2BWnK07QC3WYsepKzy33qqY5U= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25 h1:ZntTCl5EsYnhN/IygQEUugpdwbhdkom9uHcbCftiGgA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25/go.mod h1:DBdPrgeocww+CSl1C8cEV8PN1mHMBhuCDLpXezyvWkE= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32 h1:p5luUImdIqywn6JpQsW3tq5GNOxKmOnEpybzPx+d1lk= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 h1:DWYZIsyqagnWL00f8M/SOr9fN063OEQWn9LLTbdYXsk= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23/go.mod h1:uIiFgURZbACBEQJfqTZPb/jxO7R+9LeoHUFudtIdeQI= github.com/aws/aws-sdk-go-v2/service/ec2 v1.91.0 h1:b4Qme29Ml9nl3QBxWobytF5UxlfmYUJI7+u1FTqjehs= @@ -201,10 +212,14 @@ github.com/aws/aws-sdk-go-v2/service/iam v1.19.8 h1:kQsBeGgm68kT0xc90spgC5qEOQGH github.com/aws/aws-sdk-go-v2/service/iam v1.19.8/go.mod h1:lf/oAjt//UvPsmnOgPT61F+q4K6U0q4zDd1s1yx2NZs= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 h1:CeuSeq/8FnYpPtnuIeLQEEvDv9zUjneuYi8EghMBdwQ= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26/go.mod h1:2UqAAwMUXKeRkAHIlDJqvMVgOWkUi/AUXPk/YIe+Dg4= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 h1:5LHn8JQ0qvjD9L9JhMtylnkcw7j05GDZqM9Oin6hpr0= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.6 h1:50+XsN70RS7dwJ2CkVNXzj7U2L1HKP8nqTd3XWEXBN4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.6/go.mod h1:WqgLmwY7so32kG01zD8CPTJWVWM+TzJoOVHwTg4aPug= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0 h1:e2ooMhpYGhDnBfSvIyusvAwX7KexuZaHbQY2Dyei7VU= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0/go.mod h1:bh2E0CXKZsQN+faiKVqC40vfNMAWheoULBCnEgO9K+8= github.com/aws/aws-sdk-go-v2/service/kms v1.20.8 h1:R5f4VOFi3ScTe7TtePyxLqEhNqTJIAxL57MzrXFNs6I= @@ -215,14 +230,23 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.31.0 h1:B1G2pSPvbAtQjilPq+Y7jLIzCOwKz github.com/aws/aws-sdk-go-v2/service/s3 v1.31.0/go.mod h1:ncltU6n4Nof5uJttDtcNQ537uNuwYqsZZQcpkd2/GUQ= github.com/aws/aws-sdk-go-v2/service/servicequotas v1.14.7 h1:HYGdUZ0XwZ4G6Fyy9w3UxTUHbCIbtYhlVOY6jAj1sXY= github.com/aws/aws-sdk-go-v2/service/servicequotas v1.14.7/go.mod h1:2EILaoWLexVCHo6VmAMO+S1ENFJNjLEVn+QVdKpSE5Q= +github.com/aws/aws-sdk-go-v2/service/ssm v1.56.1 h1:cfVjoEwOMOJOI6VoRQua0nI0KjZV9EAnR8bKaMeSppE= +github.com/aws/aws-sdk-go-v2/service/ssm v1.56.1/go.mod h1:fGHwAnTdNrLKhgl+UEeq9uEL4n3Ng4MJucA+7Xi3sC4= github.com/aws/aws-sdk-go-v2/service/sso v1.12.6 h1:5V7DWLBd7wTELVz5bPpwzYy/sikk0gsgZfj40X+l5OI= github.com/aws/aws-sdk-go-v2/service/sso v1.12.6/go.mod h1:Y1VOmit/Fn6Tz1uFAeCO6Q7M2fmfXSCLeL5INVYsLuY= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.7 h1:rLnYAfXQ3YAccocshIH5mzNNwZBkBo+bP6EhIxak6Hw= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.7/go.mod h1:ZHtuQJ6t9A/+YDuxOLnbryAmITtr8UysSny3qcyvJTc= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6 h1:B8cauxOH1W1v7rd8RdI/MWnoR4Ze0wIHWrb90qczxj4= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6/go.mod h1:Lh/bc9XUf8CfOY6Jp5aIkQtN+j1mc+nExc+KXj9jx2s= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.6 h1:JnhTZR3PiYDNKlXy50/pNeix9aGMo6lLpXwJ1mw8MD4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.6/go.mod h1:URronUEGfXZN1VpdktPSD1EkAL9mfrV+2F4sjH38qOY= github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 h1:bWNgNdRko2x6gqa0blfATqAZKZokPIeM1vfmQt2pnvM= github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8NcjjwgOKEfZ4cOjMuT2IBT/2eI= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 h1:s4074ZO1Hk8qv65GqNXqDjmkf4HSQqJukaLuuW0TpDA= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.2/go.mod h1:mVggCnIWoM09jP71Wh+ea7+5gAp53q+49wDFs1SW5z8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= +github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= @@ -280,6 +304,8 @@ github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs= github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8= +github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= +github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM= github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4 h1:6KzMkQeAF56rggw2NZu1L+TH7j9+DM1/2Kmh7KUxg1I= @@ -447,6 +473,8 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= +github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= diff --git a/internal/types/flags.go b/internal/types/flags.go index 392d221ad..3ea212759 100644 --- a/internal/types/flags.go +++ b/internal/types/flags.go @@ -35,4 +35,5 @@ type CliFlags struct { K3sServersPublicIPs []string K3sServersArgs []string InstallKubefirstPro bool + AmiType string } diff --git a/internal/utilities/flags.go b/internal/utilities/flags.go index c6ac1dd52..4be336fa1 100644 --- a/internal/utilities/flags.go +++ b/internal/utilities/flags.go @@ -131,6 +131,13 @@ func GetFlags(cmd *cobra.Command, cloudProvider string) (types.CliFlags, error) } cliFlags.ECR = ecrFlag + + amiType, err := cmd.Flags().GetString("ami-type") + if err != nil { + progress.Error(err.Error()) + return cliFlags, fmt.Errorf("failed to get ami type: %w", err) + } + cliFlags.AmiType = amiType } if cloudProvider == "azure" {