ive gone through the book and while i like the idea (signed up for the vids as well!:)) , but still feel rather lost on how to use the cfc-modules (Maybe becasue i dont use clouformation?). Is there an example for say wordpress, where theres a db and a container talking.
apologies if this isnt the best place to ask… please let me where if theres somewhere better.
All of the examples do exactly what you are looking for: connect an application with a MySQL database (provided by RDS Aurora Serverless). I believe that the PHP example comes closest to WordPress. Pages 35 ff. and 74 ff. are explaining how you configure your app to use the database and how it works. But I suggest to go trough chapter 1-3.
Let me know if this helps. Otherwise, a more concret question (what have you tried? where are you stuck? what is your goal? how does your Dockerfile look like?) would help to guide you.
So im basically piecing together the ec2-rds example and the fargate example. to load wordpress using the latest image from docker hub and rds postgres as the backend.
im now getting the error:
An error occurred (ValidationError) when calling the CreateChangeSet operation: [/Resources/Service/ClientSg] 'null' values are not allowed in templates
Any assistance in getting it working would be greatly appricated!
This is my current config.
EXAMPLE.YML
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'cfn-modules: Fargate ALB to single container example'
Resources:
Alerting:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
Email: 'stebennettsjb@gmail.com' # replace with your email address to receive alerts
# HttpsEndpoint: 'https://api.marbot.io/v1/endpoint/xyz' # or uncommnet and receive alerts in Slack using marbot.io
TemplateURL: './node_modules/@cfn-modules/alerting/module.yml'
Vpc:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
AlertingModule: !GetAtt 'Alerting.Outputs.StackName'
S3Endpoint: 'false' # speed up the example
DynamoDBEndpoint: 'false' # speed up the example
FlowLog: 'false' # speed up the example
NatGateways: 'false' # speed up the example
TemplateURL: './node_modules/@cfn-modules/vpc/module.yml'
Cluster:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: './node_modules/@cfn-modules/ecs-cluster/module.yml'
Alb:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
AlertingModule: !GetAtt 'Alerting.Outputs.StackName'
TemplateURL: './node_modules/@cfn-modules/alb/module.yml'
AlbListener:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
AlbModule: !GetAtt 'Alb.Outputs.StackName'
TemplateURL: './node_modules/@cfn-modules/alb-listener/module.yml'
Target:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
AlbModule: !GetAtt 'Alb.Outputs.StackName'
AlbListenerModule: !GetAtt 'AlbListener.Outputs.StackName'
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
AlertingModule: !GetAtt 'Alerting.Outputs.StackName'
TemplateURL: './node_modules/@cfn-modules/ecs-alb-target/module.yml'
Service:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
ClusterModule: !GetAtt 'Cluster.Outputs.StackName'
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
TargetModule: !GetAtt 'Target.Outputs.StackName'
AlertingModule: !GetAtt 'Alerting.Outputs.StackName'
ClientSgModule1: !GetAtt 'ClientSg.Outputs.StackName'
AppImage: 'wordpress:latest'
AppEnvironment1Key: 'WORDPRESS_DB_HOST' # optional
AppEnvironment1SecretModule: !GetAtt 'Database.Outputs.DnsName'
AppEnvironment2Key: 'WORDPRESS_DB_USER' # optional
AppEnvironment2Value: 'wp' # optional
AppEnvironment3Key: 'WORDPRESS_DB_PASSWORD' # optional
AppEnvironment3Value: 'insecure' # optional
AppEnvironment4Key: 'WORDPRESS_DB_NAME' # optional
AppEnvironment4Value: 'wordpress' # optional
AppPort: '80'
TemplateURL: './node_modules/@cfn-modules/fargate-service/module.yml'
ClientSg:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
TemplateURL: './node_modules/@cfn-modules/client-sg/module.yml'
Database:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
ClientSgModule: !GetAtt 'ClientSg.Outputs.StackName'
AlertingModule: !GetAtt 'Alerting.Outputs.StackName'
DBName: 'wordpress'
DBMasterUsername: 'wp'
DBMasterUserPassword: insecure
DBBackupRetentionPeriod: '0' # speed up the example (do not set to 0 in production!)
DBMultiAZ: 'false' # speed up the example (do not set to false in production!)
TemplateURL: './node_modules/@cfn-modules/rds-postgres/module.yml'
Outputs:
Url:
Value: !Sub 'http://${Alb.Outputs.DnsName}'
Waiting for changeset to be created..
Waiting for stack create/update to complete
Failed to create/update the stack. Run the following command
to fetch the list of events leading up to the failure
aws cloudformation describe-stack-events --stack-name wordpress
running: aws cloudformation describe-stack-events --stack-name wordpress outputs to big to post in here.
Logical ID: Service
Status: CREATE_FAILED
Status Reason: Embedded stack arn:aws:cloudformation:us-east-1:066566280911:stack/wordpress-Service-1LTY48HDL73AW/b24083b0-51be-11ea-9970-0a34514375d1 was not successfully created: No export named wd1rzjzrew9l0d8.ceulecjjsvw3.us-east-1.rds.amazonaws.com-Arn found