Creating Composite Documents

A composite SSM document is a custom document that performs a
series of actions by running one or more secondary SSM documents. Composite documents
promote infrastructure as code by enabling you to create a standard
set of SSM documents for common tasks such as boot-strapping software or
domain-joining instances. You can then share these documents across AWS accounts to
reduce SSM document maintenance and ensure consistency.

For example, you can create a composite document that performs the following
actions:

Updates SSM Agent to the latest version.

Installs all whitelisted patches.

Installs antivirus software.

Downloads scripts from GitHub and runs them.

In this example, your custom SSM document includes the following plugins to perform
these actions:

The aws:runDocument plugin to run the
AWS-UpdateSSMAgent document, which updates SSM Agent to the
latest version.

The aws:runDocument plugin to run the AWS-ApplyPatchBaseline
document, which installs all whitelisted patches.

The aws:runDocument plugin to run the AWS-InstallApplication
document, which installs the antivirus software.

The aws:downloadContent plugin to download scripts from GitHub
and run them.

Composite and secondary documents can be stored in Systems Manager, GitHub (public
and private
repositories), or Amazon S3. Composite documents and secondary documents can be created
in
JSON or YAML.

Note

Composite documents can only run to a maximum depth of three documents. This means
that a composite document can call a child document; and that child document can
call one last document.

Create a Composite Document

To create a composite document, add the aws:runDocument plugin in a custom SSM document and specify
the required inputs. The following is an example of a composite document that
performs the following actions:

Runs the aws:downloadContent plugin to download an SSM
document from a GitHub public repository to a local directory called
bootstrap. The SSM document is called StateManagerBootstrap.yml (a YAML
document).

Runs the aws:runDocument plugin to run the
StateManagerBootstrap.yml document. No parameters are specified.

Runs the aws:runDocument plugin to run the
AWS-ConfigureDocker pre-defined SSM document. The specified parameters
install Docker on the instance.