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

docs(cognito): fix up code samples so that they compile #11034

Merged
merged 2 commits into from
Oct 22, 2020

Conversation

shivlaks
Copy link
Contributor

Added a default fixture with the imports needed to compile snippets.
Fixed up a few parameter names, required parameters, references that were incorrect.

Verified that these snippets (with fixture) compile by running compile-samples in
the scripts directory.

Closes #9185


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

Added a default fixture with the imports needed to compile snippets.
Fixed up a few parameter names, required parameters, references that were incorrect.

Verified that these snippets (with fixture) compile by running `compile-samples` in
the `scripts` directory.

Closes #9185
@shivlaks shivlaks added the @aws-cdk/aws-cognito Related to Amazon Cognito label Oct 22, 2020
@shivlaks shivlaks requested a review from nija-at October 22, 2020 10:24
@shivlaks shivlaks self-assigned this Oct 22, 2020
@gitpod-io
Copy link

gitpod-io bot commented Oct 22, 2020

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 22, 2020
@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 97935dd
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit a73a4ee into master Oct 22, 2020
@mergify mergify bot deleted the shivlaks/cognito-rosetta branch October 22, 2020 12:29

new UserPool(this, 'myuserpool', {
new cognito.UserPool(this, 'myuserpool', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big fan of prefixing cognito everywhere. Would've preferred if the fixture had individually imported what's required, so the README stays clean.

OTOH doing so would mean that any new type being used here would have the fixture be updated. Given that we have no validation for this, maybe this is ok.

userpool.addTrigger(UserPoolOperation.USER_MIGRATION, new lambda.Function(this, 'userMigrationFn', {
// ...
userpool.addTrigger(cognito.UserPoolOperation.USER_MIGRATION, new lambda.Function(this, 'userMigrationFn', {
runtime: lambda.Runtime.NODEJS_10_X,
Copy link
Contributor

Choose a reason for hiding this comment

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

fix indent

Comment on lines 323 to 327
const authChallengeFn = new lambda.Function(this, 'authChallengeFn', {
// ...
runtime: lambda.Runtime.NODEJS_10_X,
handler: 'index.handler',
code: lambda.Code.fromInline('auth challenge'),
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary? I thought rosetta translations work as long as it was valid typescript. Does it have to actually compile and work?

I would've preferred to leave this open for the user to define and rosetta translation snippet does the same.


pool.addDomain('CognitoDomain', {
cognitoDomain: {
domainPrefix: 'my-awesome-app',
},
});

const domainCert = new acm.Certificate.fromCertificateArn(this, 'domainCert', certificateArn);
const certificateArn = 'arn:aws:acm:us-east-1:123456789012:certificate/11-3336f1-44483d-adc7-9cd375c5169d';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not move this into the fixture?

Comment on lines +404 to 407
clientId: 'amzn-client-id',
clientSecret: 'amzn-client-secret',
userPool: userpool,
attributeMapping: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of this change either. Now the focus is diffused and doesn't focus on just the attributeMapping property which this section is talking about.

How about defining the whole set of properties in the rosetta fixture and doing something like

new UserPoolIdentityProviderAmazon(stack, 'Amazon', {
  ...otherIdentityProviderAttrs, // this is defined in the fixture
  attributeMapping: {
  }
});

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

Successfully merging this pull request may close these issues.

Reference examples for C#/.NET show "new Struct" when it should be "new <module>Props"
4 participants