Created
April 7, 2018 20:33
-
-
Save epequeno/10f0346109230cd5fa50c6083f35d74d to your computer and use it in GitHub Desktop.
creates instances for use with https://github.com/Praqma/LearnKubernetes/blob/master/kamran/Kubernetes-The-Hard-Way-on-AWS.md
This file contains hidden or 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
"""create instances for | |
https://github.com/Praqma/LearnKubernetes/blob/master/kamran/Kubernetes-The-Hard-Way-on-AWS.md""" | |
# stdlib | |
import logging | |
# 3rd party | |
import boto3 | |
#local | |
ec2 = boto3.client('ec2', region_name='us-east-1') | |
instances = {'etcd1': '10.0.0.245', | |
'etcd2': '10.0.0.246', | |
'controller1': '10.0.0.137' | |
'controller2': '10.0.0.138' | |
'worker1': '10.0.0.181' | |
'worker2': '10.0.0.182'} | |
for instance_name in instances: | |
name = f'k8sthw-{instance_name}' | |
ec2.run_instances(ImageId='ami-b81dbfc5', | |
MaxCount=1, | |
MinCount=1, | |
InstanceType='t2.micro', | |
KeyName='k8sthw-key', | |
NetworkInterfaces=[ | |
{'AssociatePublicIpAddress': True, | |
'Groups': ['sg-04db214d'], | |
'DeviceIndex': 0, | |
'DeleteOnTermination': True, | |
'PrivateIpAddress': instances[instance_name], | |
'SubnetId': 'subnet-9cdde0a3'} | |
], | |
TagSpecifications=[ | |
{'ResourceType': 'instance', | |
'Tags': [ | |
{'Key': 'Name', | |
'Value': name} | |
]} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment