Cloudwatch datasource configured via API

I’m trying to configure a CloudWatch datasource via the API with a bash script that contains:

curl -s -X POST --header "Content-Type:application/json" \
http://${GRAFANA_USER}:${GRAFANA_PASS}@${GRAFANA_HOST}/api/datasources \
--data-binary @- <<EOF

  "name": "test_aws",
  "access": "proxy",
  "type": "cloudwatch",
  "defaultRegion": "eu-west-1"

The code above works but the “Default Region” section in the GUI is always blank and hence the datasource does not work. I couldn’t find any examples of how this should be configured via the API. I’d be grateful for any pointers…

The documentation is not great for this. You have to pass the custom Cloudwatch data in the jsonData property. Something like this:

I’ll try and update the documentation to be more detailed.