Creating a dashboard, configuring datasource through a lambda

I’ve configured a cloudwatch datasource through a credentials file, and added a custom namespace through the UI.
My metric is being created through a serverless projecr with data from a lambda into a custom metric. Is it possible to create a dashboard, configure a data source through the lambda/serverless project?
I’m deploying to multiple environments and it would make sense to not configure manually into different grafana environments.