ps_env_ecs_db.yaml
--- AWSTemplateFormatVersion: '2010-09-09' Description: PeopleSoft Environment Database Parameters: SecurityGroupCloudFormationName: Description: CloudFormation Security Group Name Type: String Default: "PeopleSoftSG" PillarLowerCase: Description: Lower Case Environment Pillar Identifier (el, hr, or sa) Type: String Default: "el" EnvironmentLowerCase: Description: Loser Case Environment Identifier (dev, tst, stg, prd, etc.) Type: String Default: "dev" PillarUpperCase: Description: Upper Case Environment Pillar Identifier (EL, HR, or SA) Type: String Default: "EL" EnvironmentUpperCase: Description: Upper Case Environment Identifier (DEV, TST, STG, PRD, etc.) Type: String Default: "DEV" DBSnapshotID: Description: DB Snapshot from Which to Restore From Type: String Default: "peoplesoft-eldev-final-snapshot" DBMultiAz: Description: DB Multi Availibility Zone Deployment (boolean) Type: String Default: "false" DBInstanceClass: Description: DB Instance Class Type: String Default: "db.t2.medium" DBStorageType: Description: DB Storage Type (gp2-SSD, io1-Provisioned IOPS) Type: String Default: "gp2" TagService: Description: Refers to the application (Uaccess Learning, Uaccess Employee, Uaccess Student) Type: String Default: "Uaccess Learning" TagContactNetid: Description: NetID of person most familiar with resource Type: String Default: "kellehs" TagAccountNumber: Description: Identifies the financial system account number Type: String Default: "Human Resources Systems" TagSubAccount: Description: Identifies the financial system subaccount number Type: String Default: "Uaccess Learning" TagTicketNumber: Description: Jira Ticket Number Type: String Default: "CLOUD-15" SetUpLikePrd: Description: If set to Y then will set up like a Production Environment Type: String Default: "N" #PSAWS-69 Preferred Availability Zone, needed to ensure DB and Batch servers are in the same AZ PreferredAz: Description: Preferred Availability Zone Type: String Default: "us-west-2a" #MEM-19341 This will be used to determine if a snapshot will be taken. For some environments a final snapshot #is not wanted (i.e. TRN) and maybe SUP. TakeSnapshot: Description: Take a final RDS Snapshot on Delete for the instance (Y/N) Type: String Default: "Y" #PSAWS-74 - Add a DBEngineVersion Parameter to pass which version of the DB should be used DBEngineVersion: Description: The DB Engine Version should be used Type: String Default: "12.1.0.2.v15" #Next is the Conditions section, these will be used to build additional infrastructure for production Conditions: ThisIsProd: !Equals [!Ref "SetUpLikePrd", "Y"] ThisIsNotProd: !And [ !Not [ !Equals [!Ref "SetUpLikePrd", "Y"] ], !Equals [!Ref "TakeSnapshot", "Y"] ] ThisIsNotProdNoSnap: !And [ !Not [ !Equals [!Ref "SetUpLikePrd", "Y"] ], !Equals [!Ref "TakeSnapshot", "N"] ] #Resources for this CloudFormation Stack Resources: #Use this DB instance if it's for a production environment. Production Enviornments will be Multi Zoned DBInstanceProd: Type: AWS::RDS::DBInstance Condition: ThisIsProd Properties: DBInstanceIdentifier: !Sub "peoplesoft-${PillarLowerCase}${EnvironmentLowerCase}" DBName: !Sub "${PillarUpperCase}${EnvironmentUpperCase}" DBSnapshotIdentifier: !Ref "DBSnapshotID" #PSAWS-69 set the Availibility Zone for the DB to ensure it is in the same AZ as the Batch Servers #to avoid latency issues in some batch processes #AvailabilityZone: !Ref "PreferredAz" MultiAZ: !Ref "DBMultiAz" Engine: "oracle-ee" LicenseModel: "bring-your-own-license" DBInstanceClass: !Ref "DBInstanceClass" DBParameterGroupName: "peoplesoft-oracle-ee-12-1" OptionGroupName: "oem-agent-ee-12-1" StorageType: !Ref "DBStorageType" CopyTagsToSnapshot: "true" BackupRetentionPeriod: 21 #Includes July 2018 Patch EngineVersion: !Ref "DBEngineVersion" DBSubnetGroupName: Fn::ImportValue: !Sub "${SecurityGroupCloudFormationName}-RDSSubnetGroup" VPCSecurityGroups: - Fn::ImportValue: !Sub "${SecurityGroupCloudFormationName}-DbSg" Tags: - Key: service Value: !Ref "TagService" - Key: Name Value: !Sub "peoplesoft-${PillarLowerCase}${EnvironmentLowerCase}-rds" - Key: environment Value: !Ref "EnvironmentLowerCase" - Key: contactnetid Value: !Ref "TagContactNetid" - Key: accountnumber Value: !Ref "TagAccountNumber" - Key: subaccount Value: !Ref "TagSubAccount" - Key: ticketnumber Value: !Ref "TagTicketNumber" #This will create a final snapshot when the database is removed DeletionPolicy: "Snapshot" #Use this DB instance if it's for a non-production environment. #Non-production databases will be placed into a particular AZ so they can match up with the Batch Server AZ DBInstanceNonProd: Type: AWS::RDS::DBInstance Condition: ThisIsNotProd Properties: DBInstanceIdentifier: !Sub "peoplesoft-${PillarLowerCase}${EnvironmentLowerCase}" DBName: !Sub "${PillarUpperCase}${EnvironmentUpperCase}" DBSnapshotIdentifier: !Ref "DBSnapshotID" #PSAWS-69 set the Availibility Zone for the DB to ensure it is in the same AZ as the Batch Servers #to avoid latency issues in some batch processes AvailabilityZone: !Ref "PreferredAz" #MultiAZ: !Ref "DBMultiAz" Engine: "oracle-ee" LicenseModel: "bring-your-own-license" DBInstanceClass: !Ref "DBInstanceClass" DBParameterGroupName: "peoplesoft-oracle-ee-12-1" OptionGroupName: "oem-agent-ee-12-1" StorageType: !Ref "DBStorageType" CopyTagsToSnapshot: "true" BackupRetentionPeriod: 7 #Includes July 2018 Patch EngineVersion: !Ref "DBEngineVersion" DBSubnetGroupName: Fn::ImportValue: !Sub "${SecurityGroupCloudFormationName}-RDSSubnetGroup" VPCSecurityGroups: - Fn::ImportValue: !Sub "${SecurityGroupCloudFormationName}-DbSg" Tags: - Key: service Value: !Ref "TagService" - Key: Name Value: !Sub "peoplesoft-${PillarLowerCase}${EnvironmentLowerCase}-rds" - Key: environment Value: !Ref "EnvironmentLowerCase" - Key: contactnetid Value: !Ref "TagContactNetid" - Key: accountnumber Value: !Ref "TagAccountNumber" - Key: subaccount Value: !Ref "TagSubAccount" - Key: ticketnumber Value: !Ref "TagTicketNumber" #This will create a final snapshot when the database is removed or not depending on the TakeSnapshot variable DeletionPolicy: "Snapshot" #Use this DB instance if it's for a non-production environment. #Non-production databases will be placed into a particular AZ so they can match up with the Batch Server AZ #And this will not create a final snapshot when the resource is deleted, used for TRN environments and maybe SUP DBInstanceNonProdNoSnap: Type: AWS::RDS::DBInstance Condition: ThisIsNotProdNoSnap Properties: DBInstanceIdentifier: !Sub "peoplesoft-${PillarLowerCase}${EnvironmentLowerCase}" DBName: !Sub "${PillarUpperCase}${EnvironmentUpperCase}" DBSnapshotIdentifier: !Ref "DBSnapshotID" #PSAWS-69 set the Availibility Zone for the DB to ensure it is in the same AZ as the Batch Servers #to avoid latency issues in some batch processes AvailabilityZone: !Ref "PreferredAz" #MultiAZ: !Ref "DBMultiAz" Engine: "oracle-ee" LicenseModel: "bring-your-own-license" DBInstanceClass: !Ref "DBInstanceClass" DBParameterGroupName: "peoplesoft-oracle-ee-12-1" OptionGroupName: "oem-agent-ee-12-1" StorageType: !Ref "DBStorageType" CopyTagsToSnapshot: "true" BackupRetentionPeriod: 7 #Includes July 2018 Patch EngineVersion: !Ref "DBEngineVersion" DBSubnetGroupName: Fn::ImportValue: !Sub "${SecurityGroupCloudFormationName}-RDSSubnetGroup" VPCSecurityGroups: - Fn::ImportValue: !Sub "${SecurityGroupCloudFormationName}-DbSg" Tags: - Key: service Value: !Ref "TagService" - Key: Name Value: !Sub "peoplesoft-${PillarLowerCase}${EnvironmentLowerCase}-rds" - Key: environment Value: !Ref "EnvironmentLowerCase" - Key: contactnetid Value: !Ref "TagContactNetid" - Key: accountnumber Value: !Ref "TagAccountNumber" - Key: subaccount Value: !Ref "TagSubAccount" - Key: ticketnumber Value: !Ref "TagTicketNumber" #This will not create a final snapshot DeletionPolicy: "Delete"