Hello - I’m currently using Open OnDemand in AWS.
With the correct instance role attached to the EC2 where OoD is running I should be able to run an AWS CLI command when a user logs in.
Example - When a user logs in run the command ‘aws s3 ls’ and provide that output somewhere in the OoD console.
How would I go about this ? Thanks
In the console like in the shell app? Maybe add it to /etc/profile.d
or maybe set it as the Message of the Day in /etc/motd
(I’ve never setup a shell’s MOTD, so I’m not 100% sure how to do that).
Sorry no. On the landing page of OoD. I should have been clearer.
Somewhere on the page like the below.
OK you can either use one of our ERB formats for the MOTD.
You’d put something like this in there so that the command’s output is rendered as a part of the MOTD.
<%= `aws s3 ls` %>
Or do the same thing with a generic widget.
https://osc.github.io/ood-documentation/latest/customizations.html?#custom-layouts-in-the-dashboard
1 Like
If anyone would like to do the same. Adding the below to /etc/motd did the trick. This will show 3 months AWS of costs for the logged in user, including the current month.
<%= aws ce get-cost-and-usage --time-period Start=$(date -d "-2 months" +%Y-%m-01),End=$(date +%Y-%m-%d) --granularity MONTHLY --metrics "BlendedCost" --group-by Type=TAG,Key=Name --filter '{"Tags": { "Key": "Name", "Values": [ "OoD-'$USER'" ] }}' | grep Amount
%>
1 Like