Aws.ec2metadata
Access to EC2 Instance Metadata
Install / Use
/learn @cloudyr/Aws.ec2metadataREADME
Get EC2 Instance Metadata
aws.ec2metadata is a package for retrieving Amazon EC2 instance metadata from within the running instance. The package simply contains a single R list, metadata, that contains a number of functions for retrieving metadata from within an instance. Most of these functions return character strings, but some will return lists; they default to NULL if no value is returned.
library("aws.ec2metadata")
# get instance id
metadata$instance_id()
# get ami id
metadata$ami_id()
# check for IAM role (NULL if none specified)
(role <- metadata$iam_info())
# get role credentials
if (!is.null(role)) {
metadata$iam_role("myrole")
}
# get an arbitrary metadata item
metadata$item("meta-data/placement/availability-zone")
Installation
This package is on CRAN, but to install the latest development version you can install from the cloudyr drat repository:
# latest stable version
install.packages("aws.ec2metadata", repos = c(cloudyr = "http://cloudyr.github.io/drat", getOption("repos")))
Or, to pull a potentially unstable version directly from GitHub:
if (!require("remotes")) {
install.packages("remotes")
}
remotes::install_github("cloudyr/aws.ec2metadata")
IMDSv2 support
For IMDSv2, a token is required. Details in aws support here. Set environment variable USE_IMDS_TOKEN to "TRUE" to use this feature.
Sys.setenv(USE_IMDS_TOKEN="TRUE")
Related Skills
tmux
347.6kRemote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
claude-opus-4-5-migration
108.4kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
diffs
347.6kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
blogwatcher
347.6kMonitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.


