cloudformation-cli icon indicating copy to clipboard operation
cloudformation-cli copied to clipboard

Pass in "Extra" Values

Open taylorbartley opened this issue 4 years ago • 8 comments

Feature Request

I'd like to be able to pass in values for additional properties to the MODULE types.

Example for a module named ACME::FOO::LogGroup::MODULE:

Parameters:
  FunctionName:
    Type: String

Resources:
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub /aws/lambda/${FunctionName}

Example use case of a default property as defined by CloudFormation/API:

LogGroup:
    Type: ACME::FOO::LogGroup::MODULE
    Properties:
      FunctionName: !Ref SomeLambdaFunction
      RetentionInDays: 3 << "Default" Property.

taylorbartley avatar May 20 '21 23:05 taylorbartley

I've just learned of the resource providers repository.

I can migrate this request there if it's more appropriate.

taylorbartley avatar May 20 '21 23:05 taylorbartley

Hey Taylor. Thanks for raising this. How would the RetentionInDays be used in this scenario? Is the idea that it matches a name of a property of LogGroup and is applied directly to that resource?

MalikAtalla-AWS avatar May 21 '21 05:05 MalikAtalla-AWS

@MalikAtalla-AWS That's exactly the use case! Since RetentionInDays is already a predefined property, it'd be nice to set that in the CFT template and have it passed through to the module, even if the module doesn't expose that property as a parameter.

Another example could be LambdaFunction module, where Runtime, Type, etc., are all passed in as parameters, but in the CFT template you also added Environment Variables as well.

taylorbartley avatar May 21 '21 13:05 taylorbartley

Could get ambiguous for modules with multiple resources, so this might break if the module ever gets another resource

PatMyron avatar May 21 '21 13:05 PatMyron

Right. I'm sure there would also be the complication of what happens when, for LogGroups, the module does define RetentionInDays?

taylorbartley avatar May 21 '21 13:05 taylorbartley

Yes, so this mechanism wouldn't work exactly as is, but I think I see what you're trying to achieve. You're trying to override certain properties of a module that are not exposed as parameters. This is a legitimate use case and is something we have discussed in the team before. I can pass this on as a data point to our product managers.

MalikAtalla-AWS avatar May 21 '21 15:05 MalikAtalla-AWS

I understand the use case (it is very tempting to use modules to set your own defaults), but I personally would recommend against doing this.

  • It makes it significantly harder to know the configuration of what will be deployed because you need to look at both the AWS documentation and the module documentation (or even source code).
  • The ACME::FOO::LogGroup::MODULE might not be used in other modules you're writing, and that's hard to see form the top-level
  • ACME::FOO::LogGroup::MODULE will definitely not be used in modules that are shared as Open Source projects
  • Other Companies are running into this issue too

If you want more background on that, here are some links for possibly diving deeper

benbridts avatar May 26 '21 07:05 benbridts

@benbridts I really appreciate the extra info you included. To be clear, I do understand this was a very niche ask, and is probably outside the philosophical scope of modules in general. I mainly asked out of curiosity to see how far we could extend them. I'm satisfied with the dialog. Whoever's in charge, please feel free to close or resolve this issue thank you!

taylorbartley avatar Jun 05 '21 17:06 taylorbartley