{"id":15010071,"url":"https://github.com/outcompute/cloudmetadata","last_synced_at":"2026-03-14T16:50:34.500Z","repository":{"id":57034054,"uuid":"82111757","full_name":"outcompute/CloudMetaData","owner":"outcompute","description":"Get metadata JSON within an instance from 169.254.169.254 across providers.","archived":false,"fork":false,"pushed_at":"2018-09-21T12:05:21.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T17:17:31.536Z","etag":null,"topics":["aws","azure","cloud-management","composer-packages","digitalocean","google-cloud-platform","metadata-parser","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outcompute.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-15T22:08:10.000Z","updated_at":"2023-05-17T17:55:32.000Z","dependencies_parsed_at":"2022-08-24T14:52:52.687Z","dependency_job_id":null,"html_url":"https://github.com/outcompute/CloudMetaData","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outcompute%2FCloudMetaData","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outcompute%2FCloudMetaData/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outcompute%2FCloudMetaData/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outcompute%2FCloudMetaData/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outcompute","download_url":"https://codeload.github.com/outcompute/CloudMetaData/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258505,"owners_count":20262300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","azure","cloud-management","composer-packages","digitalocean","google-cloud-platform","metadata-parser","php"],"created_at":"2024-09-24T19:29:47.329Z","updated_at":"2025-12-26T17:02:10.112Z","avatar_url":"https://github.com/outcompute.png","language":"PHP","readme":"# CloudMetaData\r\nA simple PHP library to fetch instance meta data from the link local address of http://169.254.169.254 from within an instance.\r\n  - Supports [AWS][awsmetadata], [Azure][azuremetadata], [DigitalOcean][dometadata] \u0026 [Google Cloud][gcpmetadata].\r\n  - Results can be cached in a file.\r\n  - Always refreshes metadata after a restart.\r\n\r\nThe 169.254.169.254 is a link-local address and you can read up more about them [here][wikilinklocal].\r\n\r\n\r\n### Installation\r\nAdd this line to your composer.json file,\r\n```json\r\n\"outcompute/cloudmetadata\": \"1.5.0\"\r\n```\r\nand run.\r\n```sh\r\n$ composer update\r\n```\r\nIn case you don't want to use composer, you'll have to include all the files, something like this:\r\n```php\r\ninclude_once('src/Cache/AbstractCache.php');\r\ninclude_once('src/Cache/File.php');\r\ninclude_once('src/CacheFactory.php');\r\ninclude_once('src/Provider/AbstractProvider.php');\r\ninclude_once('src/Provider/AWS.php');\r\ninclude_once('src/Provider/Azure.php');\r\ninclude_once('src/Provider/DigitalOcean.php');\r\ninclude_once('src/Provider/GCP.php');\r\ninclude_once('src/ProviderFactory.php');\r\ninclude_once('src/TemplateParser/Base.php');\r\ninclude_once('src/TemplateParser/AWS.php');\r\ninclude_once('src/TemplateParser/Azure.php');\r\ninclude_once('src/TemplateParser/DigitalOcean.php');\r\ninclude_once('src/TemplateParser/GCP.php');\r\ninclude_once('src/TemplateParserFactory.php');\r\ninclude_once('src/MetaData.php');\r\n```\r\n\r\n\r\n### How to use\r\nWithout cache\r\n```php\r\n\u003c?php\r\ninclude_once('vendor/autoload.php');\r\n\r\n$metaObject = new OutCompute\\CloudMetaData\\MetaData();\r\n$metaData = $metaObject-\u003eget();\r\nvar_export($metaData);\r\n?\u003e\r\n```\r\n\r\nWith cache (only 'File' available at the moment)\r\n```php\r\n\u003c?php\r\ninclude_once('vendor/autoload.php');\r\n\r\n$cache = OutCompute\\CloudMetaData\\CacheFactory::factory('File');\r\n$cache-\u003edirectory = dirname(__FILE__);\r\n$metaObject = new OutCompute\\CloudMetaData\\MetaData($cache);\r\n$metaData = $metaObject-\u003eget('json');\r\nvar_export($metaData);\r\n?\u003e\r\n```\r\n\r\n### Templated Responses\r\nIf you've cross cloud deployments and use the metadata in any way, then it'd help to have the metadata in a consistent manner.\r\nSupport has been added for templates which allows you to specify templates and tokens. A few sample tokens have been provided.\r\nCommon and provider agnostic tokens are processed in `src/TemplateParser/Base.php` whereas provider specific tokens are parsed in their specific handlers present in `src/TemplateParser`.\r\n\r\nThe templates have to be stored in the templates directory, and the file name provided as the second argument to `OutCompute\\CloudMetaData\\MetaData()::get()`.\r\n```php\r\n\u003c?php\r\ninclude_once('vendor/autoload.php');\r\n\r\n$metaObject = new OutCompute\\CloudMetaData\\MetaData();\r\n$metaData = $metaObject-\u003eget('json', 'basic.json');\r\nvar_export($metaData);\r\n?\u003e\r\n```\r\nThe tokens don't have to follow the heirarchy from the templates they are included in and can be any string as long as they are handled in any parser. The initial set of supported tokens seem to follow the heirarchy in basic.json with a dot(.) as a separator, but that is not a strict requirement.\r\n\r\nHowever, if you're contributing to the repository then it'd be great if the tokens followed some structure.\r\n\r\n### TODO\r\n\r\n - Add other cloud providers, eg: Linode, etc.\r\n - Add test cases\r\n - General improvements\r\n - Supporting templates in varied configurations and extending the set of supported tokens\r\n\r\nLicense\r\n----\r\n\r\nMIT\r\n\r\n   [awsmetadata]: \u003chttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html\u003e\r\n   [azuremetadata]: \u003chttps://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service\u003e\r\n   [dometadata]: \u003chttps://developers.digitalocean.com/documentation/metadata/\u003e\r\n   [gcpmetadata]: \u003chttps://cloud.google.com/compute/docs/storing-retrieving-metadata\u003e\r\n   [wikilinklocal]: \u003chttps://en.wikipedia.org/wiki/Link-local_address\u003e\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutcompute%2Fcloudmetadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutcompute%2Fcloudmetadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutcompute%2Fcloudmetadata/lists"}