Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions MissingPagination.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,5 @@
import java.util.Map;

public class MissingPagination {
private static CFNHelperSingleton instance = new CFNHelperSingleton();
private Map<String, AmazonCloudFormation> cfnPerRegionMap = new HashMap<>();

private CFNHelperSingleton() {
}

public static CFNHelperSingleton getInstance() {
return instance;
}

private AmazonCloudFormation getCfnClient(String region) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Single comment demo 1

return cfnPerRegionMap.computeIfAbsent(region, k -> AmazonCloudFormationClientBuilder.standard()
.withCredentials(new DefaultAWSCredentialsProviderChain())
.withRegion(region).build());
}

public Map<String, Object> getExistingStackParameters(String stackName, String region) throws IOException {
AmazonCloudFormation client = getCfnClient(region);
try {
GetTemplateResult result = client.getTemplate(new GetTemplateRequest().withStackName(stackName));
String template = result.getTemplateBody();
Copy link
Owner Author

Choose a reason for hiding this comment

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

single comment demo 2

return new ObjectMapper(new YAMLFactory()).readValue(template, Map.class);
} catch (AmazonCloudFormationException e) {
if (e.getMessage().contains("does not exist")) {
return null;
} else {
throw e;
}
}
}

public List<StackSummary> listStacks(String region) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

single comment demo 3

AmazonCloudFormation client = getCfnClient(region);
ListStacksResult result = client.listStacks();
return result.getStackSummaries();
}
}