Questions tagged with AWS AppSync

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

What value do I insert inside the body of my API request according to this API Specification?

I'm trying to make a data request call from a data exchange API based on the data provider's API specification. My app is built using the Node.JS and NPM. I'm subscribed to use the API and I've verified that all my identity credentials, policies and IAM keys that give me permission to access the API. However when I test the request call in AWS CLI, I get the message '404: Asset not found'. What could be the problem with my API request call? Thanks! My current request code looks like below: ```bash aws dataexchange send-api-asset \ --data-set-id xe4xxxxxxxxxx72b7edxxxx6 \ --revision-id xx54cxxxxxxxx9d05d81xxxxxxxx \ --asset-id xxxxxxbde1fa3d5xxxxe2bb5xx \ --method POST \ --path "/psdm/graphql/" \ --query-string-parameters 'param1=value1,param2=value2' \ --request-headers '{"Content-Type": "application/json"}' \ --body '{"content": { "application/graphql": { "schema": { "$ref": "#/components/schemas/CatalogSearchRequest" }, "value": "{ursa_udp_availablemetadatarecord(limit: 10 content: {catalogProperties: { vendor: { eq: \"ICEYE\" } } } ) { assignedId }}" } }, "required": true }' ``` The Actual API Specification: ```json { "openapi": "3.0.1", "info": { "title": "image-services", "description": "API Gateway for integration of Platform Services into AWS Data Exchange", "version": "2022-03-03T20:04:18Z" }, "servers": [ { "url": "" } ], "paths": { "/psdm/graphql": { "post": { "requestBody": { "description": "GraphQL query for the Catalog in the form of:\n\n `{\n availablemetadatarecord(\n QUERYPARAMS\n ) { \n FIELDLIST\n } \n }`\n", "content": { "application/graphql": { "schema": { "$ref": "#/components/schemas/CatalogSearchRequest" }, "examples": { "Limit returned data": { "description": "Limit the number of records in a response.\n\nIn your query, simply specify `limit: <int>` \n", "value": "{\n availablemetadatarecord(\n limit: 10\n content: { catalogProperties: { vendor: { eq: \"EYE\" } } }\n ) {\n assignedId\n }\n}\n" } } } }, "required": true }, "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CatalogSearchResponse" } } } } }, "security": [ { "sigv4": [] } ] } } }, "components": { "schemas": { "CatalogSearchRequest": { "title": "CatalogSearchRequest", "type": "object" }, "CatalogSearchResponse": { "title": "Catalog Search Response", "required": [ "data", "paginationInfo" ], "type": "object", "properties": { "paginationInfo": { "type": "object", "properties": { "recordsInPage": { "type": "integer" }, "nextOffset": { "type": "integer" } } }, "data": { "type": "object", "properties": { "availablemetadatarecord": { "type": "array", "description": "Records returned by query", "items": { "type": "object" } } } } } } }, "securitySchemes": { "sigv4": { "type": "apiKey", "name": "Authorization", "in": "header", "x-amazon-apigateway-authtype": "awsSigv4" } } } } ```
1
answers
0
votes
34
views
asked a month ago

Calling graphQL mutation from AWS Lambda returning WAFForbiddenException

We are using AppSync and dynamoDB and have a react website. We are trying to trigger a pass through mutation from a Lambda, but are getting WAFForbiddenException. We can call mutations from the website as we have our IP address listed in the WAF. Is there are setting in the WAF to allow access to Appsync from Lambdas? ``` const { HttpRequest, Endpoint, Signers, EnvironmentCredentials, NodeHttpClient, } = AbstractAlertsAwsSdk; ``` ..... ``` async triggerPassThroughMutationForAlert(alert, mutationName) { const p = new Promise((resolve, reject) => { const creds = new EnvironmentCredentials("AWS"); const req = new HttpRequest(this.graphQlEndpoint); req.method = "POST"; req.path = "/graphql"; req.region = "ap-southeast-2"; req.headers["presigned-expires"] = false; req.headers["Host"] = this.graphQlEndpoint.host; req.headers["Content-Type"] = "application/json"; req.body = `${JSON.stringify({ query: `mutation AlertMutation($input: AlertInput!) { ${mutationName}(input: $input) { id tag name outstandingDate } }`, operationName:'AlertMutation', variables: { input: { ...alert }, }, })}` const signer = new Signers.V4(req, "appsync", true); signer.addAuthorization(creds, new Date()); const client = new NodeHttpClient(); client.handleRequest(req, null, function (httpResp) { let body = ""; httpResp.on("data", function (chunk) { body += chunk; }); httpResp.on("end", function (chunk) { console.info(alert.reference, "triggerPassThroughMutationForAlert() Successful", chunk !== null && chunk !== void 0 ? chunk : "", body); resolve(); }); }, function (err) { console.log("triggerPassThroughMutationForAlert() Error: " + err); resolve(); }); }); return p; } } ``` Obviously, i can turn off the default rule in the WAF to block all, but then i would let everyone in. Given i am already in AWS, and have a VPC set up, how do i call it directly without going out to the internet first.
0
answers
0
votes
22
views
asked a month ago