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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay