flaviostutz / cdk-practical-constructs

A collection of CDK constructs for making the development of AWS based applications easier and safer in a practical way
MIT License
4 stars 2 forks source link

feat: add ssm param as input to log group subscriber lambda #15

Closed MarcioMeier closed 5 months ago

MarcioMeier commented 5 months ago

Summary

Add the ability to pass an ssm string parameter to the logGroupSubscriber property.

Motivation

In our scenario we have one stack that handles the log group subscription, and to avoid stack output dependency, we store the lambda arn into the system manager's parameter store as a string parameter.

To avoid having to fetch it on every lambda construct we have, it would be nice if we could just provide the parameter key for the construct and it fetches the arn from ssm.

Changes

I changed the lambda's construct property from logGroupSubscriberLambdaArn to logGroupSubscriber as we may receive a ssm key now. I changed its datatype as well, from string to an object with the following definition:

{
    type: 'ssm' | 'arn';
    value: string;
}

It is a bit verbose but very explicit, please, let me know if you agree with this definition.

P.S.: I'd rather have the union type instead of enum, but I kept it as enum to follow the project standards.