0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsで、terraform からlambdaを構築する際の、引っ掛かりポイント

Posted at

前提

Windows上で、terraformを使用

概要

Lambda構築の、引っ掛かりポイント

詳細

Code

Lambdaの部分のみ記載

module "lambda" {
    source  = "terraform-aws-modules/lambda/aws"
    version = "7.2.1"
    function_name = "function"
    description   = "lambda for example"
    handler       = "function.lambda_handler"
    runtime       = "python3.13"
    attach_policy_json = true
    policy_json        = data.aws_iam_policy_document.policy.json
    source_path        = ["${path.module}/codes/function.py"]
    timeout            = 300
    trigger_on_package_timestamp = false
    create_lambda_function_url   = true
    tags = {
        Environment = var.env
    }
    environment_variables = {
        Token: module.secretsmanager.secret
    }
    layers        = ["${aws_lambda_layer_version.lambda_layer.arn}"]
}

引っ掛かりポイント

terraform plan時にこんなエラーが出る


│ UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 1540: illegal multibyte sequence

文字エンコーディングがデフォルトの cp932 なことが原因のエラー
文字エンコーディングを UTF-8 にするとエラーが解消される。

解消パターン

C:\Users\****\terraform\dev>set PYTHONUTF8=1
C:\Users\****\terraform\dev>terraform plan
## 途中結果は略
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if
you run "terraform apply" now.

C:\Users\****\terraform\dev>terraform apply
## 途中結果は略
Apply complete! Resources: * added, * changed, * destroyed.

plan, apply両方うまくいくようになる

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?