Skip to content

Conversation

bwagner5
Copy link
Contributor

@bwagner5 bwagner5 commented Jun 4, 2021

Issue #, if available:
N/A

Description of changes:

  • The sqs queue creation command isn't quite right in the readme. The policy needs to be on a single line.

BEFORE:

$ QUEUE_POLICY=$(cat <<EOF
{
    "Version": "2012-10-17",
    "Id": "MyQueuePolicy",
    "Statement": [{
        "Effect": "Allow",
        "Principal": {
            "Service": ["events.amazonaws.com", "sqs.amazonaws.com"]
        },
        "Action": "sqs:SendMessage",
        "Resource": [
            "arn:aws:sqs:${AWS_REGION}:${ACCOUNT_ID}:${SQS_QUEUE_NAME}"
        ]
    }]
}
EOF
)

$ cat << EOF > /tmp/queue-attributes.json
{
  "MessageRetentionPeriod": "300",
  "Policy": "$(echo $QUEUE_POLICY | sed 's/\"/\\"/g')"
}
EOF

$ cat /tmp/queue-attributes.json
{
  "MessageRetentionPeriod": "300",
  "Policy": "{
    \"Version\": \"2012-10-17\",
    \"Id\": \"MyQueuePolicy\",
    \"Statement\": [{
        \"Effect\": \"Allow\",
        \"Principal\": {
            \"Service\": [\"events.amazonaws.com\", \"sqs.amazonaws.com\"]
        },
        \"Action\": \"sqs:SendMessage\",
        \"Resource\": [
            \"arn:aws:sqs:us-east-2::\"
        ]
    }]
}"
}

AFTER:

$ QUEUE_POLICY=$(cat <<EOF
{
    "Version": "2012-10-17",
    "Id": "MyQueuePolicy",
    "Statement": [{
        "Effect": "Allow",
        "Principal": {
            "Service": ["events.amazonaws.com", "sqs.amazonaws.com"]
        },
        "Action": "sqs:SendMessage",
        "Resource": [
            "arn:aws:sqs:${AWS_REGION}:${ACCOUNT_ID}:${SQS_QUEUE_NAME}"
        ]
    }]
}
EOF
)

$ cat << EOF > /tmp/queue-attributes.json
{
  "MessageRetentionPeriod": "300",
  "Policy": "$(echo $QUEUE_POLICY | sed 's/\"/\\"/g' | tr -d -s '\n' " ")"
}
EOF

$ cat /tmp/queue-attributes.json
{
  "MessageRetentionPeriod": "300",
  "Policy": "{ \"Version\": \"2012-10-17\", \"Id\": \"MyQueuePolicy\", \"Statement\": [{ \"Effect\": \"Allow\", \"Principal\": { \"Service\": [\"events.amazonaws.com\", \"sqs.amazonaws.com\"] }, \"Action\": \"sqs:SendMessage\", \"Resource\": [ \"arn:aws:sqs:us-east-2::\" ] }]}"
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bwagner5 bwagner5 requested a review from haugenj June 4, 2021 19:07
Copy link
Contributor

@haugenj haugenj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bwagner5 bwagner5 merged commit dd82bb0 into aws:main Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants