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(cognito-identitypool): providerUrl causes error when mappingKey is not provided and it is a token #21191

Merged
merged 8 commits into from
Jul 30, 2022

Conversation

SamStephens
Copy link
Contributor

This property is for use when the identityProvider is a Token. By default identityProvider is used as the key in the role mapping
hash, but Cloudformation only allows concrete strings to be used as hash keys.

In particular this feature is a requirement to allow a previously defined CDK UserPool to be used as an identityProvider.

closes #19222

Please note that the integ test results will need updating. I attempted to run the tests, and received the error

Error: ENOENT: no such file or directory, open '/home/sam/aws-cdk/packages/aws-cdk/lib/init-templates/v1/info.json'
  ERROR      integ.identitypool 0.535s
      Command exited with status 1

I've used npm to update to the latest CDK CLI. I appear to not be the only person facing this issue; see #21056 (comment)


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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

This property is for use when the identityProvider is a Token.
By default identityProvider is used as the key in the role mapping
hash, but Cloudformation only allows concrete strings to be used
as hash keys.
@gitpod-io
Copy link

gitpod-io bot commented Jul 18, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team July 18, 2022 02:24
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Jul 18, 2022
A couple of missing import statements
I couldn't run them locally, now I've seen them fail the CodeBuild
build I can fix the results based on my changes.
@SamStephens
Copy link
Contributor Author

Build failure doesn't appear to be due to anything I've done; it appears to be in @aws-cdk/aws-appsync, which I haven't touched:

@aws-cdk/aws-appsync: Verifying integration test snapshots...
@aws-cdk/aws-appsync: /codebuild/output/src316876632/src/github.com/aws/aws-cdk/packages/@aws-cdk/aws-appsync/lib/graphqlapi.js:377
@aws-cdk/aws-appsync:             throw Error('API key expiration must be between 1 and 365 days.');
@aws-cdk/aws-appsync:             ^
@aws-cdk/aws-appsync: Error: API key expiration must be between 1 and 365 days.
@aws-cdk/aws-appsync:     at GraphqlApi.createAPIKey (/codebuild/output/src316876632/src/github.com/aws/aws-cdk/packages/@aws-cdk/aws-appsync/lib/graphqlapi.js:377:19)
@aws-cdk/aws-appsync:     at new GraphqlApi (/codebuild/output/src316876632/src/github.com/aws/aws-cdk/packages/@aws-cdk/aws-appsync/lib/graphqlapi.js:189:40)
@aws-cdk/aws-appsync:     at Object.<anonymous> (/codebuild/output/src316876632/src/github.com/aws/aws-cdk/packages/@aws-cdk/aws-appsync/test/integ.auth-apikey.js:23:13)
@aws-cdk/aws-appsync:     at Module._compile (internal/modules/cjs/loader.js:1085:14)
@aws-cdk/aws-appsync:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
@aws-cdk/aws-appsync:     at Module.load (internal/modules/cjs/loader.js:950:32)
@aws-cdk/aws-appsync:     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
@aws-cdk/aws-appsync:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
@aws-cdk/aws-appsync:     at internal/main/run_main_module.js:17:47
@aws-cdk/aws-appsync:   ERROR      integ.auth-apikey 0.5s
@aws-cdk/aws-appsync:       Command exited with status 1

Also, move the documentation of the new feature to a more relevant
part of the README.md.
@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(aws-cognito-identitypool): Add mappingKey to role mapping fix(cognito-identitypool): providerUrl causes error when mappingKey is not provided and it is a token Jul 30, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

I think this is more of a fix than a feat but it's almost perfect as is. Just one suggested change inline.

} else {
const providerUrl = prop.providerUrl.value;
if (Token.isUnresolved(providerUrl)) {
throw new Error('mappingKey must be provided when providerUrl.value is an unresolved token');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new Error('mappingKey must be provided when providerUrl.value is an unresolved token');
throw new Error('mappingKey must be provided when providerUrl.value is a token');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to make this change; that was wording I've copied from other parts of the CDK such as

throw new Error('Unable to determine ARN separator for SSM parameter since the parameter name is an unresolved token. Use "fromAttributes" and specify "simpleName" explicitly');
and
throw new Error(`multiple "${operator}" conditions cannot be merged if one of them contains an unresolved token`);
.

I couldn't decide if this was a fix or a feature; I fell on the side of this being a feature as it does actually provide new functionality, rather than altering existing functionality; it's just that the new feature addresses a gap that was previously present in the CDK's capabilities. Once again, I'm happy to defer to your judgment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I've made the change manually, rather than applying your commit suggestion; that's Github functionality I hadn't seen before.

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review July 30, 2022 03:18

Pull request has been modified.

Update the wording of the error message when providerUrl.value is
a token as per request of @TheRealAmazonKendra
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 5ffb940
  • 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 Jul 30, 2022

Thank you for contributing! Your pull request will be updated from main 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 d91c904 into aws:main Jul 30, 2022
josephedward pushed a commit to josephedward/aws-cdk that referenced this pull request Aug 30, 2022
…s not provided and it is a token (aws#21191)

This property is for use when the identityProvider is a Token. By default identityProvider is used as the key in the role mapping
hash, but Cloudformation only allows concrete strings to be used as hash keys.

In particular this feature is a requirement to allow a previously defined CDK UserPool to be used as an identityProvider.

closes aws#19222

Please note that the integ test results will need updating. I attempted to run the tests, and received the error

```
Error: ENOENT: no such file or directory, open '/home/sam/aws-cdk/packages/aws-cdk/lib/init-templates/v1/info.json'
  ERROR      integ.identitypool 0.535s
      Command exited with status 1
```

I've used `npm` to update to the latest CDK CLI. I appear to not be the only person facing this issue; see aws#21056 (comment)

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(cognito-idp): cannot use Cognito identity pool for role mappings
3 participants