Hi everyone,
Today I’ve added local overrides to the global variables in my template.yml file. This was pretty finicky – a lot of conflicting suggestions out there unfortunately. These are the settings that ended up working for me.
local-env-var-overrides.json:
{
"Parameters": {
"RDS_HOSTNAME_TEST": "192.168.0.31"
}
}
template.yaml
Globals:
Function:
Environment:
Variables:
RDS_HOSTNAME_TEST:
Type: String
Default: 'DEFAULT'
aws sam local command:
sam local start-api --env-vars "local-env-var-overrides.json"
create.js
exports.createTrapHandler = async (event, context, callback) => {
try {
console.log("RDS_HOSTNAME_TEST: " + process.env.RDS_HOSTNAME_TEST)
// Outputs: 192.168.0.31
This link ended up being pretty useful: https://www.npmjs.com/package/aws-sam-local