Support authenticationType: API_KEY
I'm attempting to use API_KEY authentication and I can't work out the correct format. Looking at the code it would seem that a userPoolConfig is always required.
appSync:
authenticationType: API_KEY
.request("AppSync", "updateGraphqlApi", {
apiId: resolvedConfig.apiId,
authenticationType: resolvedConfig.authenticationType,
name: resolvedConfig.name,
userPoolConfig: {
awsRegion: resolvedConfig.region,
defaultAction: resolvedConfig.userPoolConfig.defaultAction, // userPoolConfig is null NPE
userPoolId: resolvedConfig.userPoolConfig.userPoolId
}
})
@DaleJefferson API_KEY is not a recommended way to authenticate the GraphQL API but supported by AWS AppSync. We currently only support Cognito User Pool Authentication but can look into supporting API_KEY in coming days. If you are interested, we can work together and add that feature in ;)
I'm using API_KEY while in development. It seems to all work if you make a small change.
.request("AppSync", "updateGraphqlApi", {
apiId: resolvedConfig.apiId,
authenticationType: resolvedConfig.authenticationType,
name: resolvedConfig.name,
userPoolConfig: resolvedConfig.userPoolConfig ? {
awsRegion: resolvedConfig.region,
defaultAction: resolvedConfig.userPoolConfig.defaultAction,
userPoolId: resolvedConfig.userPoolConfig.userPoolId
} : undefined
})
It's not a very robust solution but it's allowing me to continue evaluating serverless-appsync-plugin
Great project btw, if we decide to using this project I would love to contribute 👍
Hey @DaleJefferson thanks for using the plugin. I have started a thread on API_KEY here: https://github.com/sid88in/serverless-appsync-plugin/pull/51 basically the setup should create the key for you. And btw always looking forward to more contributions @DaleJefferson ;)
Ha, just ran into this myself! Thanks @DaleJefferson for quick patch.
Thanks for the API_Key support, appreciated that for development.
For production, we're interested in using an AWS_IAM from our Lambda functions - is there a timeline or road map planned for supporting AWS_IAM as an authenticationType?
@jwondrusch we can create the roadmap together ;) If you are interested we can work together to add it! Maybe you can propose a design and we can review? Feel free to ping me on twitter @sidg_sid
@sid88in Sure, I'll reach out on twitter after the weekend.
API_KEY is awesome for development. I am certainly interested in this feature as well :-)
hey everyone! update/create api key functionality is now available ;) 🎉 Thanks for your inputs! Let me know if anything is missing. @jwondrusch is going to work on adding custom IAM Auth in coming days! stay tuned 🔈
@sid88in, so awesome! Thanks for adding this feature..
This is not completed yet.
Here is one error case:
deploy-appsyncby choosingAMAZON_COGNITO_USER_POOLS- I want to use API_KEY method later, so I've changed some config and did
update-appsyncIt pops up error.
So I've checked the code.
You didn't call createAPIKey() if it has no API_KEY yet when the user update existing AppSync endpoint.
updateAPIKey API is used to change just expiration date of existing API key. so I think you should call createAPIKey API and we don't have to set apiKey in serverless.yml
Pls fix this issue Thanks
Hi, Im also planning to use AWS_IAM for authentication but will use the API_KEY during development.
It appears that if using API_KEY, it still requires a valid definition in serverless.yml for the userPoolConfig. If you remove it, it complains about "Cannot read property 'defaultAction' of undefined"
I'll see if I can provide some guidance on that as well as how to implement IAM so we get that working as well.