//TODO: Add the module include to the following assemblies
//TODO: Create related modules for OpenStack (QCOW2) and Bare Metal (ISO)

// Module included in the following assemblies:
//
// * installing/installing_aws/installing-aws-user-infra.adoc
// * installing/installing_aws/installing-restricted-networks-aws.adoc

:_mod-docs-content-type: PROCEDURE
[id="installation-aws-ami-stream-metadata_{context}"]
= Accessing {op-system} AMIs with stream metadata

[role="_abstract"]
In {product-title}, _stream metadata_ provides standardized metadata about {op-system} in the JSON format and injects the metadata into the cluster. Stream metadata is a stable format that supports multiple architectures and is intended to be self-documenting for maintaining automation.

You can use the `coreos print-stream-json` sub-command of `openshift-install` to access information about the boot images in the stream metadata format. This command provides a method for printing stream metadata in a scriptable, machine-readable format.

For user-provisioned installations, the `openshift-install` binary contains references to the version of {op-system} boot images that are tested for use with {product-title}, such as the {aws-first} AMI.

.Procedure

To parse the stream metadata, use one of the following methods:

* From a Go program, use the official `stream-metadata-go` library at https://github.com/coreos/stream-metadata-go. You can also view example code in the library.

* From another programming language, such as Python or Ruby, use the JSON library of your preferred programming language.

* From a command-line utility that handles JSON data, such as `jq`:

** Print the current `x86_64`
ifndef::openshift-origin[]
or `aarch64`
endif::openshift-origin[]
AMI for an {aws-short} region, such as `us-west-1`:
+
.For x86_64
[source,terminal]
----
$ openshift-install coreos print-stream-json | jq -r '.architectures.x86_64.images.aws.regions["us-west-1"].image'
----
+
.Example output
[source,terminal]
----
ami-0d3e625f84626bbda
----
+
ifndef::openshift-origin[]
.For aarch64
[source,terminal]
----
$ openshift-install coreos print-stream-json | jq -r '.architectures.aarch64.images.aws.regions["us-west-1"].image'
----
+
.Example output
[source,terminal]
----
ami-0af1d3b7fa5be2131
----
+
endif::openshift-origin[]
The output of this command is the {aws-short} AMI ID for your designated architecture and the `us-west-1` region. The AMI must belong to the same region as the cluster.
