Amazon Web Services
From Luis Gallego Hurtado - Not Another IT guy
Amazon Web Services (AWS)
Troubleshooting
Amazon Cloudwatch Logs Insights
See below some very basic query examples regarding analyzing log data with Cloudwatch Logs Insights:
fields @timestamp, message.body.name
| filter message.uri like "/v2/event/custom" and message.body.name like "Any name"
| sort @timestamp desc
| limit 20
fields @timestamp, @message
| filter @logStream = "svc-markets/svc-markets/d9b5df0e43c24fd1be651ea965a748df" and level = 50
| sort @timestamp desc
| limit 20
Testing
Using Localstack
Read this good cheetsheet about Localstack
Using aws client
Create account profile
You will need an AWS Access Key ID and an AWS Secret Access Key:
aws --profile protec configure
Retrieve all users from a Cognito User Pool
aws --profile protec cognito-idp list-users --user-pool-id <USER_POOL_ID>
Amazon Simple Queue Service (SQS)
Send Message
- Without message-group id:
aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url http://localstack:4566/queue/<QUEUE_NAME> --region us-east-1 --message-body 'Test Message!'
- With message-group id:
aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url http://localstack:4566/queue/<QUEUE_NAME> --region us-east-1 --message-group-id <message-group-id> --message-body 'Test Message!'
Receive Message
aws sqs receive-message --queue-url https://sqs.eu-west-1.amazonaws.com/111964576194/<QUEUE_NAME> --region eu-west-1 --wait-time-seconds 999
Amazon Simple Notification Service(SNS)
Subscribe to a topic
- Subscribe to topic by email. In order to receive an email every time a notification message is received.
aws --endpoint-url=http://localhost:4566 sns subscribe --topic-arn arn:aws:sns:us-east-1:000000000000:<TOPIC_NAME> --region us-east-1 --protocol email --notification-endpoint <email-address>
- Subscribe to topic by providing an https/http endpoint, in order to receive requests in provided endpoint every time a notification message is received. For testing purposes, I strongly recommend to setup the mocked URL with Pipedream
aws --endpoint-url=http://localhost:4566 sns subscribe --topic-arn arn:aws:sns:us-east-1:000000000000:<TOPIC_NAME> --region us-east-1 --protocol https --notification-endpoint <URL>
Confirm subscription
Subscriptions must be confirmed, so initial message will contain a confirmation token that must be sent to AWS in order to enable subscription.
aws sns confirm-subscription --endpoint-url http://localhost:4566 --topic-arn "arn:aws:sns:us-east-1:000000000000:<TOPIC_NAME>" --region us-east-1 --token <confirmation-token>