use of com.amazonaws.services.cloudformation.model.Output in project pipeline-aws-plugin by jenkinsci.
the class CloudFormationStack method describeOutputs.
public Map<String, String> describeOutputs() {
DescribeStacksResult result = this.client.describeStacks(new DescribeStacksRequest().withStackName(this.stack));
Stack cfnStack = result.getStacks().get(0);
Map<String, String> map = new HashMap<>();
for (Output output : cfnStack.getOutputs()) {
map.put(output.getOutputKey(), output.getOutputValue());
}
return map;
}
use of com.amazonaws.services.cloudformation.model.Output in project cloudbreak by hortonworks.
the class AwsResourceConnector method getOutputs.
private Map<String, String> getOutputs(String cFStackName, AmazonCloudFormation client) {
DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest().withStackName(cFStackName);
String outputNotFound = String.format("Couldn't get Cloudformation stack's('%s') output", cFStackName);
List<Output> cfStackOutputs = client.describeStacks(describeStacksRequest).getStacks().stream().findFirst().orElseThrow(getCloudConnectorExceptionSupplier(outputNotFound)).getOutputs();
return cfStackOutputs.stream().collect(Collectors.toMap(Output::getOutputKey, Output::getOutputValue));
}
use of com.amazonaws.services.cloudformation.model.Output in project cloudbreak by hortonworks.
the class AwsCreateVpcNetworkTest method createNetwork.
@Test
@Parameters({ "networkName", "description", "publicInAccount", "regionName", "vpcStackName", "vpcName", "existingSubnet" })
public void createNetwork(String networkName, @Optional("") String description, @Optional("false") boolean publicInAccount, String regionName, @Optional("it-vpc-stack") String vpcStackName, @Optional("it-vpc") String vpcName, boolean existingSubnet) {
AmazonCloudFormationClient client = new AmazonCloudFormationClient();
client.setRegion(RegionUtils.getRegion(regionName));
Map<String, Object> networkMap = new HashMap<>();
String vpcCreationJson = existingSubnet ? "public_vpc_with_subnet.json" : "public_vpc_wihout_subnet.json";
try (InputStream vpcJsonInputStream = getClass().getResourceAsStream("/cloudformation/" + vpcCreationJson)) {
String vpcCFTemplateString = IOUtils.toString(vpcJsonInputStream);
CreateStackRequest stackRequest = createStackRequest(vpcStackName, vpcName, vpcCFTemplateString);
client.createStack(stackRequest);
List<Output> outputForRequest = getOutputForRequest(vpcStackName, client);
if (existingSubnet) {
networkMap.put("vpcId", outputForRequest.get(0).getOutputValue());
networkMap.put("subnetId", outputForRequest.get(1).getOutputValue());
} else {
networkMap.put("vpcId", outputForRequest.get(1).getOutputValue());
networkMap.put("internetGatewayId", outputForRequest.get(0).getOutputValue());
}
} catch (IOException e) {
LOGGER.error("can't read vpc cloudformation template file");
throw new RuntimeException(e);
}
NetworkRequest networkRequest = new NetworkRequest();
networkRequest.setName(networkName);
networkRequest.setDescription(description);
networkRequest.setParameters(networkMap);
if (!existingSubnet) {
networkRequest.setSubnetCIDR("10.0.0.0/24");
}
networkRequest.setCloudPlatform("AWS");
String id = getCloudbreakClient().networkEndpoint().postPrivate(networkRequest).getId().toString();
getItContext().putContextParam(CloudbreakITContextConstants.NETWORK_ID, id, true);
}
Aggregations