首页 > 解决方案 > aws transfer update-server 抛出错误

问题描述

我正在使用 terraform 创建一个 aws sftp 服务器并尝试使用IP 白名单来保护我的服务器。

Terraformaws_transfer_server命令目前仅支持PUBLIC 或 VPC_ENDPOINT 等端点类型。所以我在null_resource创建 sftp 服务器后使用执行 aws 命令来更新它。terraform 片段如下:

resource "null_resource" "update_sftp_server" {
  provisioner "local-exec" {
    command = <<EOF
aws transfer update-server --server-id ${aws_transfer_server.sftp.id} --endpoint-type VPC --endpoint-details SubnetIds="${join("\", \"", var.subnet_ids)}", AddressAllocationIds="${join("\", \"", toset(aws_eip.nlb.*.id))}", VPCEndpointID="${aws_vpc_endpoint.transfer.id}", VpcId="${var.vpc_id}"
EOF
  }
  depends_on = [aws_transfer_server.sftp, aws_vpc_endpoint.transfer]
}

这将执行以下 aws 命令

aws transfer update-server --server-id s-######## --endpoint-type VPC --endpoint-details SubnetIds="subnet-#####", "subnet-#####", AddressAllocationIds="eipalloc-######", "eipalloc-######", VPCEndpointID="vpce-#######", VpcId="vpc-#####"

但我收到如下错误:

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: AddressAllocationIds=eipalloc-######, eipalloc-######, VPCEndpointID=vpce-######, VpcId=vpc-######, subnet-######

有人可以帮我知道为什么会抛出这个错误吗?我的环境详细信息如下:

Terraform v0.12.28
provider.aws v3.0.0
provider.null v2.1.2
aws-cli/2.0.33 Python/3.7.7 Windows/10 botocore/2.0.0dev37

标签: amazon-web-servicesterraformaws-cli

解决方案


您是否尝试过构建没有空格的参数列表?所以它看起来像SubnetIds="subnet-#####","subnet-#####",AddressAllocationIds="eipalloc-######","eipalloc-######",VPCEndpointID="vpce-#######",VpcId="vpc-#####"

否则,当命令行被分解为标记时,这些位中的大部分将不会被解析为--endpoint-details参数的一部分。


推荐阅读