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
Description: | |
This template deploys a VPC, with a pair of public and private subnets spread | |
across two Availability Zones. It deploys an Internet Gateway, with a default | |
route on the public subnets. It deploys a pair of NAT Gateways (one in each AZ), | |
and default routes for them in the private subnets. | |
The Availability zone information is hard-coded (on purpose) | |
Parameters: | |
EnvironmentName: |
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
root@maishsk-lin:/opt/git/playground/create-vpc/terraform# for i in {1..3}; do echo "starting run $i"; echo "create" ; time terraform apply -auto-approve ; echo "destroy" ; time terraform destroy -auto-approve; done | |
Starting run 1 | |
Create | |
aws_vpc.testvpc: Creating... | |
assign_generated_ipv6_cidr_block: "" => "false" | |
cidr_block: "" => "192.168.90.0/24" | |
default_network_acl_id: "" => "<computed>" | |
default_route_table_id: "" => "<computed>" |
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
root@maishsk-lin:/opt/git/playground/create-vpc/ansible# for i in {1..3}; do echo "starting run $i"; echo "create"; time ansible-playbook create-vpc.yml ; echo "destroy"; time ansible-playbook remove-vpc.yml ; done | |
Starting run 1 | |
Create | |
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source | |
[WARNING]: No inventory was parsed, only implicit localhost is available | |
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' | |
PLAY [VPC creation playbook] ************************************************************************************************************************************************************************************************************* | |
TASK [Create a VPC] ********************************************************************************************************************************************************************************************************************** |
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
root@maishsk-lin:/opt/git/playground/create-vpc/cloudformation# for i in {1..3}; do echo "Starting run $i"; echo "Create"; aws cloudformation create-stack --stack-name testvpc --template-body file://vpc_cloudformation_template.yml; time aws cloudformation wait stack-create-complete --stack-name testvpc --no-paginate; echo "Destroy"; aws cloudformation delete-stack --stack-name testvpc; time aws cloudformation wait stack-delete-complete --stack-name testvpc; done | |
Starting run 1 | |
Create | |
{ | |
"StackId": "arn:aws:cloudformation:us-east-2:138XXXX92836:stack/testvpc/d185d5c0-7305-11e8-8f24-508410100a8d" | |
} | |
31.750 | |
Destroy |
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
resource "aws_vpc" "testvpc" { | |
cidr_block = "${var.vpc_cidr}" | |
enable_dns_hostnames = true | |
tags { | |
Name = "${var.project_name}" | |
} | |
} |
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
- name: VPC creation playbook | |
hosts: localhost | |
connection: local | |
gather_facts: no | |
vars_files: | |
- vars/vpc_vars.yml | |
tasks: | |
- name: Create a VPC |
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
Description: | |
This template deploys a VPC. | |
Parameters: | |
EnvironmentName: | |
Description: An environment name that will be prefixed to resource names | |
Type: String | |
Default: "testvpc" | |
VpcCIDR: |
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
aws ec2 create-vpc --cidr-block 192.168.90.0/24 |
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
blob=`aws kms encrypt --key-id $keyid --plaintext "hello_world" --profile work --query CiphertextBlob --output text` | |
ssmblob=`aws ssm get-parameter --name "encrypted_password" --profile work --with-decryption | jq .Parameter.Value | tr -d '"'` | |
aws kms decrypt --ciphertext-blob fileb://<(echo $ssmblob | base64 -d) --output text --query Plaintext --profile work | base64 -d |
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 | |
## Script will get all AZ info from AWS through awscli | |
## Required: awscli and jq | |
AZINFO=$(for i in $(aws ec2 describe-regions | jq .Regions[].RegionName | tr -d '"') | |
do | |
aws ec2 describe-availability-zones --region $i | jq .AvailabilityZones[].ZoneName | tr -d '"' | |
done | sort) |