如何查找是手动创建SQS队列还是使用CF模板?

时间:2017-01-19 18:20:17

标签: python amazon-web-services aws-cli amazon-cloudformation

我尝试了以下内容,但它没有给我任何CF模板ID或任何允许我查找的说明。

示例:

{
  "Attributes": {
    "ApproximateNumberOfMessagesNotVisible": "0",
    "RedrivePolicy": "{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:80398EXAMPLE:MyDeadLetterQueue\",\"maxReceiveCount\":1000}",
    "MessageRetentionPeriod": "345600",
    "ApproximateNumberOfMessagesDelayed": "0",

 "MaximumMessageSize": "262144",
    "CreatedTimestamp": "1442426968",
    "ApproximateNumberOfMessages": "0",
    "ReceiveMessageWaitTimeSeconds": "0",
    "DelaySeconds": "0",
    "VisibilityTimeout": "30",
    "LastModifiedTimestamp": "1442426968",
    "QueueArn": "arn:aws:sqs:us-east-1:80398EXAMPLE:MyNewQueue"
  }
}

输出

// Data from AJAX response
var errorsJSON = {
    "name-pl": ["The name-pl field is required."],
    "name-en": ["The name-en field is required."]
}

var errorString = $(this).data('validate-multiple');
var errorNamesArray = errorString.split(", ");
var ul = $('<ul class="list-unstyled">');

$.each(errorNamesArray, function(key, value) {
    if (errorsJSON.hasOwnProperty(value)) {
        ul.append(`<li><span class="help-block">${errorsJSON[value]}</span></li>`);
    }
});

if (! $(this).is(':visible') && ul.children('li').length > 0) {
    $(this).find('div.controls').empty().append(ul);
    $(this).slideDown(500);
} else if ($(this).is(':visible') && ul.children('li').length === 0) {
    $(this).slideUp(500);
} else if ($(this).is(':visible') && ul.children('li').length > 0) {
    $(this).slideUp(500, function() {
        $(this).find('div.controls').empty().append(ul);
        $(this).slideDown(500);
    });
}

1 个答案:

答案 0 :(得分:1)

通过将队列URL(Physical ID of an AWS::SQS::Queue Resource)作为PhysicalResourceId参数传递给DescribeStackResources,可以确定SQS队列是否是CloudFormation堆栈的一部分。

使用AWS CLI describe-stack-resources命令,您需要使用--cli-input-json [json_file]传递参数,因为--physical-resource-id参数将在直接提供时尝试解析队列URL。

示例:

aws cloudformation describe-stack-resources --cli-input-json '{"PhysicalResourceId": "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue"}'

如果队列是堆栈的一部分,则将返回堆栈资源的列表。如果没有,则会返回ValidationError