エラー
main.tfを作成して、terraform apply
をしたら、下記エラーが出ました。
AWSのコンソールで確認すると、EC2インスタンスのみ作成されていないようでした。
→セキュリティグループやVPCなど、インスタンスに依存しない部分は作成されていました。
Error applying plan:
1 error(s) occurred:
* aws_instance.TestEC2: 1 error(s) occurred:
* aws_instance.TestEC2: Error launching source instance: OptInRequired: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit http://aws.amazon.com/marketplace/pp?sku=aw0evgkw8e5c1q413zgy5pjce
status code: 401, request id: 845acf0d-7dec-4ebd-b4b4-a4771f04ea16
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
解決方法
AWS Marketplaceで認証を許可してから、再度terraform apply
を実行!
1.まずは、エラーに書いてあったWebページに移動し、[continue]を押下します。
To do so please visit http://aws.amazon.com/marketplace/pp?sku=aw0evgkw8e5c1q413zgy5pjce
2.[Manual Launch]を選択し、[Accept Software Terms]を押下します。
3.下記画面が出たら成功です!
再度terraform apply
して、問題なければ完了!