-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replaces the configure shell script with AWS SDK #50
Open
aaronwalker
wants to merge
8
commits into
master
Choose a base branch
from
ciinabox_vpc_params
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+88
−4
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9365df5
looks up the ciinabox cloudformation stack output params and write th…
aaronwalker fdb2691
adds support for baking AMIs in a different AZ
aaronwalker 315b686
fixes
aaronwalker ac91d4e
fixes
aaronwalker 352b31c
allows overridimg an instance_type to test kitchen
aaronwalker f55b42e
use chef bundle
Guslington 9b08b51
Merge pull request #62 from Guslington/feature/chefbundle
Guslington 741f3d5
new chefdk doesnt include rspec_junit_formatter
Guslington File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*********************************** | ||
ciinabox VPC | ||
|
||
Lookups the output Params from the ciinabox vpc and writes them to a | ||
json file in the workspace called base_params.json | ||
|
||
example usage | ||
ciinaboxVPC( | ||
ciinabox: 'ciinabox', | ||
region: env.REGION, | ||
availabilityZone: 'a' | ||
) | ||
the optional az attribute allows you to override which availability zone is returned | ||
************************************/ | ||
@Grab(group='com.amazonaws', module='aws-java-sdk-cloudformation', version='1.11.359') | ||
|
||
import com.amazonaws.services.cloudformation.* | ||
import com.amazonaws.services.cloudformation.model.* | ||
|
||
def call(body) { | ||
def config = body | ||
|
||
def az = config.get('availabilityZone', 'a').toUpperCase() | ||
def ciinaboxName = config.get('ciinabox', 'ciinabox') | ||
def ciinabox = ciinaboxStack(ciinaboxName, config.region) | ||
if(ciinabox) { | ||
def outputs = [:] | ||
ciinabox.outputs.each { output -> | ||
outputs[output.outputKey] = output.outputValue | ||
} | ||
println "ciinabox outputs:${outputs}" | ||
def paramsFile = config.get('outputFile','base_params.json') | ||
def exist = fileExists(paramsFile) | ||
if(exist) { | ||
new File(paramsFile).delete() | ||
} | ||
writeFile file: paramsFile, text: toJson(outputs, az) | ||
} else { | ||
throw new RuntimeException("no ciinabox stack ${ciinabox} found") | ||
} | ||
|
||
} | ||
|
||
@NonCPS | ||
def ciinaboxStack(stackName, region) { | ||
try { | ||
def cf = setupClient(region) | ||
DescribeStacksResult result = cf.describeStacks(new DescribeStacksRequest().withStackName(stackName)) | ||
return result.getStacks().get(0) | ||
} catch (AmazonCloudFormationException ex) { | ||
if(ex.message.contains("does not exist")) { | ||
return null | ||
} else { | ||
throw ex | ||
} | ||
} | ||
} | ||
|
||
@NonCPS | ||
def toJson(outputs, az) { | ||
subnet = "ECSPrivateSubnet${az}" | ||
def json_text = """{ | ||
"region": "${outputs['Region']}", | ||
"vpc_id": "${outputs['VPCId']}", | ||
"subnet_id": "${outputs[subnet]}", | ||
"security_group": "${outputs['SecurityGroup']}", | ||
"packer_role": "${outputs['ECSRole']}", | ||
"packer_instance_profile": "${outputs['ECSInstanceProfile']}" | ||
}""" | ||
return json_text | ||
} | ||
|
||
@NonCPS | ||
def setupClient(region) { | ||
def cb = AmazonCloudFormationClientBuilder.standard().withRegion(region) | ||
return cb.build() | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if this this is a null value? Would this be better off being added to the bakery script with the rest of the options?