Skip to content

Commit

Permalink
Update packaging, documentation and CloudFormation deployment (#8)
Browse files Browse the repository at this point in the history
* CloudFormation: Set up proper dependency relation between Listener and Target Group

* Downgrade to node:10-alpine to overcome issues with fibers module installation

* CloudFormation: add optional HTTPS listener if certificate is provided

* CloudFormation: fix non-HTTPS deployment

* CloudFormation: replace instances with auto-scaling group

* CloudFormation: change default for desired count to 1

* Add helper shell script to build docker images

* Add CloudFormation stack for netwrok resource and deployment documentation

* Add operations guide

* Add packaging description

* Add references to different supplementary documents to README.md

* Add periodic obsolete files (versions and bundles) deletion to builder container

* Add environment variables to allow builder configuration overriding

* CloudFormation: add environment variables for builder for easier overriding in case of need

* Change builder to check for new version every 3 hours

* Adjust documentation

* Set proper permissions on scripts
  • Loading branch information
schernysh authored Jan 9, 2020
1 parent b5a196b commit c870b52
Show file tree
Hide file tree
Showing 14 changed files with 489 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.*
README.md
*.sh
!checkout.sh
startup.sh
todo.txt
docker
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ Responds with the content of the Prebid.js bundle with the desired modules.
run `./chekcout.sh ${num_previous_ver}` to checkout prebid.js and build the files, where `${num_previous_ver}` is the number git tags (sorted from latest release) to checkout

### Run
`node app.js`
`node app.js`

### Other documentation
Refer to [docs](docs) directory for [packaging](docs/packaging.md), [deployment](docs/deployment.md) and
[operations](docs/operations.md) guides.
Empty file modified buildCleanup.sh
100644 → 100755
Empty file.
Empty file modified bundleCleanup.sh
100644 → 100755
Empty file.
224 changes: 224 additions & 0 deletions cloudformation/network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: This stack creates a VPC constisting of two private and two public subnets, Internet Gateway, NAT Gateway

Mappings:
Subnets:
VPC:
CIDR: '172.54.0.0/16'
PrivateOne:
CIDR: '172.54.0.0/20'
PrivateTwo:
CIDR: '172.54.16.0/20'
PublicOne:
CIDR: '172.54.32.0/20'
PublicTwo:
CIDR: '172.54.48.0/20'

Resources:
# VPC
VPC:
Type: AWS::EC2::VPC
Properties:
EnableDnsSupport: true
EnableDnsHostnames: false
CidrBlock: !FindInMap ['Subnets', 'VPC', 'CIDR']
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'vpc']]

# Private subnets
PrivateSubnetOne:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: {Ref: 'AWS::Region'}
VpcId: !Ref VPC
CidrBlock: !FindInMap ['Subnets', 'PrivateOne', 'CIDR']
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'private-subnet-az1']]
PrivateSubnetTwo:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: {Ref: 'AWS::Region'}
VpcId: !Ref VPC
CidrBlock: !FindInMap ['Subnets', 'PrivateTwo', 'CIDR']
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'private-subnet-az2']]

# Public subnets
PublicSubnetOne:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: {Ref: 'AWS::Region'}
VpcId: !Ref VPC
CidrBlock: !FindInMap ['Subnets', 'PublicOne', 'CIDR']
MapPublicIpOnLaunch: true
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'public-subnet-az1']]
PublicSubnetTwo:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: {Ref: 'AWS::Region'}
VpcId: !Ref VPC
CidrBlock: !FindInMap ['Subnets', 'PublicTwo', 'CIDR']
MapPublicIpOnLaunch: true
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'public-subnet-az2']]

# Internet Gateway for public subnets
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'igw']]
InternetGatewayAttachement:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway

# Route table for public subnets
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'public-routing-table']]
PublicRoute:
Type: AWS::EC2::Route
DependsOn: InternetGatewayAttachement
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: '0.0.0.0/0'
GatewayId: !Ref InternetGateway
PublicSubnetOneRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnetOne
RouteTableId: !Ref PublicRouteTable
PublicSubnetTwoRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnetTwo
RouteTableId: !Ref PublicRouteTable

# NAT Gateways for private subnets
NATGatewayOne:
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt EIPNATOne.AllocationId
SubnetId: !Ref PublicSubnetOne
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'nat-gw-az1']]
NATGatewayTwo:
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt EIPNATTwo.AllocationId
SubnetId: !Ref PublicSubnetTwo
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'nat-gw-az2']]
EIPNATOne:
Type: AWS::EC2::EIP
DependsOn: InternetGatewayAttachement
Properties:
Domain: vpc
EIPNATTwo:
Type: AWS::EC2::EIP
DependsOn: InternetGatewayAttachement
Properties:
Domain: vpc

# Route tables for private subnets
PrivateRouteTableOne:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'private-routing-table-az1']]
PrivateRouteOne:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PrivateRouteTableOne
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NATGatewayOne
PrivateRouteTableOneAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PrivateRouteTableOne
SubnetId: !Ref PrivateSubnetOne
PrivateRouteTableTwo:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: 'Name'
Value: !Join ['-', [!Ref 'AWS::StackName', 'private-routing-table-az2']]
PrivateRouteTwo:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PrivateRouteTableTwo
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NATGatewayTwo
PrivateRouteTableTwoAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PrivateRouteTableTwo
SubnetId: !Ref PrivateSubnetTwo

# ECS cluster
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Join ['-', [!Ref 'AWS::StackName', 'ecs-cluster']]

Outputs:
ClusterName:
Description: The name of the ECS cluster
Value: !Ref ECSCluster
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'ClusterName' ] ]
VPCId:
Description: The ID of the VPC that this stack is deployed in
Value: !Ref VPC
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'VPCId' ] ]
PublicSubnetOne:
Description: Public subnet one
Value: !Ref PublicSubnetOne
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'PublicSubnetOne' ] ]
PublicSubnetTwo:
Description: Public subnet two
Value: !Ref PublicSubnetTwo
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'PublicSubnetTwo' ] ]
PrivateSubnetOne:
Description: Private subnet one
Value: !Ref PrivateSubnetOne
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'PrivateSubnetOne' ] ]
PrivateSubnetTwo:
Description: Private subnet two
Value: !Ref PrivateSubnetTwo
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'PrivateSubnetTwo' ] ]
Loading

0 comments on commit c870b52

Please sign in to comment.