Skip to content

Commit

Permalink
feat(aws): ability to lookup sourceAmi via dynamic configs (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
asher committed May 14, 2019
1 parent 6ce4545 commit 6d78af6
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.rosco.providers.aws

import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import com.netflix.spinnaker.rosco.api.Bake
import com.netflix.spinnaker.rosco.api.BakeOptions
import com.netflix.spinnaker.rosco.api.BakeRequest
Expand All @@ -36,6 +37,9 @@ public class AWSBakeHandler extends CloudProviderBakeHandler {
@Autowired
RoscoAWSConfiguration.AWSBakeryDefaults awsBakeryDefaults

@Autowired
DynamicConfigService dynamicConfigService

@Override
def getBakeryDefaults() {
return awsBakeryDefaults
Expand Down Expand Up @@ -87,6 +91,13 @@ public class AWSBakeHandler extends CloudProviderBakeHandler {
awsVirtualizationSettings.sourceAmi = bakeRequest.base_ami
}

// Attempt to lookup baseAmi via dynamicConfigService if unset in the bakeRequest or rosco.yml
// Property name: "aws.base.${bakeRequest.base_os}.${bakeRequest.vm_type}.${bakeRequest.base_label}.$region"
if (!awsVirtualizationSettings.sourceAmi) {
def property = "aws.base.${bakeRequest.base_os}.${bakeRequest.vm_type}.${bakeRequest.base_label}.$region"
awsVirtualizationSettings.sourceAmi = dynamicConfigService.getConfig(String, property, null)
}

return awsVirtualizationSettings
}

Expand Down

0 comments on commit 6d78af6

Please sign in to comment.