Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Currently when I configure both a REST api and an appsync API (using AWS_IAM authentication) through amplify I'm receiving a 403 error. When enabling logging on appsync the error type is: ErrorType=InvalidSignatureException.
When I configure appsync through amplify using the authentication type AWS_IAM using these three properties the appsync API works properly:
aws_appsync_graphqlEndpoint: <endpoint url>,
aws_appsync_region: <region>,
aws_appsync_authenticationType: 'AWS_IAM'
If I add a REST endpoint to the configuration - I receive an error when I attempt to use graphql via appsync I receive an error "No graphql endpoint provided.":
API: {
endpoints: [
{
name: <name>,
endpoint: <api gateway endpoint>
}
]
},
Auth: {
.....
},
aws_appsync_graphqlEndpoint: <endpoint url>,
aws_appsync_region: <region>,
aws_appsync_authenticationType: 'AWS_IAM'
I then added appsync / graphql configuration within the API endpoints section of config and I receive the 403 error (InvalidSignatureException):
API: {
endpoints: [
{
name: <name>,
endpoint: <api gateway url>
}
],
graphql_endpoint: <endpoint url>,
graphql_endpoint_iam_region: <region>
},
Auth: {
.....
}
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.
What is the expected behavior?
I expect to be able to use appsync with AWS_IAM authentication alongside an API gateway exposed REST API through amplify.
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
aws-amplify 1.0.2
aws-amplify-angular 1.0.1
Google Chrome: 67.0.3396.99 (Official Build) (32-bit)
Windows 10
I reviewed the source code for amplify for the API package. I tried the following configuration and it seems to be working - but I believe that either the documentation or the code should be updated as I believe it is intended to work with the configuration I showed above in the bug I filed.
API: {
endpoints: [
{
name:
endpoint:
}
],
aws_appsync_graphqlEndpoint:
aws_appsync_region:
aws_appsync_authenticationType: 'AWS_IAM'
}
Auth: {
....
}
Hi @dankuchler
I am glad you got it working, I am labeling this issue as * documentation* so we can better explain this in the docs
With the configuration specified by @dankuchler subscriptions will not work.
See https://aws-amplify.github.io/amplify-js/media/api_guide.html#subscriptions
When using AWS AppSync subscriptions, be sure that your AppSync configuration is at the root of the configuration object, instead of being under API
I got the same issue with AMAZON_COGNITO_USER_POOLS as authentication method for AppSync.
If I remove REST API configuration then AppSync could work. However if I add it back I got "No graphql endpoint provided."
// appSync settings, extracted from the downloaded setting file
"aws_appsync_graphqlEndpoint": "https://my-appsync-end-point.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
API: {
endpoints: [{
name: "CampaignPublicGet",
endpoint: "https://my-rest-end-point.execute-api.us-east-1.amazonaws.com/stage"
}],
},
Hi everybody,
I had the same problem described above, and I managed to solve id by moving the appsync configuration ("aws_appsync_graphqlEndpoint", "aws_appsync_region", "aws_appsync_authenticationType", ecc) inside the "API" object.
Seems like if you've got no API endpoints, you can place the appsync data at root level, but if you have some endpoint, you have to put everything inside the "API" object.
So now my configuration looks like this:
```javascript
{
...,
Auth: {
identityPoolId: 'eu-west-1:xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx',
region: 'eu-west-1',
userPoolId: 'eu-west-1_xxxxxxx',
userPoolWebClientId: 'xxxxxxxxxxxxxxxxxx',
},
API: {
endpoints: [
{
name: 'MyFunction',
endpoint: 'https://lambda.eu-west-1.amazonaws.com/2015-03-31/functions/MyFunction/invocations',
service: 'lambda',
region: 'eu-west-1',
},
],
aws_appsync_graphqlEndpoint: 'https://xxxxxxxxxxxxxxxxxxxxxxx.appsync-api.eu-west-1.amazonaws.com/graphql',
aws_appsync_region: 'eu-west-1',
aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS',
aws_appsync_apiKey: 'null',
},
...
}
`
I was having the same problem, this solved it for me.
import awsconfig from './src/aws-exports';
import Amplify from 'aws-amplify';
Amplify.configure(awsconfig)
Most helpful comment
Hi everybody,
I had the same problem described above, and I managed to solve id by moving the appsync configuration ("aws_appsync_graphqlEndpoint", "aws_appsync_region", "aws_appsync_authenticationType", ecc) inside the "API" object.
Seems like if you've got no API endpoints, you can place the appsync data at root level, but if you have some endpoint, you have to put everything inside the "API" object.
So now my configuration looks like this:
```javascript
{
...,
}
`