Key_Pair_Operations for the Amazon EC2 REST adapter

This topic illustrates the adapter requests and responses for Key pair operations.

Create Key Pair operation

The Create Key Pair operation enables you to create a new 2048-bit RSA key pair. 

For a key pair, Amazon EC2 stores the public key and the private key is displayed on the console. The Create Key Pair operation returns the private key in the form of an unencrypted PEM-encoded PKCS#8 private key.

Note

If a key with the specified name already exists in Amazon EC2, the operation returns an error in the adapter response.

The following figure shows a sample <items> XML element for the Create Key Pair operation. 

Sample <items> XML element for the Create Key Pair operation 

<items>
    <item>
        <parameters>
            <key-name></key-name>
        </parameters>
    </item>
</items>

The following table describes the elements for this adapter request. 

Adapter request elements for the Create Key Pair operation 

Element

Definition

Required

<access-key>

Specifies the Amazon Web Services (AWS) access key

You need to generate the AWS access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Access Key is specified, the adapter ignores the value.
<secret-key>

Specifies the AWS secret access key

You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Secret Access Key is specified, the adapter ignores the value.
<region>

Specifies the region with which you want the adapter to communicate

Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions.

Valid values:

  • us-east-1
  • us-west-2 (default)
  • us-west-1
  • eu-west-1
  • ap-southeast-1
  • ap-northeast-1
  • ap-southeast-2
  • sa-east-1
No

<operation-name>

Contains the name of the operation: create-key-pair

Yes

<key-name>

Specifies a unique name for the key pair

Yes

The following figure shows a sample adapter request for the Create Key Pair operation. 

Sample adapter request for the Create Key Pair operation 

<amazon-ec2-rest-request>
    <operation-name>create-key-pair</operation-name>
    <access-key>AKIA**********N8BT2Q</access-key>
    <secret-key>WQisk8Irh********************8AiJx3VQVd</secret-key>
    <region>us-east-1</region>   
    <parameters>
        <key-name>TestKey</key-name>
    </parameters>
</amazon-ec2-rest-request>

The following figure shows the response for the sample Create Key Pair operation. 

Sample adapter response for the Create Key Pair operation 

<amazon-ec2-rest-response>
    <metadata>
        <status>success</status>
    </metadata>
    <CreateKeyPairResponse>
        <keyName>TestKey</keyName>
        <keyFingerprint>10:36:24:a7:79:78:35:d3:26:a5:a8:0a:19:bf:c9:4c:00:6f:1d:61</keyFingerprint>
        <keyMaterial>---BEGIN RSA PRIVATE KEY---
            MIIEpAIBAAKCAQEAohkMgW0It6VKcE/V2PJqQEYVM9hp7oD//mvQ/MPRkLwkWTdZ0dYj11V9MtAj
            34V1bHSmWzF6C221mrH5cs5qhg+dXZWeakQRC20nCdxcs3LpuoSXiD+D9YEgSwQpNyNuEc53L6u4
            fzIKVZZI/N8z/CQP70merZz39X4hE5DPdPD2Nkr2ALz58cyxjdU5GVwaHqvBDwY7lBXuRgWN2/06
            UwOS44GeXtGEMjXcWmxE2VWkUzFZtLAhjBIgxBqZu2FfS2d/JWXdUAF5zWp0yJXW8LQS/eNN5fMi
            DZ6besW+mU7wS0NXqjZLguB6VujzPpcd1WuD+wKPbcshdNGPYyU/fwIDAQABAoIBAHo/zfCmXJaz
            8An4C92MJZnHwSHSq0GWxHoKshiPTjOL0RX/6puYlntGHCAAXa2rpz1eVEAedl68JORAKVLuXeQx
            TotP1aNrJjep4HFNYhRsK93hNa8px8mV0tcAklzlOZPwVG79YS18fdLCftVHOJuGTwY2TZe99DuP
            Hj71TaBxC/XZS1B8XFbaK3vtnbREPOD3YBQCMw3pyyWFuTEqT/Cctr67VdgQVJ5a9t+DAh4xmHkC
            dWKLZNGsdU/g95JzOA3wqQq35SsEObaVYzEwUM7svqdVtPR5gA/Q1QtF8xZQpRKtA31GxjkKn5Kr
            RK/j+RBAknlrSfsope/rbqsfkUECgYEA6ak9CBHp//2Nbvy1Ms3Ra0OyzOOebjn3aaE/DlCmqI9b
            KiZ9Yg+ENxxiTuIRH/K/yEA6Zf2RqPqjUYX8U8kv5vbniiOuKSdeP8icPWLnRuU6aoNWD37whZx1
            3Oqb9t8FDHeOGuvfwDi4pwsW9/bGotuVxxdejIdprzGpSFXd2S8CgYEAsZhUKtA8ZRRrVeLCD4vU
            WYh2XSPCWA6xB3r4/oeZ5Yrd6pHPH1bHussEM70b2mH+IQ0OJMJ1QD255XCocX98HSJudKxa8LEJ
            Ye1wwmaLUlc2LAQQhVbeX3EfmnY1foe6Zr8dLYZWHJMRT/A46UAAFcSiJYuh7APGqF0xTBANyrEC
            gYEA16jkM7aVCziyeWW0uBdO2nm5ZXIQoBvQRyYUVNoLeDgYJGcyAnffyB3ifnwY4ivi5qihPdEz
            x4rNgkjwA0UFeV8ZhV45OLKlQqmdyuqmG8EmkXh2zgaTaD5oamX/XXOp7T/LYP2jnn67rzGFGYgi
            /d09+GuRUJMK8DAd1i2qfPECgYA/liPkpGRLaLE5shP7jvw8BmEi3g/SiYgW/o+ySojup/bm6sf3
            F5IxrkjV4YrceSONX+hFfx6OHsu1e83DvXqJz+8udRumfCy41FQANskBdVpfDiGALGc4Uv+WxWZH
            5H74FMt0plmkp3+WWJN36ENfh+TqfoE+SOfTFnL1IfZeMQKBgQDYoGGI//Tqivprn1RXqmsmfyvu
            g7Wk8/pjZ4A72yuDHpKzwNkEJZFdyNHVL/pYKCKUCARjd7+ev1KSSEknTVhB1uW85VmFH7eHQh52
            BcjvzB2l7o9jPhk/fWMAUu9SIFDYpQpouF7jh4H7CaKseEoJx25NSW5WXlCLhcLvlNA+sQ==
            ---END RSA PRIVATE KEY---
        </keyMaterial>
    </CreateKeyPairResponse>
</amazon-ec2-rest-response>

 Back to top

Describe Key Pairs operation

The Describe Key Pairs operation enables you to retrieve information about key pairs available to you. If you specify the required key pairs, the operation returns information about the specified key pairs. If you do not specify any key pairs, the operation returns information about all registered key pairs available to you. 

The following figure shows a sample <items> XML element for the Describe Key Pairs operation. 

Sample <items> XML element for the Describe Key Pairs operation 

<items>
    <item>
        <parameters>
            <key-set>
                <!--Zero or more repetitions:-->
                <item>
                    <key-name>Test API key</key-name>
                </item>
            </key-set>
        </parameters>
    </item>
</items>

The following table describes the elements for this adapter request. 

Adapter request elements for the Describe Key Pairs operation 

Element

Definition

Required

<access-key>

Specifies the Amazon Web Services (AWS) access key

You need to generate the AWS access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Access Key is specified, the adapter ignores the value.
<secret-key>

Specifies the AWS secret access key

You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Secret Access Key is specified, the adapter ignores the value.
<region>

Specifies the region with which you want the adapter to communicate

Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions.

Valid values:

  • us-east-1
  • us-west-2 (default)
  • us-west-1
  • eu-west-1
  • ap-southeast-1
  • ap-northeast-1
  • ap-southeast-2
  • sa-east-1
No

<operation-name>

Contains the name of the operation: describe-key-pair

Yes

<key-set>

Contains the key pairs with key names that you want to query

Yes

The following figure shows a sample adapter request for the Describe Key Pairs operation. 

Sample adapter request for the Describe Key Pairs operation 

<amazon-ec2-rest-request>
    <operation-name>describe-key-pairs</operation-name>
    <access-key>AKIA**********N8BT2Q</access-key>
    <secret-key>WQisk8Irh*******************8AiJx3VQVd</secret-key>
    <region>us-east-1</region>   
    <parameters>
        <key-set>
            <!Zero or more repetitions:>
            <item>
                <key-name>TestKey</key-name>
            </item>
            <item>
                <key-name>Demo</key-name>
            </item>
        </key-set>
    </parameters>
</amazon-ec2-rest-request>

The following figure shows the response for the sample Describe Key Pairs operation. 

Sample adapter response for the Describe Key Pairs operation 

<amazon-ec2-rest-response>
    <metadata>
        <status>success</status>
    </metadata>
    <DescribeKeyPairsResponse>
        <keySet>
            <item>
                <keyName>Demo</keyName>
                <keyFingerprint>f6:68:4b:4d:08:87:17:b7:98:f2:90:ce:52:15:ee:fa:7d:50:1b:b5</keyFingerprint>
            </item>
            <item>
                <keyName>TestKey</keyName>
                <keyFingerprint>10:36:24:a7:79:78:35:d3:26:a5:a8:0a:19:bf:c9:4c:00:6f:1d:61</keyFingerprint>
            </item>
        </keySet>
    </DescribeKeyPairsResponse>
</amazon-ec2-rest-response>

Back to top

Delete Key Pair operation

The Delete Key Pair operation enables you to delete the specified key pair, by removing the public key from Amazon EC2. You can delete a key pair only if you own it. 

The following figure shows a sample <items> XML element for the Delete Key Pair operation. 

Sample <items> XML element for the Delete Key Pair operation 

items>
    <item>
        <parameters>
            <key-name></key-name>
        </parameters>
    </item>
</items>

The following table shows the elements for this adapter request. 

Adapter request elements for the Delete Key Pair operation 

Element

Definition

Required

<access-key>

Specifies the Amazon Web Services (AWS) access key

You need to generate the AWS access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Access Key is specified, the adapter ignores the value.
<secret-key>

Specifies the AWS secret access key

You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Secret Access Key is specified, the adapter ignores the value.
<region>

Specifies the region with which you want the adapter to communicate

Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions.

Valid values:

  • us-east-1
  • us-west-2 (default)
  • us-west-1
  • eu-west-1
  • ap-southeast-1
  • ap-northeast-1
  • ap-southeast-2
  • sa-east-1
No

<operation-name>

Contains the name of the operation: delete-key-pair

Yes

<key-name>

Specifies the name of the key pair to be deleted

Yes

The following figure shows a sample adapter request for the Delete Key Pair operation. 

Sample adapter request for the Delete Key Pair operation 

<amazon-ec2-rest-request>
    <operation-name>delete-key-pair</operation-name>    
    <access-key>AKIA**********N8BT2Q</access-key>
    <secret-key>WQisk8Irh********************8AiJx3VQVd</secret-key>
    <region>us-east-1</region>
    <parameters>
        <key-name>TestKey</key-name>
    </parameters>
</amazon-ec2-rest-request>

The following figure shows the response for the sample Delete Key Pair operation. 

Sample adapter response for the Delete Key Pair operation 

<amazon-ec2-rest-response>
    <metadata>
        <status>success</status>
    </metadata>
    <DeleteKeyPairResponse>
        <return>true</return>
    </DeleteKeyPairResponse>
</amazon-ec2-rest-response>

Back to top

Was this page helpful? Yes No Submitting... Thank you

Comments