Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump all metadata to a file #174

Open
bwagner5 opened this issue Jun 1, 2022 · 3 comments
Open

Dump all metadata to a file #174

bwagner5 opened this issue Jun 1, 2022 · 3 comments
Labels
enhancement New feature or request stalebot-ignore To NOT let stalebot update or close the Issue / PR

Comments

@bwagner5
Copy link
Contributor

bwagner5 commented Jun 1, 2022

Describe the feature
A concise description of the feature and desired behavior.

AL2 dumps all the metadata to a file on the instance which is useful for looking at what's available globally or for quick access without having to use HTTP (or for when the metadata endpoint is restricted).

It would be useful to be able to generate this file with ec2-metadata-mock.

$ cat  /run/cloud-init/instance-data.json
{
 "base64_encoded_keys": [],
 "ds": {
  "_doc": "EXPERIMENTAL: The structure and format of content scoped under the 'ds' key may change in subsequent releases of cloud-init.",
  "_metadata_api_version": "2016-09-02",
  "dynamic": {
   "instance-identity": {
    "document": {
     "accountId": "xxxxxxxxxxxxxxxxx",
     "architecture": "x86_64",
     "availabilityZone": "us-west-2c",
     "billingProducts": null,
     "devpayProductCodes": null,
     "imageId": "ami-03af6523db112033e",
     "instanceId": "i-019f3238ddb9db5c1",
     "instanceType": "m5.4xlarge",
     "kernelId": null,
     "marketplaceProductCodes": null,
     "pendingTime": "2022-04-27T17:56:39Z",
     "privateIp": "192.168.8.35",
     "ramdiskId": null,
     "region": "us-west-2",
     "version": "2017-09-30"
    },
    "pkcs7": [
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    ],
    "rsa2048": [
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    ],
    "signature": [
     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    ]
   }
  },
  "meta-data": {
   "ami-id": "ami-03af6523db112033e",
   "ami-launch-index": "0",
   "ami-manifest-path": "(unknown)",
   "block-device-mapping": {
    "ami": "xvda",
    "root": "/dev/xvda"
   },
   "hostname": "ip-192-168-8-35.us-west-2.compute.internal",
   "iam": {
    "info": {
     "Code": "Success",
     "InstanceProfileArn": "arn:aws:iam::xxxxxxxxxxxx:instance-profile/xxxxxxxxxxxxxxxxx",
     "InstanceProfileId": "xxxxxxxxxxxxxxxxxxxxxxxx",
     "LastUpdated": "2022-04-27T17:56:40Z"
    }
   },
   "instance-action": "none",
   "instance-id": "i-019f3238ddb9db5c1",
   "instance-type": "m5.4xlarge",
   "local-hostname": "ip-192-168-8-35.us-west-2.compute.internal",
   "local-ipv4": "192.168.8.35",
   "mac": "xxxxxxxxxxxxxxxx",
   "metrics": {
    "vhostmd": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
   },
   "network": {
    "interfaces": {
     "macs": {
      "xxxxxxxxxxxxx": {
       "device-number": "0",
       "interface-id": "eni-xxxxxxxxxxxxxx",
       "ipv4-associations": {
        "xxxxxxxxxxxxxxx": "192.168.8.35"
       },
       "local-hostname": "ip-192-168-8-35.us-west-2.compute.internal",
       "local-ipv4s": "192.168.8.35",
       "mac": "xxxxxxxxxxxxx",
       "owner-id": "xxxxxxxxxxxxxx",
       "public-hostname": "ec2-xxxxxxxxx.us-west-2.compute.amazonaws.com",
       "public-ipv4s": "xxxxxxxxxxxxxxxxx",
       "security-group-ids": "xxxxxxxxxxxxxxxxxx",
       "security-groups": "xxxxxxxxxxxxxxxxxxxxxxxxx",
       "subnet-id": "subnet-0e1c2770e9430751e",
       "subnet-ipv4-cidr-block": "192.168.0.0/19",
       "vpc-id": "vpc-02e676af1f39c5f08",
       "vpc-ipv4-cidr-block": "192.168.0.0/16",
       "vpc-ipv4-cidr-blocks": "192.168.0.0/16"
      }
     }
    }
   },
   "placement": {
    "availability-zone": "us-west-2c"
   },
   "profile": "default-hvm",
   "public-hostname": "ec2-xxxxxxxxxxxxxxx.us-west-2.compute.amazonaws.com",
   "public-ipv4": "xxxxxxxxxxxx,
   "reservation-id": "r-067e0510e77dcf3d6",
   "security-groups": "xxxxxxxxxxxxxxxx",
   "services": {
    "domain": "amazonaws.com",
    "partition": "aws"
   }
  }
 },
 "sensitive_keys": [],
 "v1": {
  "_beta_keys": [
   "subplatform"
  ],
  "availability-zone": "us-west-2c",
  "availability_zone": "us-west-2c",
  "cloud-name": "aws",
  "cloud_name": "aws",
  "instance-id": "i-019f3238ddb9db5c1",
  "instance_id": "i-019f3238ddb9db5c1",
  "local-hostname": "ip-192-168-8-35",
  "local_hostname": "ip-192-168-8-35",
  "platform": "ec2",
  "public_ssh_keys": [],
  "region": "us-west-2",
  "subplatform": "metadata (http://169.254.169.254)"
 }
}

Is the feature request related to a problem?
A description of what the problem is. For example: I'm frustrated when [...]

It may be desirable to rely on this file instead of using an HTTP client to receive metadata for various reasons. So making it easier to test with this file is useful.

Describe alternatives you've considered
A description of any alternative solutions or features you've considered.

Could construct this manually, but it's a pain.

@bwagner5 bwagner5 added the enhancement New feature or request label Jun 1, 2022
@github-actions
Copy link

github-actions bot commented Jul 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want this issue to never become stale, please ask a maintainer to apply the "stalebot-ignore" label.

@github-actions github-actions bot added the stale Issues / PRs with no activity label Jul 2, 2022
@bwagner5
Copy link
Contributor Author

bwagner5 commented Jul 5, 2022

If all the data is available, cloud-init will dump it w/ this CLI command: https://cloudinit.readthedocs.io/en/latest/topics/cli.html#:~:text=dump%3A%20machine%2Dreadable%20JSON%20dump%20of%20all%20cloud%2Dinit%20tracked%20events

cloud-init analyze dump

@bwagner5 bwagner5 removed the stale Issues / PRs with no activity label Jul 5, 2022
@github-actions
Copy link

github-actions bot commented Aug 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want this issue to never become stale, please ask a maintainer to apply the "stalebot-ignore" label.

@github-actions github-actions bot added the stale Issues / PRs with no activity label Aug 4, 2022
@snay2 snay2 added stalebot-ignore To NOT let stalebot update or close the Issue / PR and removed stale Issues / PRs with no activity labels Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stalebot-ignore To NOT let stalebot update or close the Issue / PR
Projects
None yet
Development

No branches or pull requests

2 participants