Created
July 16, 2022 20:20
-
-
Save paresy/5b2b13a0d8f70fa29e62372ab6171e46 to your computer and use it in GitHub Desktop.
(Re-)Enable all AWS SNS endpoints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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