DEV Community

Cover image for  AWS CDK  Escape Hatches in GO-CDK
Gernot Glawe
Gernot Glawe

Posted on

AWS CDK Escape Hatches in GO-CDK

With a hint from the jssi issues, I finally managed the CDK escape hatches - https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html in GO.

Basic idea is to replace the "any" types defined in the CDK/jsii like:

type CfnBucket_AnalyticsConfigurationProperty struct {
    Id *string `json:"id" yaml:"id"`
    StorageClassAnalysis interface{} `json:"storageClassAnalysis" yaml:"storageClassAnalysis"`
    Prefix *string `json:"prefix" yaml:"prefix"`
    TagFilters interface{} `json:"tagFilters" yaml:"tagFilters"`
}
Enter fullscreen mode Exit fullscreen mode

With GoFormation structures, which include all type informations like:

// See: 
type Bucket_AnalyticsConfiguration struct {
    Id string `json:"Id,omitempty"`
    Prefix string `json:"Prefix,omitempty"`
    StorageClassAnalysis *Bucket_StorageClassAnalysis `json:"StorageClassAnalysis,omitempty"`
Enter fullscreen mode Exit fullscreen mode

And get rid of the interface{}.

So: Want to use AWS CDK Escape Hatches as direct Cfnxx Construct modification easy and type-safe in GO-CDK?
Details here:
https://www.go-on-aws.com/infrastructure-as-go/cdk-go/escape-hatches/
Image description

What do you think about the methods?

aws #cdk #golang #cloudformation

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up