Connect to SQS
Connecting an AWS SQS service to a DevZero workspace.
Using the AWS CLI
- Install the AWS CLI into your DevBox.
- Go to AWS Console > IAM > Users > Create user.
- Add the following permissions to the user: AmazonSQSFullAccess.
- After you obtained the credentials, log into the AWS CLI by running:
aws configure
- Update your SQS access policy to allow access to the new user.
- Send a test message to the queue:
aws sqs send-message --queue-url <your-queue-url> --message-body "Hello from your DevBox!"
- Verify you can recieve the messages:
aws sqs receive-message --queue-url <your-queue-url>
VPC-only access policy
Configure the Endpoint
- Follow the Connecting to AWS guide.
- Go to VPC > Endpoints > Create Endpoint.
- Enter a name then select "AWS Services" as your Service category.
- In the "Services" search bar type "SQS" and select the suggested service.
- Under VPC, select your EC2 "relay" VPC.
- Select the desired subnets.
- Select the desired security groups. Make sure that you allow inbound/outbound access to/from your EC2 instance.
- Specify custom VPC endpoint policies, if required.
- Click on "Create endpoint" to proceed.
Apply the policy
Set your SQS-queue policy as follows:
{
"Sid": "VPC-only",
"Effect": "Deny",
"Principal": {
"AWS": "<your-aws-user>"
},
"Action": "SQS:*",
"Resource": "<your-sqs-queue>",
"Condition": {
"StringNotEquals": {
"aws:SourceVpce": "<your-vpce-id>"
}
}
}
Test the policy
Running the following in your DevBox terminal:
aws sqs receive-message --queue-url <your-queue-url>
Will result in:
An error occurred (AccessDenied) when calling the ReceiveMessage operation: User: <your-aws-user> is not authorized to perform: sqs:receivemessage on resource: <your-sqs-queue> with an explicit deny in a resource-based policy
Running the same command with a custom endpoint should result in no errors however:
aws sqs receive-message --queue-url <your-queue-url> --endpoint-url <your-endpoint-url>