-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #414 from zalando-stups/coreos
#402 find latest AMI for CoreOS
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
|
||
from senza.components.subnet_auto_configuration import component_subnet_auto_configuration | ||
from senza.utils import ensure_keys | ||
|
||
|
||
def find_coreos_image(release_channel: str, region: str): | ||
'''Find the latest CoreOS AMI''' | ||
|
||
response = requests.get('https://coreos.com/dist/aws/aws-{}.json'.format(release_channel), timeout=5) | ||
response.raise_for_status() | ||
data = response.json() | ||
return data[region]['hvm'] | ||
|
||
|
||
def component_coreos_auto_configuration(definition, configuration, args, info, force, account_info): | ||
ami_id = find_coreos_image(configuration.get('ReleaseChannel') or 'stable', args.region) | ||
configuration = ensure_keys(configuration, "Images", 'LatestCoreOSImage', args.region) | ||
configuration["Images"]['LatestCoreOSImage'][args.region] = ami_id | ||
|
||
component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) | ||
|
||
return definition |
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