|
| 1 | +AWSTemplateFormatVersion: '2010-09-09' |
| 2 | +Description: Backend Infrastructure |
| 3 | +Parameters: |
| 4 | + ProjectName: |
| 5 | + Type: String |
| 6 | + Description: The project name to use for resource naming |
| 7 | + SecretKey: |
| 8 | + Type: String |
| 9 | + Description: Application secret key |
| 10 | + EmailHost: |
| 11 | + Type: String |
| 12 | + EmailPort: |
| 13 | + Type: Number |
| 14 | + EmailUser: |
| 15 | + Type: String |
| 16 | + EmailPassword: |
| 17 | + Type: String |
| 18 | + FrontendUrl: |
| 19 | + Type: String |
| 20 | +Resources: |
| 21 | + RDSDatabase: |
| 22 | + Type: AWS::RDS::DBInstance |
| 23 | + Properties: |
| 24 | + # Specify other properties as required for your use case |
| 25 | + DBName: !Sub '${ProjectName}-db' |
| 26 | + MasterUsername: admin |
| 27 | + Engine: postgres # Example, adjust based on your requirements |
| 28 | + MasterUserPassword: !Ref DBPassword # This parameter will be auto-generated; see Outputs below |
| 29 | + DBInstanceClass: db.t3.micro # Example, adjust based on your requirements |
| 30 | + AllocatedStorage: 20 # Example, adjust based on your requirements |
| 31 | + Secrets: |
| 32 | + Type: AWS::SecretsManager::Secret |
| 33 | + Properties: |
| 34 | + Name: !Sub '${ProjectName}-backend-secrets' |
| 35 | + Description: 'Backend secrets' |
| 36 | + SecretString: !Sub | |
| 37 | + { |
| 38 | + "SECRET_KEY": "${SecretKey}", |
| 39 | + "DB_NAME": "${RDSDatabase.DBName}", |
| 40 | + "DB_HOST": "${RDSDatabase.Endpoint.Address}", |
| 41 | + "DB_USER": "${RDSDatabase.MasterUsername}", |
| 42 | + "DB_PORT": "5432", # Example, adjust based on your RDS engine |
| 43 | + "DB_PASSWORD": "${RDSDatabase.MasterUserPassword}", |
| 44 | + "EMAIL_HOST": "${EmailHost}", |
| 45 | + "EMAIL_PORT": "${EmailPort}", |
| 46 | + "EMAIL_USER": "${EmailUser}", |
| 47 | + "EMAIL_PASSWORD": "${EmailPassword}", |
| 48 | + "FRONTEND_URL": "${FrontendUrl}" |
| 49 | + } |
| 50 | +
|
| 51 | + BackendBucket: |
| 52 | + Type: 'AWS::S3::Bucket' |
| 53 | + Properties: |
| 54 | + BucketName: !Sub '${ProjectName}-backend' |
| 55 | + |
| 56 | + TerraformStateBucket: |
| 57 | + Type: 'AWS::S3::Bucket' |
| 58 | + Properties: |
| 59 | + BucketName: !Sub '${ProjectName}-terraform' |
| 60 | + VersioningConfiguration: |
| 61 | + Status: Enabled |
| 62 | + |
| 63 | + RedirectBucket: |
| 64 | + Type: 'AWS::S3::Bucket' |
| 65 | + Properties: |
| 66 | + BucketName: !Sub '${ProjectName}-redirect' |
| 67 | + WebsiteConfiguration: |
| 68 | + RedirectAllRequestsTo: |
| 69 | + HostName: "www.example.com" |
| 70 | + |
| 71 | + ZappaBucket: |
| 72 | + Type: 'AWS::S3::Bucket' |
| 73 | + Properties: |
| 74 | + BucketName: !Sub 'zappa-${ProjectName}' |
| 75 | +Outputs: |
| 76 | + DBPassword: |
| 77 | + Description: "The RDS database master user password" |
| 78 | + Value: !Ref MasterUserPassword |
| 79 | + RDSEndpoint: |
| 80 | + Description: "The RDS database endpoint" |
| 81 | + Value: !GetAtt RDSDatabase.Endpoint.Address |
0 commit comments