Skip to content

Commit

Permalink
Merge pull request #450 from joesondow/default-vpc-id-getter
Browse files Browse the repository at this point in the history
Expose method to get default VPC ID
  • Loading branch information
joesondow committed Jan 2, 2014
2 parents bea6238 + 5ce747a commit c6b151a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion grails-app/services/com/netflix/asgard/AwsEc2Service.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,20 @@ class AwsEc2Service implements CacheInitializer, InitializingBean {
* @return list of identifiers for subnets in default VPC, or empty list if no default VPC exists
*/
List<String> getDefaultVpcSubnetIds(UserContext userContext) {
String defaultVpcId = getVpcs(userContext).find { it.isDefault }?.vpcId
String defaultVpcId = getDefaultVpcId(userContext)
defaultVpcId ? getSubnets(userContext).findSubnetsByVpc(defaultVpcId).subnetIds : []
}

/**
* Gets the default VPC ID if available.
*
* @param userContext who, where, why
* @return the identifier of the default VPC, if available, or null if there is no default VPC
*/
String getDefaultVpcId(UserContext userContext) {
getVpcs(userContext).find { it.isDefault }?.vpcId
}

private Collection<Vpc> retrieveVpcs(Region region) {
awsClient.by(region).describeVpcs().vpcs
}
Expand Down

0 comments on commit c6b151a

Please sign in to comment.