blob: 6df891b6c614b2bfbe7304af88c468de8c37d370 [file] [log] [blame]
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Stack for running OpenNLP testing. Licensed under the ASLv2.",
"Parameters": {
"InstanceType": {
"Description": "EC2 instance type.",
"Type": "String",
"Default": "m4.xlarge"
},
"Image": {
"Description": "The base AMI.",
"Type": "String",
"Default": "ami-80861296"
},
"KeyName": {
"Description": "An existing EC2 keypair.",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription": "Must be the name of an existing EC2 keypair."
},
"OpenNLPDataOnS3": {
"Description": "The location of the OpenNLP evaluation test data on S3.",
"Type": "String",
"ConstraintDescription": "s3://bucket-name/opennlp-data.zip"
},
"NotificationsEmail": {
"Description": "Email address to receive notifications.",
"Type": "String"
},
"SSHCIDR": {
"Description": "IP to allow SSH.",
"Type": "String",
"Default": "0.0.0.0/0"
}
},
"Resources": {
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": true,
"EnableDnsHostnames": true,
"Tags": [
{
"Key": "Application",
"Value": {
"Ref": "AWS::StackId"
}
}
]
}
},
"Subnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.0.0/24",
"MapPublicIpOnLaunch": true,
"Tags": [
{
"Key": "Application",
"Value": {
"Ref": "AWS::StackId"
}
}
],
"VpcId": {
"Ref": "VPC"
}
}
},
"InternetGateway": {
"Type": "AWS::EC2::InternetGateway",
"Properties": {
"Tags": [
{
"Key": "Application",
"Value": {
"Ref": "AWS::StackId"
}
}
]
}
},
"AttachGateway": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"InternetGatewayId": {
"Ref": "InternetGateway"
}
}
},
"RouteTable": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"Tags": [
{
"Key": "Application",
"Value": {
"Ref": "AWS::StackId"
}
}
]
}
},
"Route": {
"Type": "AWS::EC2::Route",
"DependsOn": "AttachGateway",
"Properties": {
"RouteTableId": {
"Ref": "RouteTable"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "InternetGateway"
}
}
},
"SubnetRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "Subnet"
},
"RouteTableId": {
"Ref": "RouteTable"
}
}
},
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH access via port 22",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": {
"Ref": "SSHCIDR"
}
}
],
"VpcId": {
"Ref": "VPC"
}
}
},
"RolePolicies": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "root",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
},
{
"Action": [
"sns:*"
],
"Effect": "Allow",
"Resource": "*"
}
]
},
"Roles": [
{
"Ref": "InstanceRole"
}
]
}
},
"InstanceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/"
}
},
"InstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "InstanceRole"
}
]
}
},
"SNSTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"Subscription": [
{
"Endpoint": {
"Ref": "NotificationsEmail"
},
"Protocol": "email"
}
],
"TopicName": "OpenNLP-Notification"
}
},
"OpenNLPInstance": {
"Type": "AWS::EC2::Instance",
"DependsOn": "AttachGateway",
"Properties": {
"IamInstanceProfile": {
"Ref": "InstanceProfile"
},
"ImageId": {
"Ref": "Image"
},
"InstanceType": {
"Ref": "InstanceType"
},
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds": [
{
"Ref": "InstanceSecurityGroup"
}
],
"SubnetId": {
"Ref": "Subnet"
},
"Tags": [
{
"Key": "Application",
"Value": {
"Ref": "AWS::StackId"
}
},
{
"Key": "Name",
"Value": "OpenNLP Testing"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash -xe\n",
"apt-get update && sudo apt-get -y dist-upgrade\n",
"apt-get install -y openjdk-8-jdk git maven awscli\n",
"# Get the scripts\n",
"git clone https://github.com/apache/opennlp-sandbox.git\n",
"mv opennlp-sandbox/aws-ec2-testing-scripts/* /opt/\n",
"# Get OpenNLP\n",
"git clone https://github.com/apache/opennlp.git\n",
"mv opennlp /opt/\n",
"sed -i 's/TOPICARNPARAM/", {"Ref": "SNSTopic"}, "/g' /opt/notify.sh\n",
"mkdir /opt/opennlp-data\n",
"aws s3 cp ",
{
"Ref": "OpenNLPDataOnS3"
},
" /opt/opennlp-data --recursive\n"
]
]
}
}
}
}
},
"Outputs": {
"Instance": {
"Description": "The instance public IP.",
"Value": {
"Fn::GetAtt": [
"OpenNLPInstance",
"PublicDnsName"
]
}
}
}
}