在云形成模板中使用 AWSUtility::CloudFormation::CommandRunner 时出错 "Index: 0, Size: 0"
Error "Index: 0, Size: 0" while using AWSUtility::CloudFormation::CommandRunner in cloud formation template
我们正在尝试 运行 AWS 中的云形成模板中的几个 bash 命令。
我们关注了 AWS 的以下博客 运行 CommandRunner utilty in cloud formation template。
https://aws.amazon.com/blogs/mt/running-bash-commands-in-aws-cloudformation-templates/
Resources:
CommandRunner:
Type: AWSUtility::CloudFormation::CommandRunner
Properties:
Command: 'echo HelloWorld > /command-output.txt'
Outputs:
Op1:
Description: Test output
Value:
Fn::GetAtt: CommandRunner.Output
在云形成模板中 运行ning 命令实用程序时遇到以下错误。
Resource handler returned message: "Index: 0, Size: 0" (RequestToken: c99903a7-****-0c58-010c-4fa03699fcfd, HandlerErrorCode: InternalFailure)
堆栈 ID/堆栈 ARN:arn:aws:cloudformation:eu-west-2:*****:stack/comandrunner-test-iops/ **
错误消息的描述不够明确,无法确定根本原因。
联系 AWS 支持团队时,他们给出了以下回复。
The Index: 0, Size: 0 error usually happens because you may not have a
default VPC in the eu-west-2 region (P.S.: I am not able to verify
this since I do not have access to your account).
In general, CommandRunner uses the default VPC to run the command, but
when it doesn’t exist this error is thrown. You can still run the
CommandRunner without a default VPC, by specifying the SubnetId
property.
I also found an active issue pulled in on the github repository to
improve the error handling for this error when it occurs on
CloudFormation.
在他们回应后,我们在模板中添加了子网 ID 和安全组 ID。
提供私有子网 ID。
Parameters:
ReqSubnetId:
Type: String
Description: Please enter Subnet id so that command runner can execute
Default: subnet-0sampleid28474
ReqSecurityGroupId:
Type: String
Description: Please enter security group id so that command runner can execute
Default: sg-03samplesecuritygroupid
Resources:
CommandRunner:
Type: AWSUtility::CloudFormation::CommandRunner
Properties:
Command: 'echo HelloWorld > /command-output.txt'
SubnetId: !Ref ReqSubnetId
SecurityGroupId: !Ref ReqSecurityGroupId
Outputs:
Op1:
Description: Test output
Value:
Fn::GetAtt: CommandRunner.Output
Type: AWSUtility::CloudFormation::CommandRunner
支持的选项是
Type: AWSUtility::CloudFormation::CommandRunner
Properties:
Command: String
Role: String
LogGroup: String
SubnetId: String
KeyId: String
SecurityGroupId: String
我们正在尝试 运行 AWS 中的云形成模板中的几个 bash 命令。
我们关注了 AWS 的以下博客 运行 CommandRunner utilty in cloud formation template。 https://aws.amazon.com/blogs/mt/running-bash-commands-in-aws-cloudformation-templates/
Resources:
CommandRunner:
Type: AWSUtility::CloudFormation::CommandRunner
Properties:
Command: 'echo HelloWorld > /command-output.txt'
Outputs:
Op1:
Description: Test output
Value:
Fn::GetAtt: CommandRunner.Output
在云形成模板中 运行ning 命令实用程序时遇到以下错误。
Resource handler returned message: "Index: 0, Size: 0" (RequestToken: c99903a7-****-0c58-010c-4fa03699fcfd, HandlerErrorCode: InternalFailure)
堆栈 ID/堆栈 ARN:arn:aws:cloudformation:eu-west-2:*****:stack/comandrunner-test-iops/ **
错误消息的描述不够明确,无法确定根本原因。
联系 AWS 支持团队时,他们给出了以下回复。
The Index: 0, Size: 0 error usually happens because you may not have a default VPC in the eu-west-2 region (P.S.: I am not able to verify this since I do not have access to your account).
In general, CommandRunner uses the default VPC to run the command, but when it doesn’t exist this error is thrown. You can still run the CommandRunner without a default VPC, by specifying the SubnetId property.
I also found an active issue pulled in on the github repository to improve the error handling for this error when it occurs on CloudFormation.
在他们回应后,我们在模板中添加了子网 ID 和安全组 ID。
提供私有子网 ID。
Parameters:
ReqSubnetId:
Type: String
Description: Please enter Subnet id so that command runner can execute
Default: subnet-0sampleid28474
ReqSecurityGroupId:
Type: String
Description: Please enter security group id so that command runner can execute
Default: sg-03samplesecuritygroupid
Resources:
CommandRunner:
Type: AWSUtility::CloudFormation::CommandRunner
Properties:
Command: 'echo HelloWorld > /command-output.txt'
SubnetId: !Ref ReqSubnetId
SecurityGroupId: !Ref ReqSecurityGroupId
Outputs:
Op1:
Description: Test output
Value:
Fn::GetAtt: CommandRunner.Output
Type: AWSUtility::CloudFormation::CommandRunner
支持的选项是
Type: AWSUtility::CloudFormation::CommandRunner
Properties:
Command: String
Role: String
LogGroup: String
SubnetId: String
KeyId: String
SecurityGroupId: String