{"id":22247,"date":"2026-04-13T09:29:39","date_gmt":"2026-04-13T00:29:39","guid":{"rendered":"https:\/\/itport.cloud\/?p=22247"},"modified":"2026-04-13T09:29:39","modified_gmt":"2026-04-13T00:29:39","slug":"post-22247","status":"publish","type":"post","link":"https:\/\/itport.cloud\/?p=22247","title":{"rendered":"ECR\u306e\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u3067Lambda\u95a2\u6570\u3092\u4f5c\u308b"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"e79baee6aca1-1\">\u76ee\u6b21<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#1\" data-type=\"internal\" data-id=\"#\u306f\u3058\u3081\u306b\">\u306f\u3058\u3081\u306b<\/a><\/li>\n\n\n\n<li><a href=\"#2\" data-type=\"internal\" data-id=\"#2\">\u30a4\u30e1\u30fc\u30b8\u3092\u7528\u610f\u3059\u308b<\/a><\/li>\n\n\n\n<li><a href=\"#3\">\u30a4\u30e1\u30fc\u30b8\u306e\u4e2d\u8eab\u3092\u4f5c\u6210\u3059\u308b<\/a><\/li>\n\n\n\n<li><a href=\"#4\">Terrafrom\u3092\u65b0\u898f\u4f5c\u6210<\/a><\/li>\n\n\n\n<li><a href=\"#5\">AWS\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b<\/a><\/li>\n\n\n\n<li><a href=\"#6\">ECR\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3059\u308b<\/a><\/li>\n\n\n\n<li><a href=\"#7\">\u3059\u3079\u3066\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b<\/a><\/li>\n\n\n\n<li><a href=\"#8\">\u307e\u3068\u3081<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1\">\u306f\u3058\u3081\u306b<\/h2>\n\n\n\n<p>Docker \u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092 AWS Lambda \u306b\u30c7\u30d7\u30ed\u30a4\u3057\u305f\u969b\u306e\u624b\u9806\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001\u95a2\u9023\u3059\u308b\u30ea\u30bd\u30fc\u30b9\u306f\u3059\u3079\u3066 Terraform \u306b\u3088\u3063\u3066\u7ba1\u7406\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2\">\u30a4\u30e1\u30fc\u30b8\u3092\u7528\u610f\u3059\u308b<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u307e\u305a\u306fDockerDesktop\u3092\u8d77\u52d5\u3057\u307e\u3057\u3087\u3046\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6301\u3063\u3066\u306a\u3044\u65b9\u306f<a href=\"https:\/\/www.docker.com\/ja-jp\/get-started\/\" data-type=\"link\" data-id=\"https:\/\/www.docker.com\/ja-jp\/get-started\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u516c\u5f0f<\/a>\u3088\u308a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u306e\u53d6\u5f97<\/li>\n<\/ul>\n\n\n\n<p>docker run\u30b3\u30de\u30f3\u30c9\u3067AWS \u304c\u63d0\u4f9b\u3057\u3066\u3044\u308b Lambda \u7528\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n> docker pull public.ecr.aws\/lambda\/python:3.12\n3.13: Pulling from lambda\/python\nb71754c34aa3: Pull complete\nd2379533db7f: Pull complete\n26c6d8a1e1c2: Pull complete\n94f2ecca3b37: Pull complete \nf9e394d707b7: Pull complete\n15b946295de2: Pull complete\nDigest: sha256:e78bfe2edd6206a58448bbeb08164c7c420fc974b38e21cefbcd8ed2e7f2d49c\nStatus: Downloaded newer image for public.ecr.aws\/lambda\/python:3.13\npublic.ecr.aws\/lambda\/python:3.13\n<\/pre><\/div>\n\n\n<p>\u3053\u308c\u3067\u30a4\u30e1\u30fc\u30b8\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u78ba\u8a8d\u3059\u308b\u3068\u3001<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n> docker images\nREPOSITORY                                                                 TAG        IMAGE ID       CREATED        SIZE\npublic.ecr.aws\/lambda\/python                                               3.13       f1006010e0ac   2 days ago    528MB\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"3\">\u30a4\u30e1\u30fc\u30b8\u306e\u4e2d\u8eab\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n\n\n\n<p>Lambda\u3092\u52d5\u304b\u3059\u306b\u306f\u30cf\u30f3\u30c9\u30e9\u304c\u5fc5\u8981\u306a\u306e\u3067\u3001\u6700\u5c0f\u9650\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>sample\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u3001\u914d\u4e0b\u306bapp.py\u3068Dockerfile\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>app.py\u306b\u4e0b\u8a18\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def handler(event, context):\n    return {\"statusCode\": 200, \"body\": \"Hello from Lambda container!\"}<\/code><\/pre>\n\n\n\n<p>\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9200\u3068\u300cHello from Lambda container!\u300d\u3092\u8fd4\u3059\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p>Dockerfile\u3082\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM public.ecr.aws\/lambda\/python:3.12\nCOPY app.py ${LAMBDA_TASK_ROOT}\nCMD &#91;\"app.handler\"]<\/code><\/pre>\n\n\n\n<p>Dockerfile\u306e\u5185\u5bb9\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u5148\u307b\u3069\u30d7\u30eb\u3057\u305f\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3059\u308b\u3002<\/li>\n<li><code>app.py<\/code> \u3092\u30b3\u30f3\u30c6\u30ca\u5185\u306e Lambda \u30bf\u30b9\u30af\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\uff08<code>\/var\/task<\/code>\uff09\u306b\u30b3\u30d4\u30fc\u3059\u308b\u3002<\/li>\n<li>Lambda \u304c\u547c\u3073\u51fa\u3059\u30cf\u30f3\u30c9\u30e9\u30fc\u95a2\u6570\u3092<code>app<\/code> \u30e2\u30b8\u30e5\u30fc\u30eb\u306e <code>handler<\/code> \u95a2\u6570\u3067\u6307\u5b9a\u3059\u308b\u3002<\/li>\n<\/ul>\n<p><!-- notionvc: 4982cfea-8e30-4882-8b2d-5c3c482e7d75 --><\/p>\n\n\n\n<p>\u3053\u3053\u307e\u3067\u51fa\u6765\u305f\u3089\u3001\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092Docker\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u30d3\u30eb\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p>sample\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u3066\u304b\u3089\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker build -t sample-image:latest-01 -f Dockerfile .\/\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"4\">Terraform\u3092\u65b0\u898f\u4f5c\u6210<\/h2>\n\n\n\n<p>\u5fc5\u8981\u306aAWS\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u3001Terraform\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p>Terraform\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/developer.hashicorp.com\/terraform\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>Terraform\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/developer.hashicorp.com\/terraform\/install\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>sample-infrastructer\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u3001\u914d\u4e0b\u306bmian.tf\u3001variables.tf\u3001terraform.tfvars\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u5404\u30d5\u30a9\u30eb\u30c0\u306b\u4e0b\u8a18\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># main.tf\nterraform {\n  required_providers {\n    aws = {\n      source  = \"hashicorp\/aws\"\n      version = \"~&gt; 5.0\"\n    }\n  }\n}\n\nprovider \"aws\" {\n  profile = var.profile\n  region  = var.region\n  \n    default_tags {\n    tags = {\n      Terraform  = true\n      SystemName = \"test\"\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u203b\u4eca\u56de\u306fstate\u30d5\u30a1\u30a4\u30eb\u306f\u30ed\u30fc\u30ab\u30eb\u306b\u4fdd\u5b58\u3059\u308b\u8a2d\u5b9a\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># variables.tf\nvariable \"profile\" {\n  type = string\n  default = \"\"\n}\n\nvariable \"region\" {\n  type = string\n  default = \"\"\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># terraform.tfvars\nprofile = \"xxxxxxxx\"\nregion  = \"xxxxxxx\"<\/code><\/pre>\n\n\n\n<p><code>profile<\/code>\u306f\u69cb\u7bc9\u5148\u306eAWS\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n>terraform init\nInitializing the backend...\nInitializing provider plugins...\n- Finding hashicorp\/aws versions matching \"~> 5.0\"...\n- Installing hashicorp\/aws v5.100.0...\n- Installed hashicorp\/aws v5.100.0 (signed by HashiCorp)\nTerraform has made some changes to the provider dependency selections recorded\nin the .terraform.lock.hcl file. Review those changes and commit them to your\nversion control system if they represent changes you intended to make.\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,  \nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\n<\/pre><\/div>\n\n\n<p>\u3053\u308c\u3067Terraform\u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5\">AWS\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5fc5\u8981\u306aAWS\u30ea\u30bd\u30fc\u30b9\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p>sample-infrastructer\u30d5\u30a9\u30eb\u30c0\u914d\u4e0b\u306becr.tf\u3001lambda.tf\u3001iam.tf\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u5404\u30d5\u30a1\u30a4\u30eb\u306b\u4e0b\u8a18\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ------------------------------------------------------ #\n# ECR\n# ------------------------------------------------------ #\nresource \"aws_ecr_repository\" \"example\" {\n  name                 = \"example-repo\"\n  image_tag_mutability = \"IMMUTABLE\"\n  force_delete         = true\n}\n\n# \u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u30dd\u30ea\u30b7\u30fc\nresource \"aws_ecr_lifecycle_policy\" \"example\" {\n  repository = aws_ecr_repository.example.name\n  policy = jsonencode(\n    {\n      rules = &#91;\n        {\n          rulePriority = 1,\n          description  = \"Keep last 10 images\",\n          selection = {\n            tagStatus   = \"any\",\n            countType   = \"imageCountMoreThan\",\n            countNumber = 10\n          },\n          action = {\n            type = \"expire\"\n          }\n        }\n      ]\n    }\n  )\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>####################################################\n# Data sources for ECR images\n####################################################\ndata \"aws_ecr_image\" \"example_latest\" {\n  repository_name = aws_ecr_repository.example.name\n  most_recent     = true\n}\n\n# ------------------------------------------------------ #\n# Lambda - using ECR image\n# ------------------------------------------------------ #\nresource \"aws_lambda_function\" \"lambda\" {\n  function_name = \"lambda-test\"\n  architectures = &#91;\"x86_64\"]\n  package_type  = \"Image\"\n  image_uri     = data.aws_ecr_image.example_latest.image_uri\n  role          = aws_iam_role.lambda_role.arn\n  publish       = true\n\n  memory_size = 512\n  timeout     = 30\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># ------------------------------------------------------ #\n# Lambda IAM Role and Policies\n# ------------------------------------------------------ #\n\n# Lambda Assume Role \u30dd\u30ea\u30b7\u30fc\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\ndata \"aws_iam_policy_document\" \"lambda_assume_role_policy\" {\n  statement {\n    effect = \"Allow\"\n    principals {\n      type        = \"Service\"\n      identifiers = &#91;\"lambda.amazonaws.com\"]\n    }\n    actions = &#91;\"sts:AssumeRole\"]\n  }\n}\n\nresource \"aws_iam_role\" \"lambda_role\" {\n  name = \"example_lambda_iam_role\"\n  assume_role_policy = data.aws_iam_policy_document.lambda_assume_role_policy.json\n}\n\n# AWS\u30de\u30cd\u30fc\u30b8\u30c9\u30dd\u30ea\u30b7\u30fc\u3092\u30a2\u30bf\u30c3\u30c1 (CloudWatch Logs\u3078\u306e\u66f8\u304d\u8fbc\u307f\u6a29\u9650)\nresource \"aws_iam_role_policy_attachment\" \"lambda_basic_execution\" {\n  role       = aws_iam_role.lambda_role.name\n  policy_arn = \"arn:aws:iam::aws:policy\/service-role\/AWSLambdaBasicExecutionRole\"\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<p>cli\u3067AWS\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<\/p>\n<p><code>&lt;profile-name&gt;<\/code>\u306b\u306f\u69cb\u7bc9\u5148\u306eAWS\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\naws sso login --prifile &lt;profile_name>\n<\/pre><\/div>\n\n\n<p>\u4f5c\u6210\u3055\u308c\u308b\u30ea\u30bd\u30fc\u30b9\u4e00\u89a7\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nterraform plan -var-file=\"terraform.tfvars\"\n<\/pre><\/div>\n\n\n\n\n<p>\u4eca\u56de\u3001Docker\u30d5\u30a1\u30a4\u30eb\u306fTerraform\u3068\u306f\u5225\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u304a\u3044\u3066\u307e\u3059\u306e\u3067\u3001\u5148\u306bECR\u3092\u7528\u610f\u3057\u3066\u624b\u52d5\u3067\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002<\/p>\n<p>Terraform\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5168\u4f53\u3092\u4e00\u6c17\u306b\u9069\u7528\u3059\u308b\u3068\u3001ECR\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304c\u7a7a\u306e\u305f\u3081\u3001Lambda\u4f5c\u6210\u6642\u306b\u30a8\u30e9\u30fc\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>plan\u30b3\u30de\u30f3\u30c9\u3067\u554f\u984c\u306a\u3051\u308c\u3070ECR\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nterraform apply -var-file=\"terraform.tfvars\" -target=\"aws_ecr_repository.example\"\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"6\">ECR\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3059\u308b<\/h2>\n\n\n\n<p>\u5148\u306b\u4f5c\u6210\u3057\u305fECR\u306bDocker\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002<\/p>\n<p>\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u306e\u30d7\u30c3\u30b7\u30e5\u30b3\u30de\u30f3\u30c9\u3092\u8868\u793a\u30dc\u30bf\u30f3\u3092\u62bc\u4e0b\u3059\u308b\u3068\u3001\u30d7\u30c3\u30b7\u30e5\u65b9\u6cd5\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ECR\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\naws ecr get-login-password --region ap-northeast-1 --profile &lt;profile_name> | docker login --username AWS --password-stdin &lt;accountID>.dkr.ecr.ap-northeast-1.amazonaws.com\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Docker\u30a4\u30e1\u30fc\u30b8\u306b\u30bf\u30b0\u3092\u3064\u3051\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p><code>:<\/code>\u4ee5\u964d\u304c\u30a4\u30e1\u30fc\u30b8\u30bf\u30b0\u306b\u306a\u308a\u3001\u4eca\u56de\u306f<code>latest<\/code>\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Terrafrom\u306eECR\u306e\u8a2d\u5b9a\u3067<code>image_tag_mutability = \"IMMUTABLE\"<\/code>\u3068\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001<mark class=\"HxTRcb\" data-sfc-root=\"c\" data-sfc-cb=\"\">\u30ea\u30dd\u30b8\u30c8\u30ea\u5185\u306e\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u30bf\u30b0\u306e\u5909\u66f4\uff08\u4e0a\u66f8\u304d\uff09\u3092\u7981\u6b62\u3059\u308b\u8a2d\u5b9a<\/mark>\u3067\u3001\u540c\u3058\u30bf\u30b0\u3067\u306e\u518d\u30d7\u30c3\u30b7\u30e5\u304c\u4e0d\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker tag sample-image:latest-01 &lt;accountID>.dkr.ecr.ap-northeast-1.amazonaws.com\/example-repo:latest\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>\u30bf\u30b0\u4ed8\u3051\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker push &lt;accountID>.dkr.ecr.ap-northeast-1.amazonaws.com\/example-repo:latest\n<\/pre><\/div>\n\n\n<p>\u7121\u4e8b\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"227\" src=\"https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2-1024x227.png\" alt=\"\" class=\"wp-image-22391\" srcset=\"https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2-1024x227.png 1024w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2-300x66.png 300w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2-768x170.png 768w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2-450x100.png 450w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2-900x199.png 900w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/image-2.png 1530w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7\">\u3059\u3079\u3066\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n\n\n\n<p>\u6b8b\u308a\u306e\u30ea\u30bd\u30fc\u30b9\u3082Terraform\u304b\u3089\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nterraform apply -var-file=\"terraform.tfvars\" \n<\/pre><\/div>\n\n\n<p>\u6210\u529f\u3057\u305f\u3089\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3067Lambda\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9200\u3068Hello from Lambda container!\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"475\" src=\"https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-1024x475.png\" alt=\"\" class=\"wp-image-22405\" srcset=\"https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-1024x475.png 1024w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-300x139.png 300w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-768x356.png 768w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-1536x713.png 1536w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-450x209.png 450w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1-900x418.png 900w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-12-11-183918-1.png 1856w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"458\" src=\"https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-1024x458.png\" alt=\"\" class=\"wp-image-22392\" srcset=\"https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-1024x458.png 1024w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-300x134.png 300w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-768x343.png 768w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-1536x686.png 1536w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-450x201.png 450w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23-900x402.png 900w, https:\/\/itport.cloud\/wp-content\/uploads\/2026\/03\/2025-12-11_18h40_23.png 1761w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"8\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u7121\u4e8b\u306bHello from Lambda container!\u3092\u62dd\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u306f\u4e0d\u8981\u306a\u5834\u5408\u306f<code>terraform destroy<\/code>\u3067\u524a\u9664\u3059\u308b\u3053\u3068\u3092\u304a\u5fd8\u308c\u306a\u304f\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u4eca\u56de\u306e\u4f5c\u696d\u3067\u30b3\u30f3\u30c6\u30ca\u3084Lambda\u306b\u95a2\u3057\u3066\u5c11\u3057\u89e3\u50cf\u5ea6\u304c\u3042\u304c\u3063\u305f\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u7686\u3055\u307e\u3082\u540c\u3058\u3088\u3046\u306a\u30bf\u30b9\u30af\u304c\u767a\u751f\u3057\u305f\u969b\u306f\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3092\u5f79\u7acb\u3066\u3066\u3044\u305f\u3060\u3051\u307e\u3057\u305f\u3089\u975e\u5e38\u306b\u3046\u308c\u3057\u3044\u9650\u308a\u3067\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u3053\u3046\u3059\u308c\u3070\u3082\u3063\u3068\u7c21\u5358\u3067\u3042\u3063\u305f\u308a\u3001\u8a00\u3063\u3066\u308b\u3053\u3068\u304a\u304b\u3057\u3044\u3068\u3044\u3046\u65b9\u304c\u3044\u3089\u3063\u3057\u3083\u3044\u307e\u3057\u305f\u3089\u3001<\/p>\n<p>\u00a0<\/p>\n<p>\u662f\u975e\u30b3\u30e1\u30f3\u30c8\u3044\u305f\u3060\u3051\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u00a0<\/p>\n<p><!-- notionvc: 64dbc8fd-5fb9-468b-ab0c-2442273b36c5 --><\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"\u76ee\u6b21 \u306f\u3058\u3081\u306b \u30a4\u30e1\u30fc\u30b8\u3092\u7528\u610f\u3059\u308b \u30a4\u30e1\u30fc\u30b8\u306e\u4e2d\u8eab\u3092\u4f5c\u6210\u3059\u308b Terrafrom\u3092\u65b0\u898f\u4f5c\u6210 AWS\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b ECR\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3059\u308b \u3059\u3079\u3066\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b \u307e\u3068\u3081 \u306f\u3058\u3081\u306b Docker \u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092 AWS Lambda \u306b\u30c7\u30d7\u30ed\u30a4\u3057\u305f\u969b\u306e\u624b\u9806\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002 \u306a\u304a\u3001\u95a2\u9023\u3059\u308b\u30ea\u30bd\u30fc\u30b9\u306f\u3059\u3079\u3066 Terraform \u306b\u3088\u3063\u3066\u7ba1\u7406\u3057\u3066\u3044\u307e\u3059\u3002 \u30a4\u30e1\u30fc\u30b8\u3092\u7528\u610f\u3059\u308b \u307e\u305a\u306fDockerDesktop\u3092\u8d77\u52d5\u3057\u307e\u3057\u3087\u3046\u3002 \u6301\u3063\u3066\u306a\u3044\u65b9\u306f\u516c\u5f0f\u3088\u308a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002 \u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u306e\u53d6\u5f97 docker run\u30b3\u30de\u30f3\u30c9\u3067AWS \u304c\u63d0\u4f9b\u3057\u3066\u3044\u308b Lambda \u7528\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u3092\u53d6\u5f97\u3057\u307e\u3059&hellip;","protected":false},"author":42,"featured_media":22376,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80,136,183],"tags":[40],"class_list":{"0":"post-22247","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-docker","9":"category-terraform","10":"tag-article"},"_links":{"self":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts\/22247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22247"}],"version-history":[{"count":30,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts\/22247\/revisions"}],"predecessor-version":[{"id":22408,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts\/22247\/revisions\/22408"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/media\/22376"}],"wp:attachment":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}