Last active
December 12, 2018 15:38
-
-
Save TimoDJatomika/ef9564a0f9cd843f48a335c854417196 to your computer and use it in GitHub Desktop.
Erstellen von drei AWS EC2 Instanzen für den Aufbau eines Hochverfügbaren Vault Clusters
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
#!/bin/bash | |
# author: Timo Stankowitz <timo.stankowitz@inf.h-brs.de> | |
# create date: 2017-11-04 | |
# last change: 2018-12-12 | |
# version 5 | |
# this script creates 3 servers in 3 different AZ's in EU-Central (aka. Frankfurt) | |
# make sure you have the following variables set in your .bashrc or declare it in this script | |
# - AWS_ACCESS_KEY_ID | |
# - AWS_SECRET_ACCESS_KEY | |
# - AWS_DEFAULT_REGION | |
operatingImage="ami-05e7f7fc79cd6ba7e" # Container OS (last checked 2018-12-12) | |
profile="vault-instance-role" # you have to create this by yourself | |
serverType="t2.micro" | |
sshKey="timo_ssh_key" # change to your SSH-Key | |
securityGroupId="sg-c702b7ad" # change to your security Group | |
# subnetID in AZ's (change to your subnet-id) | |
subAZa="subnet-8a9c47e1" # 10.10.1.0/24 | |
subAZb="subnet-73a9b709" # 10.10.2.0/24 | |
subAZc="subnet-1343975e" # 10.10.3.0/24 | |
# create first server in FRA-AZ A | |
aws ec2 run-instances --image-id $operatingImage --instance-type $serverType --iam-instance-profile Name=$profile \ | |
--key-name $sshKey --security-group-ids $securityGroupId \ | |
--subnet-id $subAZa \ | |
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=Server_A},{Key=OS,Value=CoreOS},{Key=Cluster,Value=vault-cluster}]' | |
# second server in FRA-AZ B | |
aws ec2 run-instances --image-id $operatingImage --instance-type $serverType --iam-instance-profile Name=$profile \ | |
--key-name $sshKey --security-group-ids $securityGroupId \ | |
--subnet-id $subAZb \ | |
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=Server_B},{Key=OS,Value=CoreOS},{Key=Cluster,Value=vault-cluster}]' | |
# third server in FRA-AZ C | |
aws ec2 run-instances --image-id $operatingImage --instance-type $serverType --iam-instance-profile Name=$profile \ | |
--key-name $sshKey --security-group-ids $securityGroupId \ | |
--subnet-id $subAZc \ | |
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=Server_C},{Key=OS,Value=CoreOS},{Key=Cluster,Value=vault-cluster}]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment