runway.cfngin.lookups.handlers.ami module

AMI lookup.

class runway.cfngin.lookups.handlers.ami.AmiLookup[source]

Bases: LookupHandler[CfnginContext]

AMI lookup.

TYPE_NAME: ClassVar[str] = 'ami'

Name that the Lookup is registered as.

classmethod handle(value: str, context: runway.context.CfnginContext, **_kwargs: Any) str[source]

Fetch the most recent AMI Id using a filter.

Parameters:
  • value – Parameter(s) given to this lookup.

  • context – Context instance.

Example

The above fetches the most recent AMI where owner is self account or amazon and the ami name matches the regex described, the architecture will be either x64 or i386

You can also optionally specify the region in which to perform the AMI lookup.

classmethod parse_query(value: str) tuple[str, dict[str, str]][source]

Parse the value passed to the lookup.

This overrides the default parsing to account for special requirements.

Parameters:

value – The raw value passed to a lookup.

Returns:

The lookup query and a dict of arguments

pydantic model runway.cfngin.lookups.handlers.ami.ArgsDataModel[source]

Bases: BaseModel

Arguments data model.

Any other arguments specified are sent as filters to the AWS API. For example, architecture:x86_64 will add a filter.

Show JSON schema
{
   "title": "ArgsDataModel",
   "description": "Arguments data model.\n\nAny other arguments specified are sent as filters to the AWS API.\nFor example, ``architecture:x86_64`` will add a filter.",
   "type": "object",
   "properties": {
      "executable_users": {
         "anyOf": [
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Executable Users"
      },
      "owners": {
         "items": {
            "type": "string"
         },
         "title": "Owners",
         "type": "array"
      },
      "region": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Region"
      }
   },
   "required": [
      "owners"
   ]
}

field executable_users: list[str] | None = None

List of executable users.

field owners: list[str] = PydanticUndefined

At least one owner is required.

Should be amazon, self, or an AWS account ID.

field region: str | None = None

AWS region.

exception runway.cfngin.lookups.handlers.ami.ImageNotFound[source]

Bases: Exception

Image not found.

__init__(search_string: str) None[source]

Instantiate class.