Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssm: deploy-time random string generator for Parameter store #30881

Open
1 of 2 tasks
tmokmss opened this issue Jul 18, 2024 · 1 comment
Open
1 of 2 tasks

ssm: deploy-time random string generator for Parameter store #30881

tmokmss opened this issue Jul 18, 2024 · 1 comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@tmokmss
Copy link
Contributor

tmokmss commented Jul 18, 2024

Describe the feature

This is a feature request for Systems Manager Parameter store construct StringParameter to generate a random string on deploy-time.

Secrets Manager construct (Secret) already has this feature and it is useful for generating secrets such as a database password. However, the drawback of Secret Manager is its cost; it costs $0.40/month per secret. Parameter store is a lot cheaper; it incurrs no additional charge for storing a parameter.

If we can reliably and deterministically generate a cryptographically-secure random string for a parameter store, it will be a handy way to store secrets.

Use Case

Generate and store an API key or encryption key for an app deployed by CDK.

Proposed Solution

To avoid from any breaking changes, we add a new construct e.g. GeneratedStringParameter

Generally speaking, each parameter is used to store a single parameter, not an object like JSON, so we only need a simpler API than Secrets Manager. Something like the below should suffice:

new GeneratedStringParameter(scope, 'id', {
  parameterName: 'foo',
  generateOption: {
      excludeCharacters: 'asdf',
      excludeLowercase: true,
      excludeNumbers: true,
      excludePunctuation: true,
      excludeUppercase: true,
      includeSpace: false,
      length: 46,
      requireEachIncludedType: true
  }
});

The generateOption follows the existing SecretStringGenerator except the template feature, which should meet most use cases. 

Besides that, the construct should inherit all the props from StringParameterProps except stringValue, which will be filled by a random generated string.

Inside the construct, we add a custom resource to generate a string and a StringParameter construct:

class GeneratedStringParameter {
  constructor(scope, id, props) {
    const generator = new CustomResource(this, 'Generator', {
      serviceToken:...,
      resourceType: 'Custom:RandomStringGenerator',
      properties: {...props.generateOption},
    });

    new StringParameter(this, 'Resource', {
      ...props,
      stringValue: generator.getAttString('generated'),
    });
  }
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.149.0

Environment details (OS name and version, etc.)

macOS

@tmokmss tmokmss added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 18, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ssm Related to AWS Systems Manager label Jul 18, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 18, 2024
@khushail khushail self-assigned this Jul 18, 2024
@khushail
Copy link
Contributor

Hi @tmokmss , thanks for proposing this and volunteering to contribute. Since this is a proposed construct, one needs to submit an RFC and get the approval and review for the design, from the core team. However this whole contribution process is currently under review and being reassessed. Please feel free to check this ReadMe on L2 construct submission..

@khushail khushail added p2 effort/medium Medium work item – several days of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jul 18, 2024
@khushail khushail removed their assignment Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants