runway.cfngin.hooks.keypair module

AWS EC2 keypair hook.

pydantic model runway.cfngin.hooks.keypair.EnsureKeypairExistsHookArgs[source]

Bases: BaseModel

Hook arguments for ensure_keypair_exists.

Show JSON schema
{
   "title": "EnsureKeypairExistsHookArgs",
   "description": "Hook arguments for ``ensure_keypair_exists``.",
   "type": "object",
   "properties": {
      "keypair": {
         "title": "Keypair",
         "type": "string"
      },
      "public_key_path": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Public Key Path"
      },
      "ssm_key_id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ssm Key Id"
      },
      "ssm_parameter_name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ssm Parameter Name"
      }
   },
   "required": [
      "keypair"
   ]
}

field keypair: str = PydanticUndefined

Name of the key pair to ensure exists.

field public_key_path: str | None = None

Path to a public key file to be imported instead of generating a new key. Incompatible with the SSM options, as the private key will not be available for storing.

field ssm_key_id: str | None = None

ID of a KMS key to encrypt the SSM parameter with. If omitted, the default key will be used.

field ssm_parameter_name: str | None = None

Path to an SSM store parameter to receive the generated private key instead of importing it or storing it locally.

class runway.cfngin.hooks.keypair.KeyPairInfo[source]

Bases: TypedDict

Value returned from get_existing_key_pair.

runway.cfngin.hooks.keypair.create_key_pair(ec2: EC2Client, keypair_name: str) KeyPairTypeDef[source]

Create keypair.

runway.cfngin.hooks.keypair.create_key_pair_from_public_key_file(ec2: EC2Client, keypair_name: str, public_key_path: Path) KeyPairInfo | None[source]

Create keypair from public key file.

runway.cfngin.hooks.keypair.create_key_pair_in_ssm(ec2: EC2Client, ssm: SSMClient, keypair_name: str, parameter_name: str, kms_key_id: str | None = None) KeyPairInfo | None[source]

Create keypair in SSM.

runway.cfngin.hooks.keypair.create_key_pair_local(ec2: EC2Client, keypair_name: str, dest_dir: Path) KeyPairInfo | None[source]

Create local keypair.

runway.cfngin.hooks.keypair.ensure_keypair_exists(context: runway.context.CfnginContext, *__args: Any, **kwargs: Any) KeyPairInfo[source]

Ensure a specific keypair exists within AWS.

If the key doesn’t exist, upload it.

runway.cfngin.hooks.keypair.get_existing_key_pair(ec2: EC2Client, keypair_name: str) KeyPairInfo | None[source]

Get existing keypair.

runway.cfngin.hooks.keypair.import_key_pair(ec2: EC2Client, keypair_name: str, public_key_data: bytes) ImportKeyPairResultTypeDef[source]

Import keypair.

runway.cfngin.hooks.keypair.interactive_prompt(keypair_name: str) tuple[Literal['create', 'import'] | None, str | None][source]

Interactive prompt.

runway.cfngin.hooks.keypair.read_public_key_file(path: Path) bytes | None[source]

Read public key file.