Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | 1x 308x 308x 1x 1x 1x 1x 1x 308x 1x 1x 1x 31x 29x 31x 60x 29x 1x 1x 1x 1x 1x 1x 1x 1x 8x 1x 8x 8x 8x 8x 8x 8x 1x 9x 9x 9x 9x 1x 1x 8x 1x 1x 8x 1x 1x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 2x 8x 8x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 2x 2x 2x 1x | "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { Eif (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { Iif (mod && mod.__esModule) return mod; var result = {}; Eif (mod != null) for (var k in mod) Eif (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.configureTags = exports.setAttributes = exports.getAttributes = exports.getQueue = exports.getDefaults = exports.getUrl = exports.getArn = exports.getAccountId = exports.deleteQueue = exports.createQueue = void 0; const ramda_1 = require("ramda"); const aws_sdk_1 = __importDefault(require("aws-sdk")); const _ = __importStar(require("lodash")); const getDefaults = ({ defaults }) => { return ramda_1.clone(defaults); }; exports.getDefaults = getDefaults; const getQueue = ({ sqs, queueUrl }) => __awaiter(void 0, void 0, void 0, function* () { let queueAttributes = {}; try { const response = yield sqs .getQueueAttributes({ QueueUrl: queueUrl }) .promise(); queueAttributes = response.Attributes; } catch (error) { if (error.code !== "AWS.SimpleQueueService.NonExistentQueue") { throw error; } } return queueAttributes; }); exports.getQueue = getQueue; const getAccountId = () => __awaiter(void 0, void 0, void 0, function* () { const STS = new aws_sdk_1.default.STS(); const res = yield STS.getCallerIdentity({}).promise(); return res.Account; }); exports.getAccountId = getAccountId; const getUrl = ({ name, region, accountId }) => { return `https://sqs.${region}.amazonaws.com/${accountId}/${name}`; }; exports.getUrl = getUrl; const getArn = ({ name, region, accountId }) => { return `arn:aws:sqs:${region}:${accountId}:${name}`; }; exports.getArn = getArn; const createAttributeMap = (config) => { const attributeMap = {}; Iif (typeof config.visibilityTimeout !== "undefined") attributeMap.VisibilityTimeout = config.visibilityTimeout.toString(); Iif (typeof config.maximumMessageSize !== "undefined") attributeMap.MaximumMessageSize = config.maximumMessageSize.toString(); Iif (typeof config.messageRetentionPeriod !== "undefined") attributeMap.MessageRetentionPeriod = config.messageRetentionPeriod.toString(); Iif (typeof config.delaySeconds !== "undefined") attributeMap.DelaySeconds = config.delaySeconds.toString(); Iif (typeof config.receiveMessageWaitTimeSeconds !== "undefined") attributeMap.ReceiveMessageWaitTimeSeconds = config.receiveMessageWaitTimeSeconds.toString(); Iif (typeof config.redrivePolicy !== "undefined") attributeMap.RedrivePolicy = JSON.stringify(config.redrivePolicy) || ""; Iif (typeof config.policy !== "undefined") attributeMap.Policy = JSON.stringify(config.policy) || ""; Iif (typeof config.kmsMasterKeyId !== "undefined") attributeMap.KmsMasterKeyId = JSON.stringify(config.kmsMasterKeyId) || ""; Iif (typeof config.kmsDataKeyReusePeriodSeconds !== "undefined") attributeMap.KmsDataKeyReusePeriodSeconds = JSON.stringify(config.kmsDataKeyReusePeriodSeconds) || "300"; Iif (config.fifoQueue) { if (typeof config.deduplicationScope !== "undefined") { attributeMap.DeduplicationScope = config.deduplicationScope.toString(); } if (typeof config.fifoThroughputLimit !== "undefined") { attributeMap.FifoThroughputLimit = config.fifoThroughputLimit.toString(); } if (typeof config.kmsDataKeyReusePeriodSeconds !== "undefined") { attributeMap.ContentBasedDeduplication = JSON.stringify(config.contentBasedDeduplication) || "false"; } } return attributeMap; }; const createQueue = ({ sqs, config }) => __awaiter(void 0, void 0, void 0, function* () { const params = { QueueName: config.name, Attributes: createAttributeMap(config), tags: undefined }; Iif (config.fifoQueue) { params.Attributes.FifoQueue = "true"; } if (config.tags) { params.tags = config.tags; } const { QueueUrl: url } = yield sqs .createQueue(params) .promise(); return { url }; }); exports.createQueue = createQueue; const getAttributes = (sqs, queueUrl) => __awaiter(void 0, void 0, void 0, function* () { const params = { QueueUrl: queueUrl, AttributeNames: ["All"] }; const { Attributes: queueAttributes } = yield sqs .getQueueAttributes(params) .promise(); return queueAttributes; }); exports.getAttributes = getAttributes; const setAttributes = (sqs, queueUrl, config) => __awaiter(void 0, void 0, void 0, function* () { const params = { QueueUrl: queueUrl, Attributes: createAttributeMap(config) }; yield sqs.setQueueAttributes(params).promise(); }); exports.setAttributes = setAttributes; const configureTags = (context, sqs, queueUrl, inputTags) => __awaiter(void 0, void 0, void 0, function* () { const currentTags = {}; context.debug("Trying to get existing tags."); const data = yield sqs.listQueueTags({ QueueUrl: queueUrl }).promise(); Eif (data.Tags) { Object.keys(data.Tags).forEach((key) => { currentTags[key] = data.Tags[key]; }); } if (!_.isEqual(inputTags, currentTags)) { context.debug("Tags have changed. Updating tags."); yield sqs .untagQueue({ QueueUrl: queueUrl, TagKeys: Object.keys(inputTags) }) .promise(); yield sqs .tagQueue({ QueueUrl: queueUrl, Tags: inputTags }) .promise(); } else { context.debug("Tags are the same as before, not doing anything."); } }); exports.configureTags = configureTags; const deleteQueue = ({ sqs, queueUrl }) => __awaiter(void 0, void 0, void 0, function* () { try { yield sqs.deleteQueue({ QueueUrl: queueUrl }).promise(); } catch (error) { if (error.code !== "AWS.SimpleQueueService.NonExistentQueue") { throw error; } } }); exports.deleteQueue = deleteQueue; |