简体   繁体   English

Terraform 创建 ec2 实例错误,即使实例已创建

[英]Terraform to create ec2 instance error even though instance is created

I am having trouble creating ec2 instances with my IAM role.我在使用我的 IAM 角色创建 ec2 实例时遇到问题。 The permissions I gave are我给的权限是

List DescribeInstances DescribeKeyPairs列出DescribeInstances DescribeKeyPairs

Read DescribeTags阅读DescribeTags

Tagging CreateTags标记创建标签

Write CreateKeyPair DeleteKeyPair ImportKeyPair RunInstances TerminateInstances写入CreateKeyPair DeleteKeyPair ImportKeyPair RunInstances TerminateInstances

The error is错误是

error while describing instance(...) attribute (instanceInitiatedShutdownBehaviour): UnnauthorizedOperation: You are no authorized to perform this operation.

However, on the AWS console, the ec2 instance is created.但是,在 AWS 控制台上,创建了 ec2 实例。 I am unable to terraform destroy it due to the same error.由于同样的错误,我无法terraform destroy它。

It works if I give full ec2 access (ec2:*) so it has nothing to do with my terraform code.如果我提供完整的 ec2 访问权限 (ec2:*),它就会工作,因此它与我的 terraform 代码无关。

Thank you.谢谢。

I went through the same error and it is because of lack of permission.我遇到了同样的错误,这是因为缺乏许可。 In the error:在错误中:

error while describing instance(...) attribute (instanceInitiatedShutdownBehaviour): UnnauthorizedOperation: You are no authorized to perform this operation.

the UnnauthorizedOperation is trying to describe an instance attribute since you do not have the ec2:DescribeInstanceAttribute permission. UnnauthorizedOperation试图描述实例属性,因为您没有ec2:DescribeInstanceAttribute权限。

Depending on how your terraform config looks like for the instances, you may require more permissions.根据实例的 terraform 配置,您可能需要更多权限。 You can enable debug logs in your apply command to get more information:您可以在应用命令中启用调试日志以获取更多信息:

TF_LOG=DEBUG terraform apply

Use the visual policy editor to add permissions to your IAM role and look out for Action Warnings .使用可视化策略编辑器向您的 IAM 角色添加权限并留意Action Warnings It will tell you if you are missing any permissions required by the existing permission.它会告诉您是否缺少现有权限所需的任何权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium 崩溃,即使 chromedriver 位于正确的位置(EC2 实例) - Selenium crashing even though chromedriver is in the right place (EC2 instance) 无法访问使用 terraform 创建的 EC2 实例 - unable to access EC2 instance created using terraform Terraform - 我无法使用 SG 模块创建 EC2 实例 - Terraform - I can not create EC2 instance using SG module 如果设置了安全组,则无法使用 terraform 创建 ec2 实例 - failed to create ec2 instance using terraform if set security group 使用 Terraform 脚本使用密钥旋转 ec2 实例时出错 - error while spinning ec2 instance with key using Terraform script Terraform ec2 实例不创建 - Terraform ec2 instance don't creating 使用 Terraform 将文件传递给新创建的 ec2 实例,而不共享“连接”部分中的私钥 - using Terraform to pass a file to newly created ec2 instance without sharing the private key in "connection" section 如果我更改 AMI ID,Terraform 不会创建新的 ec2 实例 - Terraform does not create a new ec2 instance if I change the AMI ID 在实例中使用 EC2 Instance Connect 时出错是从 Cluster ECS 创建的 - Error when using EC2 Instance Connect in the instance was created from Cluster ECS EC2创建实例需要什么权限 - What are the permission required for EC2 create Instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM