Discovering resources with Idem#

Idem can discover existing resources and let you quickly create a state file that represents them.

Even though you might write an Idem state (SLS) file from scratch, it’s often easier to start with states derived from actual resources.

Prerequisites#

Running the describe command#

To create an SLS file by discovery, use a describe command that follows this pattern:

idem describe plug-in.resource-group.resource

Where:

plug-in The provider environment from your credentials file
resource-group Resources of the same type, such as AWS EC2 or S3
resource Specific resources that you want to detect, such as EC2 subnets or S3 buckets

For example:

idem describe aws.s3.bucket

The example command creates output that contains any AWS S3 buckets that are part of the aws subscription in your credentials file. Just paste or direct the output to an SLS data file.

Filtering the describe command#

The describe command might yield a long list of results. To further refine the output, add the --filter argument.

The following example only discovers automatically named S3 buckets that start with the word production.

idem describe aws.s3.bucket --filter="[?resource[?bucket_prefix=='production']]"