finmod-rds_instance.yaml
---

KFS RDS Instance

This CloudFormation template will build an RDS Instance

AWSTemplateFormatVersion: '2010-09-09' Description: KFS RDS Instance

Parameters

These are the input parameters for this template. All of these parameters must be supplied for this template to be deployed.

Parameters: EnvSlug: MinLength: '2' Type: String Description: Short environment slug, ie 'dev', or 'prd'. Lowercase letters, numbers and dashes only AllowedPattern: "[a-z0-9]*" AppDBServicename: Description: Database Service Name Type: String DBSnapshotID: Description: DB Snapshot ID Type: String DBInstClass: Description: DB Snapshot ID Type: String Default: "db.t3.medium"

FIN-1386 Preferred Availability Zone; needed to ensure DB and EC2 instances are in the same AZ

PreferredAz: Description: Preferred Availability Zone Type: String Default: "us-west-2a" DBSubnetGroup: Description: "Name of the RDS private subnet group" Type: String MinLength: '2' Default: "rds-private-subnet-group" DBSecurityGroupStack: Description: "Name of the CloudFormation Stack for the Database Access Security Group" Type: String MinLength: '2' Default: "kfs-nonprod-db-access-sg" OptionGroupStack: Description: "Name of the CloudFormation Stack for the RDS Option Group" Type: String MinLength: '2' Default: "kfs-rds-option-group" TagService: Description: Service name (from the service catalog) that is utilizing this resource Type: String Default: "Financials Modernization" TagName: Description: Descriptive identifier of resource. Type: String Default: "RDS instance" TagEnvironment: Description: Type of environment that is using this resource, such as 'dev', 'tst', 'prd'. Type: String TagCreatedBy: Description: NetID of the user that created this resource Type: String TagContactNetId: Description: NetID of the person to contact for information about this resource Type: String TagAccountNumber: Description: Financial system account number for the service utilizing this resource Type: String Default: "1192801" TagSubAccount: Description: Financial system subaccount number for the service utilizing this resource Type: String Default: "INTGR" TagTicketNumber: Description: Ticket number that this resource is for Type: String TagResourceFunction: Description: Human-readable description of what function this resource is providing Type: String Conditions: IsHAEnv: !Equals [!Ref EnvSlug, "prd"]

Resources

These are all of the actual AWS resources created for this application.

Resources:

RDS Instance for Environment Assumes no final snapshot before deletion

DBInstance: Type: AWS::RDS::DBInstance Properties: DBInstanceIdentifier: !Ref "AppDBServicename" DBName: !Ref "AppDBServicename" DBSnapshotIdentifier: !Ref "DBSnapshotID"

FIN-1386 Set the Availibility Zone for the DB to ensure it is in the same AZ as the EC2 instance it could be connectd to

AvailabilityZone: !Ref "PreferredAz" MultiAZ: !If ["IsHAEnv","true","false"] Engine: "oracle-ee" LicenseModel: "bring-your-own-license" DBInstanceClass: !Ref "DBInstClass" OptionGroupName: Fn::ImportValue: !Sub "${OptionGroupStack}-DbOptionGroup" StorageType: "gp2" DBSubnetGroupName: !Ref "DBSubnetGroup" AutoMinorVersionUpgrade: "false" VPCSecurityGroups: - Fn::ImportValue: !Sub "${DBSecurityGroupStack}-id" Tags: - Key: service Value: !Ref TagService - Key: Name Value: !Sub "${TagName}-db-instance" - Key: environment Value: !Ref TagEnvironment - Key: createdby Value: !Ref TagCreatedBy - Key: contactnetid Value: !Ref TagContactNetId - Key: accountnumber Value: !Ref TagAccountNumber - Key: subaccount Value: !Ref TagSubAccount - Key: ticketnumber Value: !Ref TagTicketNumber - Key: resourcefunction Value: !Ref TagResourceFunction Outputs: InstanceId: Description: InstanceId of the newly created RDS Instance Value: !Ref DBInstance