$npx -y skills add giuseppe-trisciuoglio/developer-kit --skill aws-cloudformation-rdsProvides AWS CloudFormation patterns for Amazon RDS databases. Use when creating RDS instances (MySQL, PostgreSQL, Aurora), DB clusters, multi-AZ deployments, parameter groups, subnet groups, and implementing template structure with Parameters, Outputs, Mappings, Conditions, and
| 1 | # AWS CloudFormation RDS Database |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Create production-ready Amazon RDS infrastructure using AWS CloudFormation templates. Covers RDS instances (MySQL, PostgreSQL, Aurora), DB clusters, multi-AZ deployments, parameter groups, subnet groups, security groups, and cross-stack references. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - Creating RDS instances (MySQL, PostgreSQL, Aurora) or DB clusters with read replicas |
| 10 | - Setting up multi-AZ deployments or configuring parameter/subnet groups |
| 11 | - Integrating with Secrets Manager or implementing cross-stack references |
| 12 | |
| 13 | ## Quick Reference |
| 14 | |
| 15 | | Component | CloudFormation Type | Use Case | |
| 16 | |-----------|-------------------|----------| |
| 17 | | DB Instance | `AWS::RDS::DBInstance` | Single database instance | |
| 18 | | DB Cluster | `AWS::RDS::DBCluster` | Aurora cluster | |
| 19 | | DB Subnet Group | `AWS::RDS::DBSubnetGroup` | VPC deployment | |
| 20 | | Parameter Group | `AWS::RDS::DBParameterGroup` | Database configuration | |
| 21 | | Security Group | `AWS::EC2::SecurityGroup` | Network access control | |
| 22 | | Secrets Manager | `AWS::SecretsManager::Secret` | Credential storage | |
| 23 | |
| 24 | ## Instructions |
| 25 | |
| 26 | ### Step 1 — Define Database Parameters |
| 27 | |
| 28 | Use AWS-specific parameter types for validation. |
| 29 | |
| 30 | ```yaml |
| 31 | Parameters: |
| 32 | DBInstanceClass: |
| 33 | Type: AWS::RDS::DBInstance::InstanceType |
| 34 | Default: db.t3.micro |
| 35 | AllowedValues: [db.t3.micro, db.t3.small, db.t3.medium] |
| 36 | |
| 37 | Engine: |
| 38 | Type: String |
| 39 | Default: mysql |
| 40 | AllowedValues: [mysql, postgres, aurora-mysql, aurora-postgresql] |
| 41 | |
| 42 | MasterUsername: |
| 43 | Type: String |
| 44 | Default: admin |
| 45 | AllowedPattern: "^[a-zA-Z][a-zA-Z0-9]*$" |
| 46 | MinLength: 1 |
| 47 | MaxLength: 16 |
| 48 | |
| 49 | MasterUserPassword: |
| 50 | Type: String |
| 51 | NoEcho: true |
| 52 | MinLength: 8 |
| 53 | MaxLength: 41 |
| 54 | ``` |
| 55 | |
| 56 | See [template-structure.md](references/template-structure.md) for advanced parameter patterns, mappings, conditions, and cross-stack references. |
| 57 | |
| 58 | ### Step 2 — Create DB Subnet Group |
| 59 | |
| 60 | Required for VPC deployment with subnets in different AZs. |
| 61 | |
| 62 | ```yaml |
| 63 | DBSubnetGroup: |
| 64 | Type: AWS::RDS::DBSubnetGroup |
| 65 | Properties: |
| 66 | DBSubnetGroupDescription: Subnet group for RDS |
| 67 | SubnetIds: |
| 68 | - !Ref PrivateSubnet1 |
| 69 | - !Ref PrivateSubnet2 |
| 70 | ``` |
| 71 | |
| 72 | See [database-components.md](references/database-components.md) for parameter groups, option groups, and engine-specific configurations. |
| 73 | |
| 74 | ### Step 3 — Configure Security Group |
| 75 | |
| 76 | Restrict access to application tier only. |
| 77 | |
| 78 | ```yaml |
| 79 | DBSecurityGroup: |
| 80 | Type: AWS::EC2::SecurityGroup |
| 81 | Properties: |
| 82 | GroupDescription: Security group for RDS |
| 83 | VpcId: !Ref VpcId |
| 84 | SecurityGroupIngress: |
| 85 | - IpProtocol: tcp |
| 86 | FromPort: 3306 |
| 87 | ToPort: 3306 |
| 88 | SourceSecurityGroupId: !Ref AppSecurityGroup |
| 89 | ``` |
| 90 | |
| 91 | See [security-secrets.md](references/security-secrets.md) for VPC security groups, encryption, Secrets Manager integration, and IAM authentication. |
| 92 | |
| 93 | ### Step 4 — Launch RDS Instance |
| 94 | |
| 95 | Configure instance with subnet group, security group, and settings. |
| 96 | |
| 97 | ```yaml |
| 98 | DBInstance: |
| 99 | Type: AWS::RDS::DBInstance |
| 100 | Properties: |
| 101 | DBInstanceIdentifier: !Sub "${AWS::StackName}-mysql" |
| 102 | DBInstanceClass: !Ref DBInstanceClass |
| 103 | Engine: !Ref Engine |
| 104 | MasterUsername: !Ref MasterUsername |
| 105 | MasterUserPassword: !Ref MasterUserPassword |
| 106 | AllocatedStorage: 20 |
| 107 | StorageType: gp3 |
| 108 | DBSubnetGroupName: !Ref DBSubnetGroup |
| 109 | VPCSecurityGroups: [!Ref DBSecurityGroup] |
| 110 | StorageEncrypted: true |
| 111 | MultiAZ: true |
| 112 | BackupRetentionPeriod: 7 |
| 113 | DeletionProtection: false |
| 114 | ``` |
| 115 | |
| 116 | See [database-components.md](references/database-components.md) for MySQL, PostgreSQL, Aurora cluster configurations, and parameter groups. |
| 117 | |
| 118 | ### Step 5 — Enable High Availability |
| 119 | |
| 120 | Configure multi-AZ deployment for production. |
| 121 | |
| 122 | ```yaml |
| 123 | Conditions: |
| 124 | IsProduction: !Equals [!Ref Environment, production] |
| 125 | |
| 126 | Resources: |
| 127 | DBInstance: |
| 128 | Type: AWS::RDS::DBInstance |
| 129 | Properties: |
| 130 | MultiAZ: !If [IsProduction, true, false] |
| 131 | BackupRetentionPeriod: !If [IsProduction, 35, 7] |
| 132 | DeletionProtection: !If [IsProduction, true, false] |
| 133 | EnablePerformanceInsights: !If [IsProduction, true, false] |
| 134 | ``` |
| 135 | |
| 136 | See [high-availability.md](references/high-availability.md) for multi-AZ deployments, read replicas, Aurora auto-scaling, enhanced monitoring, and disaster recovery. |
| 137 | |
| 138 | ### Step 6 — Define Outputs |
| 139 | |
| 140 | Export connection details for application stacks. |
| 141 | |
| 142 | ```yaml |
| 143 | Outputs: |
| 144 | DBInstanceEndpoint: |
| 145 | Description: Database endpoint address |
| 146 | Value: !GetAtt DBInstance.Endpoint.Address |
| 147 | Export: |
| 148 | Name: !Sub ${AWS::StackName}-DBEndpoint |
| 149 | |
| 150 | DBInstancePort: |
| 151 | Description: Database port |
| 152 | Value: !GetAtt DBInstance.Endpoint.Port |
| 153 | Export: |
| 154 | Name: !Sub ${AWS::StackName}-DBPort |
| 155 | |
| 156 | DBConn |