Repository navigation
PLAT-3409 Added genrule to detect system resources - #454
NicolasHuertas wants to merge 4 commits into
Conversation
|
I added some more metadata to the aws_instance_type and gap_machine_type genrules so it shows:
To test, we can run Is there anything else that would be useful to add? |
| genrule( | ||
| name = "get_aws_instance_type", | ||
| outs = ["aws_instance.txt"], | ||
| # Fetches key AWS instance metadata for performance comparison | ||
| cmd = "(" + | ||
| "TOKEN=$$(curl -s -X PUT 'http://169.254.169.254/latest/api/token' -H 'X-aws-ec2-metadata-token-ttl-seconds: 21600') && " + | ||
| "echo '=== AWS Instance Metadata ===' && " + | ||
| "echo 'Instance Type:' && " + | ||
| "curl -s -H \"X-aws-ec2-metadata-token: $$TOKEN\" http://169.254.169.254/latest/meta-data/instance-type && echo '' && " + | ||
| "echo 'AMI ID:' && " + | ||
| "curl -s -H \"X-aws-ec2-metadata-token: $$TOKEN\" http://169.254.169.254/latest/meta-data/ami-id && echo '' && " + | ||
| "echo 'Availability Zone:' && " + | ||
| "curl -s -H \"X-aws-ec2-metadata-token: $$TOKEN\" http://169.254.169.254/latest/meta-data/placement/availability-zone && echo '' && " + | ||
| "echo 'Instance Lifecycle:' && " + | ||
| "curl -s -H \"X-aws-ec2-metadata-token: $$TOKEN\" http://169.254.169.254/latest/meta-data/instance-life-cycle && echo '' && " + | ||
| "echo 'Instance ID:' && " + | ||
| "curl -s -H \"X-aws-ec2-metadata-token: $$TOKEN\" http://169.254.169.254/latest/meta-data/instance-id" + | ||
| ") > $@ 2>&1 || echo 'Not AWS or unavailable' > $@", |
There was a problem hiding this comment.
These are a lot of curls. What about using ec2-metadata --all?
There was a problem hiding this comment.
That command doesn't seem to be installed in the remote execution container, but it works after downloading the shell script. I've updated the genrule to do that and also made a recursive query for the GCP genrule.
anfelbar
left a comment
There was a problem hiding this comment.
One final thing. Is it possible to delete the aws downloaded binary at the end of the execution?
Using
//genrules:remote_exec_infoon a bezel test command outputs:To test with a specific example, like EngFlow's simple Java example, run: