These scripts are used for the "Deploy to AWS with Ansible and Terraform" course on Linux Academy.
$ apt update
$ apt install python2.7
$ python --version
$ apt install python-pip
$ pip install --upgrade pip
$ curl -O https://releases.hashicorp.com/terraform/0.11.8/terraform_0.11.8_linux_amd64.zip
$ apt-get install unzip
$ mkdir /bin/terraform
$ unzip terraform_0.11.8_linux_amd64.zip -d /usr/local/bin/
$ terraform --version
$ python -m pip install awscli --upgrade
$ aws --version
$ apt-get update
$ apt-get install software-properties-common
$ apt-add-repository ppa:ansible/ansible
$ apt-get update
$ apt-get install ansible
$ ansible --version
$ vi /etc/ansible/ansible.cfg
Uncomment "host_key_checking = False"
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/kryptonite
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/kryptonite.
Your public key has been saved in /root/.ssh/kryptonite.pub.
The key fingerprint is:
SHA256:D6zbO5EZcw9p1uf64OyR/Ulg4La/Cw4oiVNtsZMRHLo [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
| |
| |
| |
| |
| |
+----[SHA256]-----+
$ ssh-agent bash
$ ssh-add /root/.ssh/kryptonite
Identity added: /root/.ssh/kryptonite (/root/.ssh/kryptonite)
$ ssh-add -l
2048 SHA256:******************************* /root/.ssh/kryptonite (RSA)
- Login to Aws Console
- Got To IAM Service
- Add user (Access Type = Programmatic access)
- Click on Attach existing policies directly and Administrator Access
- Download .csv file with Access Key Id and Secret Access Key
Use the credentials in .csv file Should configure default region
$ aws configure --profile superhero
# To Test
$ aws ec2 describe-instances --profile superhero --region us-east-1
Execute the command and store ID Value
$ aws route53 create-reusable-delegation-set --caller-reference 1224 --profile superhero
{
"Location": "https://route53.amazonaws.com/2013-04-01/delegationset/*********",
"DelegationSet": {
"NameServers": [
"*************",
"*************",
"*************",
"*************",
],
"CallerReference": "1224",
"Id": "/delegationset/<ID>"
}
}
- Clone project
- Edit terraform.tfvars and change the vars. (It's mandatory change local ip and delegation_set. Should use delegation obtained in prior step)
- Execute terraform int
- Execute terraform apply
- Execute terraform destroy