如何通过AWS开发工具包设置DHCP选项集

时间:2018-09-24 07:20:09

标签: amazon-web-services aws-sdk amazon-vpc

我正在努力通过具有名称标签

的AWS开发工具包/ CLI创建DHCP选项集

AWS Console Dialog Create DHCP options set

我当前的代码:

const ec2: AWS.EC2 = new AWS.EC2();
const createDhcpOptionsResult: PromiseResult<AWS.EC2.CreateDhcpOptionsResult, AWS.AWSError> = await ec2
    .createDhcpOptions({
        DhcpConfigurations: [
            { Key: 'domain-name', Values: [`${hostedZoneName}.${region}.aws.cloud.***`] },
            { Key: 'domain-name-servers', Values: dhcpOptionValuesByRegion[region] }
        ]
    })
    .promise();

我已经尝试过

{ Key: 'name-tag', Values: [hostedZoneName] }

但结果是:

2018-09-24T07:01:41.826Z    ae6baf79-bfc7-11e8-be28-255ebcbc3290
{
    "errorMessage": "Value (name-tag) for parameter name is invalid. Unknown DHCP option",
    "errorType": "InvalidParameterValue",
    "stackTrace": [
        "Request.extractError (/var/runtime/node_modules/aws-sdk/lib/services/ec2.js:50:35)",
        "Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)",
        "Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)",
        "Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
        "Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
        "AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
        "/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
        "Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
        "Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
        "Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18)"
    ]
}

请让我知道如何通过AWS开发工具包设置选项集的名称

文档: API_CreateDhcpOptions

1 个答案:

答案 0 :(得分:0)

我找到了解决方法:

await ec2.createTags({ Resources: [dhcpOptionsId], Tags: [{ Key: 'Name', Value: hostedZoneName }] }).promise();