--- AWSTemplateFormatVersion: '2010-09-09' Description: This template creates EC2 instances on AWS. It deploys Oracle database. **WARNING** This template creates EC2 instances and related resources. You will be billed for the AWS resources used if you create a stack from this template. Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: Environment Configuration Parameters: - EnvironmentSize - VpcId - Subnets - SecurityGroups - Label: default: Amazon EC2 Configuration Parameters: - KeyPairName - StackPrefix - IamInstanceProfile - Label: default: Workload Configuration Parameters: - PuppetServerIP - ProxyServer ParameterLabels: EnvironmentSize: default: Environment Size VpcId: default: VPC ID Subnets: default: Private Subnet ID(s) SecurityGroups: default: Security Group ID(s) KeyPairName: default: Key Pair Name StackPrefix: default: Stack Name Prefix PuppetServerIP: default: Pupper Server IP Address ProxyServer: default: Proxy Server URL IamInstanceProfile: default: IAM Instance Profile Parameters: EnvironmentSize: Type: String Default: Small AllowedValues: - Small - Medium - Large Description: Select Environment Size (S,M,L) VpcId: Type: AWS::EC2::VPC::Id Description: VpcId of your existing Virtual Private Cloud (VPC) ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud. Subnets: Type: List Description: The list of SubnetIds in your Virtual Private Cloud (VPC) ConstraintDescription: must be a list of at least two existing subnets associated with at least two different availability zones. They should be residing in the selected Virtual Private Cloud. SecurityGroups: Type: List Description: The list of SecurityGroupIds in your Virtual Private Cloud (VPC) ConstraintDescription: must be the SecurityGroup Ids of an existing Virtual Private Cloud. KeyPairName: Description: The EC2 Key Pair to allow SSH access to the instances Type: AWS::EC2::KeyPair::KeyName ConstraintDescription: must be the name of an existing EC2 KeyPair. StackPrefix: Type: String MinLength: "1" MaxLength: "20" AllowedPattern: "[a-zA-Z0-9]*" Description: The prefix to all the associated resources in the stack Default: Simphony PuppetServerIP: Type: String Default: "10.10.0.230" ProxyServer: Type: String Default: "http://192.168.50.197:3128" IamInstanceProfile: Type: String Default: simphony_ec2_instance Description: must be the IAM Instance Profile of an existing Virtual Private Cloud. Mappings: RegionMap: us-east-1: "OEL7AMI" : "ami-0f5e4de17ec9ea1b8" ap-northeast-1: "OEL7AMI" : "ami-070d8d39442436586" ap-northeast-2: "OEL7AMI" : "ami-088fd31b9429bab5f" ap-south-1: "OEL7AMI" : "ami-08e4e9f5c64c4befc" ap-southeast-1: "OEL7AMI" : "ami-0284c1360e759acdf" ap-southeast-2: "OEL7AMI" : "ami-07824d3d329f9a9f8" ca-central-1: "OEL7AMI" : "ami-03bb0516cb27a3103" eu-central-1: "OEL7AMI" : "ami-03776a387eb0f2cb4" eu-north-1: "OEL7AMI" : "ami-05e73148d1af4b031" eu-west-1: "OEL7AMI" : "ami-0d2e527a99778d31c" eu-west-2: "OEL7AMI" : "ami-05e974c6d389dc49e" eu-west-3: "OEL7AMI" : "ami-00305c4621f7761e5" sa-east-1: "OEL7AMI" : "ami-09a4c73fc7f5e5a38" us-east-2: "OEL7AMI" : "ami-029d1f47786637314" us-west-1: "OEL7AMI" : "ami-0139118fa80b5b4bb" us-west-2: "OEL7AMI" : "ami-001ed3bebf18ea5d6" InstanceSize: Small: "EC2" : "c5.large" "MinSize" : "1" "MaxSize" : "1" "DesireSize" : "1" "EbsVolumeSize" : "200" Medium: "EC2" : "c5.xlarge" "MinSize" : "1" "MaxSize" : "1" "DesireSize" : "1" "EbsVolumeSize" : "250" Large: "EC2" : "c5.2xlarge" "MinSize" : "1" "MaxSize" : "1" "DesireSize" : "1" "EbsVolumeSize" : "500" Resources: LaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: KeyName: !Ref KeyPairName InstanceType: !FindInMap [InstanceSize, !Ref EnvironmentSize, EC2] ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", OEL7AMI] IamInstanceProfile: !Ref IamInstanceProfile BlockDeviceMappings: - DeviceName: /dev/sda1 Ebs: VolumeSize: !FindInMap [InstanceSize, !Ref EnvironmentSize, EbsVolumeSize] VolumeType: "gp2" SecurityGroups: Ref: SecurityGroups UserData: "Fn::Base64": !Sub | #!/bin/bash #sudo su root echo "proxy=${ProxyServer}" >> /etc/yum.conf yum -y install ca-certificates echo "${PuppetServerIP} puppet.skillnetaws.com puppet" >> /etc/hosts echo "$(curl http://169.254.169.254/latest/meta-data/local-ipv4) oracdb02.skillnetaws.com oracdb02" >> /etc/hosts #Install ntp server yum -y install ntp ntpdate systemctl start ntpd systemctl enable ntpd #Install puppet agent rpm -Uvh -httpproxy "${ProxyServer}" https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm yum install -y puppet-agent echo "[main]" >> /etc/puppetlabs/puppet/puppet.conf echo "certname = oracdb01.skillnetaws.com" >> /etc/puppetlabs/puppet/puppet.conf echo "server = puppet.skillnetaws.com" >> /etc/puppetlabs/puppet/puppet.conf echo "environment = simphony_oracledb" >> /etc/puppetlabs/puppet/puppet.conf #/opt/puppetlabs/bin/puppet agent -t SimphonyOracleDBGroup: Type: AWS::AutoScaling::AutoScalingGroup Properties: VPCZoneIdentifier: Ref: Subnets LaunchConfigurationName: Ref: LaunchConfig MinSize: !FindInMap [InstanceSize, !Ref EnvironmentSize, MinSize] MaxSize: !FindInMap [InstanceSize, !Ref EnvironmentSize, MaxSize] DesiredCapacity: !FindInMap [InstanceSize, !Ref EnvironmentSize, DesireSize] Tags: - Key: Name PropagateAtLaunch: true Value: !Join [ " - ", [ !Ref StackPrefix, "DB" ] ] - Key: LCM_TAG PropagateAtLaunch: true Value: SIM