Terraform code for AWS Ec2 instance creation

Sample Terraform Code:

provider "aws" {
  region = "us-east-1"
access_key = "xxxxxxxxxxxxxxFQQ"
secret_key = "fmxxxxxxxxxxxxxxxxxxxxx1JuV"
}
data "aws_ami" "ubuntu" {
  most_recent = true
  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }
  owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web" {
  ami           = "${data.aws_ami.ubuntu.id}"
  instance_type = "t2.micro"
key_name = "newkeyaug2017"
  tags {
    Name = "HelloWorld"
  }
}





C:\Users\sjaganathan\Documents\terraform-aws>terraform.exe validate

C:\Users\sjaganathan\Documents\terraform-aws>terraform.exe plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_ami.ubuntu: Refreshing state...
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_instance.web
    ami:                         "ami-7dce6507"
    associate_public_ip_address: ""
    availability_zone:           ""
    ebs_block_device.#:          ""
    ephemeral_block_device.#:    ""
    instance_state:              ""
    instance_type:               "t2.micro"
    ipv6_addresses.#:            ""
    key_name:                    "newkeyaug2017"
    network_interface_id:        ""
    placement_group:             ""
    private_dns:                 ""
    private_ip:                  ""
    public_dns:                  ""
    public_ip:                   ""
    root_block_device.#:         ""
    security_groups.#:           ""
    source_dest_check:           "true"
    subnet_id:                   ""
    tags.%:                      "1"
    tags.Name:                   "HelloWorld"
    tenancy:                     ""
    vpc_security_group_ids.#:    ""


Plan: 1 to add, 0 to change, 0 to destroy.

C:\Users\sjaganathan\Documents\terraform-aws>terraform.exe apply
data.aws_ami.ubuntu: Refreshing state...
aws_instance.web: Creating...
  ami:                         "" => "ami-7dce6507"
  associate_public_ip_address: "" => ""
  availability_zone:           "" => ""
  ebs_block_device.#:          "" => ""
  ephemeral_block_device.#:    "" => ""
  instance_state:              "" => ""
  instance_type:               "" => "t2.micro"
  ipv6_addresses.#:            "" => ""
  key_name:                    "" => "newkeyaug2017"
  network_interface_id:        "" => ""
  placement_group:             "" => ""
  private_dns:                 "" => ""
  private_ip:                  "" => ""
  public_dns:                  "" => ""
  public_ip:                   "" => ""
  root_block_device.#:         "" => ""
  security_groups.#:           "" => ""
  source_dest_check:           "" => "true"
  subnet_id:                   "" => ""
  tags.%:                      "" => "1"
  tags.Name:                   "" => "HelloWorld"
  tenancy:                     "" => ""
  vpc_security_group_ids.#:    "" => ""
aws_instance.web: Still creating... (10s elapsed)
aws_instance.web: Creation complete (ID: i-00a8c11897b8f9532)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path:

C:\Users\sjaganathan\Documents\terraform-aws>

Vault UI docker container installation and errors


[root@ip-172-31-39-86 vault-ui]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
                              8fa3fd9b95f7        8 hours ago         68.63 MB
djenriquez/vault-ui   latest              09077b84b73c        21 hours ago        78.61 MB
vault                 latest              6f550e834e5a        2 days ago          80.51 MB
tomcat                latest              1269f3761db5        2 weeks ago         560.2 MB
node                  8.6-alpine          b7e15c83cdaf        4 weeks ago         67.18 MB
[root@ip-172-31-39-86 vault-ui]# ./run-docker-compose-dev
------------- yarn install -------------
./run-docker-compose-dev: line 3: yarn: command not found
------------- docker-compose up -d -------------
Building webpack
Step 1 : FROM node:8.6-alpine
 ---> b7e15c83cdaf
Step 2 : LABEL maintainer "Vault-UI Contributors"
 ---> Using cache
 ---> 9b7de5e4265c
Step 3 : WORKDIR /app
 ---> Using cache
 ---> 300cebc9574d
Step 4 : COPY . .
 ---> eb2e4519e6f6
Removing intermediate container 5e1ce4a5fda2
Step 5 : RUN yarn install --pure-lockfile --silent &&     yarn run build-web &&     yarn install --silent --production &&     yarn check --verify-tree --production &&     yarn global add nodemon &&     yarn cache clean &&     rm -f /root/.electron/*
 ---> Running in 9c2cc4237125
yarn run v1.1.0
$ webpack -p --env.target=web --hide-modules
[BABEL] Note: The code generator has deoptimised the styling of "/app/node_modules/lodash/lodash.js" as it exceeds the max of "500KB".
[BABEL] Note: The code generator has deoptimised the styling of "/app/node_modules/brace/index.js" as it exceeds the max of "500KB".
Killed
error Command failed with exit code 137.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Service 'webpack' failed to build: The command '/bin/sh -c yarn install --pure-lockfile --silent &&     yarn run build-web &&     yarn install --silent --production &&     yarn check --verify-tree --production &&     yarn global add nodemon &&     yarn cache clean &&     rm -f /root/.electron/*' returned a non-zero code: 1

------------- docker-compose ps -------------
Name   Command   State   Ports
------------------------------

------------- vault auth  -------------
ERROR: No container found for vault_1

------------- vault status -------------
ERROR: No container found for vault_1

------------- vault auth-enable userpass -------------
ERROR: No container found for vault_1

------------- vault auth-enable -path=userpass2 userpass -------------
ERROR: No container found for vault_1

------------- vault auth-enable github -------------
ERROR: No container found for vault_1

------------- vault auth-enable radius -------------
ERROR: No container found for vault_1

------------- vault auth-enable -path=awsaccount1 aws-ec2 -------------
ERROR: No container found for vault_1

------------- vault auth-enable okta -------------
ERROR: No container found for vault_1

------------- vault auth-enable approle -------------
ERROR: No container found for vault_1

------------- vault policy-write admin /misc/admin.hcl -------------
ERROR: No container found for vault_1

------------- vault write auth/userpass/users/test password=test policies=admin -------------
ERROR: No container found for vault_1

------------- vault write auth/userpass2/users/john password=doe policies=admin -------------
ERROR: No container found for vault_1

------------- vault write auth/userpass/users/lame password=lame policies=default -------------
ERROR: No container found for vault_1

------------- vault write auth/radius/users/test password=test policies=admin -------------
ERROR: No container found for vault_1

------------- vault write secret/test somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault mount -path=ultrasecret generic -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/moretest somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/dir1/secret somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/dir2/secret somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/dir2/secret2 somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/admincantlistthis/butcanreadthis somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/admincantreadthis somekey=somedata -------------
ERROR: No container found for vault_1

------------- Vault Root Token -------------
[root@ip-172-31-39-86 vault-ui]# pip install yarn
-bash: pip: command not found
[root@ip-172-31-39-86 vault-ui]#
[root@ip-172-31-39-86 vault-ui]#
[root@ip-172-31-39-86 vault-ui]# yum install yarn
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
No package yarn available.
Error: Nothing to do
[root@ip-172-31-39-86 vault-ui]# yum provides yarn
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
No matches found
[root@ip-172-31-39-86 vault-ui]# sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
--2017-10-28 03:29:11--  https://dl.yarnpkg.com/rpm/yarn.repo
Resolving dl.yarnpkg.com (dl.yarnpkg.com)... 104.16.62.173, 104.16.63.173, 104.16.59.173, ...
Connecting to dl.yarnpkg.com (dl.yarnpkg.com)|104.16.62.173|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 130 [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/yarn.repo’

100%[================================================================================================================>] 130         --.-K/s   in 0s

2017-10-28 03:29:11 (33.7 MB/s) - ‘/etc/yum.repos.d/yarn.repo’ saved [130/130]

[root@ip-172-31-39-86 vault-ui]# curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash -

## Installing the NodeSource Node.js 6.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_6.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.z8cUdKyEYL' 'https://rpm.nodesource.com/pub_6.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.z8cUdKyEYL'

## Cleaning up...

+ rm -f '/tmp/tmp.z8cUdKyEYL'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `yum install -y nodejs` (as root) to install Node.js 6.x and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`

[root@ip-172-31-39-86 vault-ui]# yum install yarn
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
nodesource                                                                                                                         | 2.5 kB  00:00:00
yarn                                                                                                                               | 2.9 kB  00:00:00
(1/2): nodesource/x86_64/primary_db                                                                                                |  46 kB  00:00:00
(2/2): yarn/primary_db                                                                                                             |  16 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package yarn.noarch 0:1.2.1-1 will be installed
--> Processing Dependency: nodejs for package: yarn-1.2.1-1.noarch
--> Running transaction check
---> Package nodejs.x86_64 2:6.11.5-1nodesource will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                         Arch                            Version                                        Repository                           Size
==========================================================================================================================================================
Installing:
 yarn                            noarch                          1.2.1-1                                        yarn                                860 k
Installing for dependencies:
 nodejs                          x86_64                          2:6.11.5-1nodesource                           nodesource                           13 M

Transaction Summary
==========================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 14 M
Installed size: 41 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/yarn/packages/yarn-1.2.1-1.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 6963f07f: NOKEY
Public key for yarn-1.2.1-1.noarch.rpm is not installed
(1/2): yarn-1.2.1-1.noarch.rpm                                                                                                     | 860 kB  00:00:00
warning: /var/cache/yum/x86_64/7Server/nodesource/packages/nodejs-6.11.5-1nodesource.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 34fa74dd: NOKEYTA
Public key for nodejs-6.11.5-1nodesource.x86_64.rpm is not installed
(2/2): nodejs-6.11.5-1nodesource.x86_64.rpm                                                                                        |  13 MB  00:00:01
----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      13 MB/s |  14 MB  00:00:01
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource "
 Fingerprint: 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd
 Package    : nodesource-release-el7-1.noarch (installed)
 From       : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Is this ok [y/N]: y
Retrieving key from https://dl.yarnpkg.com/rpm/pubkey.gpg
Importing GPG key 0x6963F07F:
 Userid     : "Yarn RPM Packaging "
 Fingerprint: 9a6f 73f3 4beb 7473 4d8c 6914 9cbb b558 6963 f07f
 From       : https://dl.yarnpkg.com/rpm/pubkey.gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:nodejs-6.11.5-1nodesource.x86_64                                                                                                     1/2
  Installing : yarn-1.2.1-1.noarch                                                                                                                    2/2
  Verifying  : 2:nodejs-6.11.5-1nodesource.x86_64                                                                                                     1/2
  Verifying  : yarn-1.2.1-1.noarch                                                                                                                    2/2

Installed:
  yarn.noarch 0:1.2.1-1

Dependency Installed:
  nodejs.x86_64 2:6.11.5-1nodesource

Complete!
[root@ip-172-31-39-86 vault-ui]#
[root@ip-172-31-39-86 vault-ui]# ./run-docker-compose-dev
------------- yarn install -------------

yarn install v1.2.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.2: The platform "linux" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info 7zip-bin-mac@1.0.1: The platform "linux" is incompatible with this module.
info "7zip-bin-mac@1.0.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info 7zip-bin-win@2.1.1: The platform "linux" is incompatible with this module.
info "7zip-bin-win@2.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 47.52s.
------------- docker-compose up -d -------------
Building webpack
Step 1 : FROM node:8.6-alpine
 ---> b7e15c83cdaf
Step 2 : LABEL maintainer "Vault-UI Contributors"
 ---> Using cache
 ---> 9b7de5e4265c
Step 3 : WORKDIR /app
 ---> Using cache
 ---> 300cebc9574d
Step 4 : COPY . .
 ---> Using cache
 ---> eb2e4519e6f6
Step 5 : RUN yarn install --pure-lockfile --silent &&     yarn run build-web &&     yarn install --silent --production &&     yarn check --verify-tree --production &&     yarn global add nodemon &&     yarn cache clean &&     rm -f /root/.electron/*
 ---> Running in fdd9822cc9d4
yarn run v1.1.0
$ webpack -p --env.target=web --hide-modules
[BABEL] Note: The code generator has deoptimised the styling of "/app/node_modules/lodash/lodash.js" as it exceeds the max of "500KB".
Killed
error Command failed with exit code 137.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Service 'webpack' failed to build: The command '/bin/sh -c yarn install --pure-lockfile --silent &&     yarn run build-web &&     yarn install --silent --production &&     yarn check --verify-tree --production &&     yarn global add nodemon &&     yarn cache clean &&     rm -f /root/.electron/*' returned a non-zero code: 1

------------- docker-compose ps -------------
Name   Command   State   Ports
------------------------------

------------- vault auth  -------------
ERROR: No container found for vault_1

------------- vault status -------------
ERROR: No container found for vault_1

------------- vault auth-enable userpass -------------
ERROR: No container found for vault_1

------------- vault auth-enable -path=userpass2 userpass -------------
ERROR: No container found for vault_1

------------- vault auth-enable github -------------
ERROR: No container found for vault_1

------------- vault auth-enable radius -------------
ERROR: No container found for vault_1

------------- vault auth-enable -path=awsaccount1 aws-ec2 -------------
ERROR: No container found for vault_1

------------- vault auth-enable okta -------------
ERROR: No container found for vault_1

------------- vault auth-enable approle -------------
ERROR: No container found for vault_1

------------- vault policy-write admin /misc/admin.hcl -------------
ERROR: No container found for vault_1

------------- vault write auth/userpass/users/test password=test policies=admin -------------
ERROR: No container found for vault_1

------------- vault write auth/userpass2/users/john password=doe policies=admin -------------
ERROR: No container found for vault_1

------------- vault write auth/userpass/users/lame password=lame policies=default -------------
ERROR: No container found for vault_1

------------- vault write auth/radius/users/test password=test policies=admin -------------
ERROR: No container found for vault_1

------------- vault write secret/test somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault mount -path=ultrasecret generic -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/moretest somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/dir1/secret somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/dir2/secret somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/dir2/secret2 somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/admincantlistthis/butcanreadthis somekey=somedata -------------
ERROR: No container found for vault_1

------------- vault write ultrasecret/admincantreadthis somekey=somedata -------------
ERROR: No container found for vault_1

------------- Vault Root Token -------------
[root@ip-172-31-39-86 vault-ui]#

Installing Ingress Controller - Kubernetes

Installing the Ingress Controller Prerequisites Make sure you have access to the Ingress controller image: For NGINX Ingress controll...