0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

動的OGPをS3+Cloudfront+Lambda@Edgeの構成でcdk v2を使って実現しようとしたときにv1のCDKToolkitが邪魔をしたメモ

0
Posted at

概要

VueのSPAでの動的OGPをS3+Cloudfront+Lambda@Edgeの構成でcdkを使って実現したメモを参考に、cdk v2でlambda@edgeをデプロイしようとしたら失敗した。
v1で作成した、us-east-1リージョンのCDKToolkitスタックを消して(ロールとS3とスタックは手動削除)再度bootstrapをしたら動作することを確認できた。

ソース

今回作成した経路。

image.png

エラー内容

current credentials could not be used to assume 'arn:aws:iam::■:role/cdk-■-deploy-role-■-us-east-1', but are for the right account. Proceeding anyway.
aws-cartagraph-stack: building assets...

[0%] start: Building ■:■-ap-northeast-1

aws-cartagraph-stack: assets built


 ❌ Building assets failed: Error: Building Assets Failed: Error: edge-lambda-stack-■:
 SSM parameter /cdk-bootstrap/■/version not found.
 Has the environment been bootstrapped? 
Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
 
Building Assets Failed: Error: edge-lambda-stack-■: SSM parameter /cdk-bootstrap/■/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' 
(see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)

対応1 bootstrapを実行してみる

prease run 'cdk bootstrap'と言っているので、試してみる。

$npx cdk bootstrap --profile produser 
 ⏳  Bootstrapping environment aws://■/ap-northeast-1...
 ⏳  Bootstrapping environment aws://■/us-east-1...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
Switching from  to undefined as permissions boundary
 ✅  Environment aws://■/ap-northeast-1 bootstrapped (no changes).
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)

CDKToolkit |  0/13 | 21:22:30 | CREATE_FAILED        | AWS::IAM::Role          | LookupRole cdk-■-lookup-role-■-us-east-1 already exists

Failed resources:
CDKToolkit | 21:22:30 | CREATE_FAILED        | AWS::IAM::Role          | LookupRole cdk-■-lookup-role-537869083368-us-east-1 already exists
 ❌  Environment aws://■/us-east-1 failed bootstrapping: 
Error: The stack named CDKToolkit failed to deploy: 
UPDATE_ROLLBACK_COMPLETE: cdk-■-lookup-role-■-us-east-1 already exists

調査 - CDKToolkitStack(us-east-1)の削除

あまり有力な情報見つからず。
おそらく、cdk v1 で作った CDKToolkitスタックが邪魔をしているのだと思う。

バージニア北部リージョンのCloudFormationを確認。下記の状態となっていた。

image.png

一度、削除してみる

image.png

削除に失敗。S3を消すのにエラーになった模様。

image.png

上記の警告に従い、S3(cdk-hnb659fds-assets-■-us-east-1)を削除対象からはずしてみる。

削除できた。

cdk-■-lookup-role-537869083368-us-east-1 already exists と言われているので、こちらも消してみる。

この状態で再度bootstrapをするも、バケットが存在するエラーで落ちた。

cdk-hnb659fds-assets-■-us-east-1のバケットも手動削除する。

image.png

再度 bootstrap

us-east-1のbootstarapがようやく完了。

再度デプロイ

デプロイに成功。

参考

cdk - bootstrap
cdk - bootstrap 和訳

CDK Bootstrapをカスタマイズしてみた
AWS CDK メモ: ブートストラップ処理を実行する (cdk bootstrap)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?