Skip to content

Instantly share code, notes, and snippets.

@paresy
Created July 16, 2022 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paresy/5b2b13a0d8f70fa29e62372ab6171e46 to your computer and use it in GitHub Desktop.
Save paresy/5b2b13a0d8f70fa29e62372ab6171e46 to your computer and use it in GitHub Desktop.
(Re-)Enable all AWS SNS endpoints
let aws = require("aws-sdk");
let platformArn = "arn:aws:sns:eu-west-1:*******************";
(async function() {
let sns = new aws.SNS({region: 'eu-west-1'});
let request = {
"PlatformApplicationArn": platformArn
};
let result;
do {
result = await sns.listEndpointsByPlatformApplication(request).promise();
for(let endpoint of result.Endpoints) {
if (endpoint.Attributes.Enabled === 'false') {
console.log(endpoint.EndpointArn);
await sns.setEndpointAttributes({
"EndpointArn": endpoint.EndpointArn,
"Attributes": {
"Enabled": "true"
}
}).promise();
}
}
request.NextToken = result.NextToken;
} while(result.NextToken);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment