It appears to have been an issue with using the wrong App Client ID.
Glad you figured it out.
Fair play bwsolutions! This sorted me out as well. Sign him yāall!!
Hi @dsherida, Iāve got similar error of āTypeError: Cannot read property ā1ā of nullā as per your post. Did you get that resolved? If so , how? Thanks in advance.
Leeten
Hi, I found the mistake (not hard given such a long command). the invoke_url was entered incorrectly. Thanks
Glad you figured it out!
I have the same issue. what is the solution??
Getting temporary credentials
Making API request
{ status: 403,
statusText: āForbiddenā,
also using git bash on windows 10, this also worked for me thanks a lot.
For me it was the policy issue. Try changing the ARN to allow your account or āAny in this accountā and go from there.
This is what worked for me:
āarn:aws:execute-api:YOUR_API_GATEWAY_REGION:YOUR_ACCOUNT:YOUR_API_GATEWAY_ID///*ā
Iāve completed the automated deployments for the backend but Iām getting a 403 when trying to test the dev api. Iām using the following (although Iāve also used my non-custom domain for the invoke-url
- https://bmrv7h8aj6.execute-api.us-east-1.amazonaws.com/dev):
npx aws-api-gateway-cli-test \
--username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='us-east-1_wXqUWFHGo' \
--app-client-id='7qvgoon9vp171hqc2f27t6brn2' \
--cognito-region='us-east-1' \
--identity-pool-id='us-east-1:dfd50f42-0c81-4d10-a531-73ac91657f43' \
--invoke-url='https://api.adiecodes.com/dev' \
--api-gateway-region='us-east-1' \
--path-template='/notes' \
--method='POST' \
--body='{"content":"hello world","attachment":"hello.jpg"}'
npx: installed 110 in 8.923s
Authenticating with User Pool
Getting temporary credentials
Making API request
{
status: 403,
statusText: 'Forbidden',
data: {
Message: 'User: arn:aws:sts::669528630144:assumed-role/dev-notes-infra-cognito-CognitoAuthRoleCognitoDefa-1S5NP9V9QLSR0/CognitoIdentityCredentials is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-east-1:********0144:bmrv7h8aj6/dev/POST/notes'
}
}
Iāve used the policy simulator and it looks like Iām missing the permission to make requests to the API Gateway.
Can anyone she any light on why the services/resources/cognito-policy.yml
isnāt being applied? Itās probably worth noting this was on the root of the project (i.e. outside of services directory) before I deployed via Seed.
You can see my code here
Turns out the policy I had added, cognitive-policy.yml
in my serverless app wasnāt nested in the correct directory. Should have been services/notes/resources, I hadnāt put it within /notes. Thanks for taking the time to help
Hi, while testing the configured apis, Iāve gotten a 500 status code.
npx aws-api-gateway-cli-test \
--username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='us-east-1_f8yMlCnPZ' \
--app-client-id='57dskdenhbn3vtqb4q9daog5uh' \
--cognito-region='us-east-1' \
--identity-pool-id='us-east-1:b4594e5a-8a21-4be4-b546-b895658c19a8' \
--invoke-url='https://jdr09m6hf1.execute-api.us-east-1.amazonaws.com/dev' \
--api-gateway-region='us-east-1' \
--path-template='/notes' \
--method='POST' \
--body='{"content":"hello world","attachment":"hello.jpg"}'
Authenticating with User Pool
Getting temporary credentials
Making API request
{
status: 500,
statusText: 'Internal Server Error',
data: {
error: 'One or more parameter values were invalid: Missing the key userId in the item'
}
}
This is my DynamoDB Stack. I have userId here, so Iām confused why it is missing.
import { CfnOutput } from "@aws-cdk/core";
import * as dynamodb from "@aws-cdk/aws-dynamodb";
import * as sst from "@serverless-stack/resources";
export default class DynamoDBStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
const app = this.node.root;
const table = new dynamodb.Table(this, "Table", {
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, // Use on-demand billing mode
sortKey: { name: "noteId", type: dynamodb.AttributeType.STRING },
partitionKey: { name: "userId", type: dynamodb.AttributeType.STRING },
});
// Output values
new CfnOutput(this, "TableName", {
value: table.tableName,
exportName: app.logicalPrefixedName("TableName"),
});
new CfnOutput(this, "TableArn", {
value: table.tableArn,
exportName: app.logicalPrefixedName("TableArn"),
});
}
}
Make sure there isnāt a typo in your Lambda code.
Absolute respect, thank you for saving me from a headache, I create an account just to write this comment