You can download cloudformation yaml from here!
Description: Kopiax CloudFormation for Marketplace
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Network Configuration"
Parameters:
- VpcId
- SubnetId
- IpAddress
-
Label:
default: "Tag"
Parameters:
- owner
Parameters:
VpcId:
Type: AWS::EC2::VPC::Id
SubnetId:
Type: AWS::EC2::Subnet::Id
IpAddress:
Type: String
Description: Your own IP Address to allow access to Kopiax instance
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})
ConstraintDescription: must be a valid IP address of the form x.x.x.x.
owner:
Type: String
Default: kopiax
Description: Tagging your resources for Kopiax
Mappings:
RegionMap:
us-east-1:
ImageId: ami-0ffa1c1cd7ee576a7
us-west-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
eu-west-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-southeast-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
us-east-2:
ImageId: ami-xxxxxxxxxxxxxxxxx
us-west-2:
ImageId: ami-xxxxxxxxxxxxxxxxx
af-south-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-east-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-southeast-3:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-south-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-northeast-3:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-northeast-2:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-southeast-2:
ImageId: ami-xxxxxxxxxxxxxxxxx
ap-northeast-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
ca-central-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
eu-central-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
eu-west-2:
ImageId: ami-xxxxxxxxxxxxxxxxx
eu-south-1:
ImageId: ami-xxxxxxxxxxxxxxxxx
Resources:
InstanceProfile:
Type: AWS::IAM::InstanceProfile
DependsOn:
- IAMRole
Properties:
InstanceProfileName: kopiax-instance-profile
Roles:
- !Ref IAMRole
IAMRole:
Type: AWS::IAM::Role
Properties:
RoleName: kopiax-read-only-access
MaxSessionDuration : 43200
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Action: sts:AssumeRole
Principal:
Service:
- ec2.amazonaws.com
ManagedPolicyArns:
- arn:aws:iam::aws:policy/ReadOnlyAccess
Tags:
- Key: owner
Value: !Ref owner
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security Group for the Kopiax
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: -1
CidrIp: !Sub '${IpAddress}/32'
Tags:
- Key: owner
Value: !Ref owner
ElasticIP:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
InstanceId: !Ref EC2Instance
Tags:
- Key: owner
Value: !Ref owner
EC2Instance:
Type: AWS::EC2::Instance
DependsOn:
- SecurityGroup
- InstanceProfile
Properties:
ImageId: !FindInMap
- RegionMap
- !Ref 'AWS::Region'
- ImageId
InstanceType: "t3.small"
Tenancy: "default"
SubnetId: !Ref SubnetId
IamInstanceProfile: !Ref InstanceProfile
EbsOptimized: false
SecurityGroupIds:
- !Ref SecurityGroup
SourceDestCheck: true
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
Encrypted: false
VolumeSize: 10
VolumeType: "gp3"
DeleteOnTermination: true
UserData:
Fn::Base64:
!Sub |
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/kopiax-read-only-access > /home/ec2-user/kopiax/credentials.json
cd /home/ec2-user/kopiax
pm2 start server.js
Tags:
- Key: owner
Value: !Ref owner
- Key: Name
Value: !Ref owner
Outputs:
KopiaxPublicDNS:
Value: !Sub "${EC2Instance.PublicDnsName}:8080"
Description: Kopiax Public DNS address