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

fix(core): remove cdk.Secret #2068

Merged
merged 7 commits into from
Apr 1, 2019
Merged

fix(core): remove cdk.Secret #2068

merged 7 commits into from
Apr 1, 2019

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 21, 2019

cdk.Secret was left over from when we thought we were going to do
secrets differently. Today, we model secret values as strings, which
can be retrieved from one of these:

  • ssm.ParameterStoreSecureString.stringValue
  • secretsmanager.SecretString.stringValue
  • cdk.CfnParameter.stringValue (but don't do that, because the secret
    will be readable from CloudFormation logs)

Fixes #2064.

BREAKING CHANGE: Replace use of cdk.Secret with
secretsmanager.SecretString (preferred) or
ssm.ParameterStoreSecureString.


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

`cdk.Secret` was left over from when we thought we were going to do
secrets differently. Today, we model secret values as strings, which
can be retrieved from one of these:

- `ssm.ParameterStoreSecureString.stringValue`
- `secretsmanager.SecretString.stringValue`
- `cdk.CfnParameter.stringValue` (but don't do that, because the secret
  will be readable from CloudFormation logs)

Fixes #2064.

BREAKING CHANGE: Replace use of `cdk.Secret` with
`secretsmanager.SecretString` (preferred) or
`ssm.ParameterStoreSecureString`.
@rix0rrr rix0rrr requested review from RomainMuller, skinny85 and a team as code owners March 21, 2019 09:36
@rix0rrr rix0rrr self-assigned this Mar 21, 2019
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I recall why we added this Secret class - we wanted to help people avoid embedding in clear text secrets in their code/templates, so we just added a wrapper. Do you think it's worth keeping perhaps?

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 26, 2019

So what we would be trying to achieve then is a flavor of string that is guaranteed to not be literally in the template?

I think the following might be appropriate then:

/**
 * A marker interface for objects that represent a secret string value
 */
export interface ISecretValue {
  stringValue: string;
}

Alternatively, in the constructs that want a secret, we just go:

if (!cdk.unresolved(input)) {
  throw new Error('Oy, are you daft or what?');
}

@eladb
Copy link
Contributor

eladb commented Mar 28, 2019

The latter option is not half bad, and I love the error message.

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Apr 1, 2019

The problem is there being will prevent people who know they want a literal secret value, for whatever reason.

addWarning() maybe?

@eladb
Copy link
Contributor

eladb commented Apr 1, 2019

Maybe an explicit optional switch that disables this check?

@@ -3,3 +3,54 @@
```ts
const alexaAsk = require('@aws-cdk/alexa-ask');
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Did not expect the empty README to be the correct end situation.

* secret values will not allow you to pass in a literal secret value. They do
* so by calling `Secret.assertSafeSecret()`.
*
* You can escape the check by calling `Secret.unsafeSecret()`, but doing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of Secret.unsafeSecret we can do Secret.clearText or Secret.plainText? Less about policy, more about mechanism...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove cdk.Secret
4 participants