The file .gothicCli/templates/sam-template.yaml is a SAM / CloudFormation template that defines every AWS resource created during gothic deploy. Any resource you add here is created, updated, or deleted together with your app — no extra tooling required.
The template already includes the Lambda function, CloudFront distribution, S3 bucket, and supporting resources. You can extend it by adding your own resources below the existing ones.
Add a DynamoDB table by placing a new resource in the Resources section of your SAM template:
# Add below existing Resources in sam-template.yaml
MyAppTable:
Type : AWS::DynamoDB::Table
Properties :
TableName : !Sub "${AWS::StackName}-my-table"
BillingMode : PAY_PER_REQUEST
AttributeDefinitions :
- AttributeName : PK
AttributeType : S
- AttributeName : SK
AttributeType : S
KeySchema :
- AttributeName : PK
KeyType : HASH
- AttributeName : SK
KeyType : RANGE To give your Lambda function access to the new resource, add environment variables using !Ref and !GetAtt in the GothServer → Environment.Variables section:
GothServer :
Type : AWS::Serverless::Function
Properties :
Environment :
Variables :
# ... existing auto-generated vars ...
TABLE_NAME: !Ref MyAppTable
TABLE_ARN: !GetAtt MyAppTable.Arn After deploying, your Go code can read these values with os.Getenv("TABLE_NAME") and os.Getenv("TABLE_ARN"). The same pattern works for any AWS resource — SQS queues, SNS topics, S3 buckets, and more.
Make sure the Lambda function also has the IAM permissions it needs. Add a Policies block to the GothServer resource, or create a separate AWS::IAM::Policy resource in your template.
Ready to deploy? Check out the deploy commands!