No not necessary an anti pattern, there are more purpose build Services like Parameter store or secret Manager. But no body is stopping you from using dynamodb, s3 or something else.
Paramter store and secret manager nativity integrated with cloudformation, CDK, so you can hide sensitive data rather than expose it in the template as a variable or hard coded.
That would be my fist choice.
I pull values from the parameter store into an EKS K8s pod and have JSON in some of them. For me I use ASCP which has JMESPath functionality which allows me to make a bunch of k:v pairs from the JSON structure in the parameter store.
I know not 100% related but it illustrates how great parameter store is for this kind of thing. It’s also going to be cheaper than running an DynamoDB instance.
In my case I fill in the PS values as part of a CI/CD pipeline. On the EKS side I have automation that installs the security store CSI driver and ASCP providers as part of my cluster build along with updates to my IRSA role to allow reading the particular PS path. The rest is pretty easy in K8s. I have a manifest that creates the SecretProviderClass where I map the k:v’s using JMESPath. From there my deployment manifest has the volume configuration lines needed to mount the PS store objects. And what I get is a file system with files that correspond to the PS key name with contents of the value. I deploy all of this via my CI/CD deployment process.
YMMV depending on your workflow and your CI/CD platform. I do most everything in K8S. But PS works equally well for EC2 instance deployed apps etc.
Avoid fetching data in your cdk apps, we’ve found it to be troublesome. Where possible, do as folks have said here by referencing parameter store values (rather than fetching them). If that does not work, use a cloudformation custom resource to fetch your configuration at deploy time (instead of build/synth time)
CDK philosophy is to have all data in git along with the CDK code. They believe it’s best practice to be able to know exactly was was deployed by looking into just one place.
You can still achieve that with configuration in an external database by having a two step build that first fetches the configuration and generates files that must be committed in order to be deployed.
I don’t believe it’s an anti-pattern to skip all this. You may have issues if you use projen where this philosophy is enforced a bit more.
It’s an anti-pattern (even though I hate that term).
The whole purpose of Infrastructure-as-Code is to be able to make the process repeatable and to control changes to infrastructure. When you start adding configuration that isn’t in version control, you are undermining the whole purpose of using IaC.
Why can’t your config files be stored in source control with your CDK code?
Your code can generate configs that are consumed by your applications, but you shouldn’t have configuration that drives creation of resources sitting outside of source control.
We might not be a good example but we base64 encode complex structures into strings we can store via param store / secrets manager. But there’s not an intrinsic CF decode function.