Provision Elasticsearch cluster

During the demo, we'll walk through the screens for provisioning an ES cluster. Since it takes some time for a new cluster to be ready, we will take the cooking show approach and provision this ES cluster beforehand, and use it for the live demos.

Create an Elasticsearch domain

cat << EOF > /tmp/elasticsearch_cluster_config.json
{
    "InstanceType":           "m3.large.elasticsearch",
    "InstanceCount":          3,
    "DedicatedMasterEnabled": true,
    "ZoneAwarenessEnabled":   true,
    "DedicatedMasterType":    "m3.large.elasticsearch",
    "DedicatedMasterCount":   3
}
EOF

cat << EOF > /tmp/iam_policy.json
{
    "Version": "2012-10-17",
    "Statement": [{
        "Effect":    "Allow",
        "Principal": { "AWS": ["$ESTEST_ACCOUNT_ID"] },
        "Action":    [ "es:*" ],
        "Resource":  "arn:aws:es:us-west-2:$ESTEST_ACCOUNT_ID:domain/$ESTEST_ELASTICSEARCH_DOMAIN/*"
    }]
}
EOF

aws es create-elasticsearch-domain \
        --domain-name $ESTEST_ELASTICSEARCH_DOMAIN \
        --elasticsearch-cluster-config file:///tmp/elasticsearch_cluster_config.json \
        --ebs-options EBSEnabled=true,VolumeType=standard,VolumeSize=100 \
        --snapshot-options AutomatedSnapshotStartHour=5 \
        --access-policies file:///tmp/iam_policy.json

Tag the Elasticsearch cluster

ESTEST_ELASTICSEARCH_ARN=$(aws es describe-elasticsearch-domain \
                                   --domain-name $ESTEST_ELASTICSEARCH_DOMAIN \
                                   | jq .DomainStatus.ARN --raw-output)
aws es add-tags --arn $ESTEST_ELASTICSEARCH_ARN --tag-list Key=Name,Value=$ESTEST_ELASTICSEARCH_DOMAIN