Basic express application shown below, AWS credentials redacted, when I run this locally using node index.js
it works perfectly and the record is created on the live DB table.
However, when I push into my ECS cluster I get the following error:
{"success":false,"response":"Error: Unable to connect to instance metadata service"}
Any suggestions on how to diagnose this or better troubleshoot.
Index.js
const express = require('express')
const app = express()
const port = 80
const AWS = require("aws-sdk");
AWS.config.update({
region: "eu-west-2",
accessKeyId: 'ACCESS KEY',
secretAccessKey: 'SECRET KEY',
});
const uuidv4 = require('uuid');
app.get('/raise/create', (req, res) => {
const {DynamoDBClient, PutItemCommand} = require("@aws-sdk/client-dynamodb")
const REGION = "eu-west-2";
const params = {
TableName: "table name",
Item: {
uuid: {S: uuidv4.v4()}
}
}
const dbclient = new DynamoDBClient({region: REGION});
const run = async () => {
try {
const data = await dbclient.send(new PutItemCommand(params));
res.send({
success: true,
response: data.toString()
});
} catch (err) {
res.send({
success: false,
response: err.toString()
});
}
}
run();
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
EDIT
I am running via Fargate if it makes a difference