Skip to content

Commit

Permalink
Add CF template (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift authored Nov 27, 2023
1 parent 29b740b commit 4f8eaf2
Showing 1 changed file with 189 additions and 0 deletions.
189 changes: 189 additions & 0 deletions src/deployment/cloudformation-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A CloudFormation template for deploying the Airseeker v2 on AWS",
"Resources": {
"CloudWatchLogsGroup": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "AirseekerLogGroup",
"RetentionInDays": 7
}
},
"AppDefinition": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"NetworkMode": "awsvpc",
"Cpu": 256,
"Memory": 512,
"ExecutionRoleArn": {
"Ref": "ECSTaskRole"
},
"RequiresCompatibilities": ["FARGATE"],
"ContainerDefinitions": [
{
"Name": "AirseekerContainer",
"Image": "<DOCKER_IMAGE>",
"Environment": [
{
"Name": "SECRETS_ENV",
"Value": {
"Fn::Join": ["", ["WALLET_MNEMONIC", "=", "<AIRSEEKER_WALLET_MNEMONIC>"]]
}
},
{
"Name": "LOG_LEVEL",
"Value": "debug"
}
],
"EntryPoint": [
"/bin/sh",
"-c",
"echo -e $SECRETS_ENV >> ./config/secrets.env && wget -O - <CONFIG_URL> >> ./config/airseeker.json && node dist/index.js"
],
"LogConfiguration": {
"LogDriver": "awslogs",
"Options": {
"awslogs-group": {
"Ref": "CloudWatchLogsGroup"
},
"awslogs-region": {
"Ref": "AWS::Region"
},
"awslogs-stream-prefix": "airseeker-<SOME_ID>"
}
}
}
]
}
},
"AppCluster": {
"Type": "AWS::ECS::Cluster",
"Properties": {
"ClusterName": "AirseekerCluster-<SOME_ID>"
}
},
"AppService": {
"Type": "AWS::ECS::Service",
"Properties": {
"Cluster": {
"Ref": "AppCluster"
},
"ServiceName": "AirseekerService",
"DesiredCount": 1,
"LaunchType": "FARGATE",
"TaskDefinition": {
"Ref": "AppDefinition"
},
"NetworkConfiguration": {
"AwsvpcConfiguration": {
"AssignPublicIp": "ENABLED",
"Subnets": [
{
"Ref": "InstanceSubnet"
}
]
}
},
"DeploymentConfiguration": {
"MinimumHealthyPercent": 100,
"MaximumPercent": 200
}
}
},
"InstanceVPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": true,
"EnableDnsHostnames": true
}
},
"InstanceInternetGateway": {
"Type": "AWS::EC2::InternetGateway"
},
"InstanceVPCGatewayAttachment": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "InstanceVPC"
},
"InternetGatewayId": {
"Ref": "InstanceInternetGateway"
}
}
},
"InstancePublicRouteTable": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "InstanceVPC"
}
}
},
"InstancePublicRoute": {
"Type": "AWS::EC2::Route",
"DependsOn": "InstanceVPCGatewayAttachment",
"Properties": {
"RouteTableId": {
"Ref": "InstancePublicRouteTable"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "InstanceInternetGateway"
}
}
},
"InstanceSubnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.0.0/24",
"VpcId": {
"Ref": "InstanceVPC"
},
"MapPublicIpOnLaunch": true
}
},
"InstancePublicSubnet1RouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "InstancePublicRouteTable"
},
"SubnetId": {
"Ref": "InstanceSubnet"
}
}
},
"ECSTaskRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": {
"Effect": "Allow",
"Principal": {
"Service": ["ecs-tasks.amazonaws.com"]
},
"Action": ["sts:AssumeRole"]
}
},
"Policies": [
{
"PolicyName": "ECSTaskExecutionRolePolicy",
"PolicyDocument": {
"Statement": {
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:PutLogEvents"
],
"Resource": "*"
}
}
}
]
}
}
}
}

0 comments on commit 4f8eaf2

Please sign in to comment.