aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.71k stars 3.93k forks source link

`awsecs`: Golang - missing ecs optmized Bottlerocket images #25598

Open jpmcb opened 1 year ago

jpmcb commented 1 year ago

Describe the bug

Using the Golang CDK bindings, there is no EcsOptimizedImage_Bottlerocket. I only see the Amazon Linux ones and the Windows ones:

EcsOptimizedImage_AmazonLinux  (options *EcsOptimizedImageOptions) EcsOptimizedImage 
EcsOptimizedImage_AmazonLinux2 (hardwareType AmiHardwareType, options *EcsOptimizedImageOptions) EcsOptimizedImage
EcsOptimizedImage_Windows      (windowsVersion WindowsOptimizedVersion, options *EcsOptimizedImageOptions) EcsOptimizedImage

https://github.com/aws/aws-cdk-go/blob/main/awscdk/awsecs/EcsOptimizedImage.go

However, I do see the correct binding in this repository in typescript:

https://github.com/aws/aws-cdk/blob/05a9fec6512bdddc387a7a5c98fa55f1ab3b5b64/packages/aws-cdk-lib/aws-ecs/lib/amis.ts#L288-L298

Expected Behavior

I'd expect there to also be the correct Bottlerocket ECS optimized ami in Golang as well:

// The aws-ecs-1 variant of bottlerocket
EcsOptimizedImage_Bottlerocket  (options *EcsOptimizedImageOptions) EcsOptimizedImage 

Current Behavior

Missing function in the awsecs Go library to the Bottlerocket optimized AMI

Reproduction Steps

N/a

Possible Solution

I thought the Go bindings were generated from this Typescript codebase. So I'm surprised to find that the awsecs Go package is missing the Bottlerocket AMIs. These should be added since the aws-ecs-1 variant is supported by ECS.

Additional Information/Context

No response

CDK CLI Version

2.78.0 (build 8e95c37)

Framework Version

No response

Node.js Version

18.16.0

OS

Linux x86_64 ubuntu

Language

Go

Language Version

go version go1.20.4 linux/amd64

Other information

No response

khushail commented 1 year ago

Thanks @jpmcb for pointing this missing feature in CDK GoLang. However I am marking this as P2 which would mean our team won't be working on it immediately. However community PRs are welcome and team would be happy to review the submitted PRs. Here is the contributing guide to getting started.

stefanfreitag commented 1 year ago

@jpmcb @khushail Could it be that ECS optimized AMIs for Linux and Windows and Bottlerocket AMIs are accessible in different ways? The code below shows how to access both

awsecs.EcsOptimizedImage_AmazonLinux2(
        awsecs.AmiHardwareType_STANDARD,
        &awsecs.EcsOptimizedImageOptions{})

awsecs.NewBottleRocketImage(&awsecs.BottleRocketImageProps{
        Architecture: awsec2.InstanceArchitecture_ARM_64,
        Variant:      awsecs.BottlerocketEcsVariant_AWS_ECS_1,
    })

A cdk synth resolves the Bottlerocket part to

"SsmParameterValueawsservicebottlerocketawsecs1arm64latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
   "Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
   "Default": "/aws/service/bottlerocket/aws-ecs-1/arm64/latest/image_id"
  }, 
jpmcb commented 1 year ago

That works.

It's just weird there isn't a EcsOptimizedImage_Bottlerocket API in the awsecs package since there's the aws-ecs-1 variant of Bottlerocket that is specifically built/made for ECS while the other variants have that.

Having to use NewBottleRocketImage for only Bottlerocket is abit confusing and doesn't create a very flat/user-friendly API.