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?

Serverless Landでコントリビュートしてみた

Posted at

はじめに

同僚からServerless LandというAWSサービスのキャッチアップに活用できるサイトを教えてもらいました。
早速、EventBridge→LambdaのサンプルをReadmeに従い試してみたのですが、エラーが発生したのでその修正をコントリビュートしてみました。
はじめての経験なので拙い箇所もあるかと思いますがお付き合いくださいませ。

前提条件

  • Go:1.24.2
  • AWS-CLI:2.22.16
  • Terraform:1.12.1
    AWS-CLIやGitの基本設定は完了していることを前提としています。

エラー発生まで

eventbridge-schedule-to-lambda-terraform-goを使用しています。
本稿では手順及びエラー発生箇所までを記述します。

手順

  1. 本家リポジトリからフォーク
  2. Readme記載の手順に従ってterraform applyまで実行する

エラー内容

直貼りだと読みにくかったので適宜改行を入れています。
どうやらGo1.xのサポートが切れているので、適切なものに変更する必要があるみたいです。

aws_lambda_function.eventbridge_function: Creating...
╷
│ Error: creating Lambda Function (EventBridgeScheduleTarget): operation error 
Lambda: CreateFunction, https response error StatusCode: 400, 
RequestID: 0c4fbeaa-ed97-4ba1-b80c-5eebbe11e2f7, 
InvalidParameterValueException: The runtime parameter of go1.x is no longer
supported for creating or updating 
AWS Lambda functions. We recommend you use a supported runtime while creating 
or updating functions.
│
│   with aws_lambda_function.eventbridge_function,
│   on main.tf line 22, in resource "aws_lambda_function" 
│   "eventbridge_function":
│   22: resource "aws_lambda_function" "eventbridge_function" {

対応

エラー回避のためどのような調査、修正を行ったのかを記述します。

AWSの記事より

適当にググってみるとAWS Blogで対応についての記事がありました。

Functions that have not had their dependencies updated since July 2020 
will need to be re-compiled to prevent invocation errors when using the 
provided.al2 or 
provided.al2023 runtimes. If you prefer not to rename your executable to
bootstrap, you can instead create a shell script called bootstrap and use that 
to run your executable. Be sure to set the correct permissions on your 
bootstrap file.

なるほど、provided.al2provided.al2023をカスタムランタイムで使用すれば良いみたいです。
また、実行ファイル名もbootstrapにしないといけないみたいですね。

コンパイルについて

使用するコマンドについて

記事を読み進めると、provided.al2を使用する際には下記コマンドを叩くように記述がありました。

GOARCH=amd64 GOOS=linux go build -o bootstrap main.go

今回はサポート期間の長さからprovided.al2023を使用するのですが、結局のところbootstrapを生成する必要があるので同コマンドを実行します。

zip生成

使用する実行ファイル名が変更されたので.zipも下記コマンドで生成するようにします。

zip myFunction.zip bootstrap

terraform apply実行結果

image.png

無事完了です!
画像は割愛しますがAWSマネジメントコンソールを見ると、正しくEventBridge SchedulerとLambdaが作成されており、定期的にログ出力されていることがCloudWatchで確認できました。

コントリビュート

修正して動作確認もできたのでいよいよコントリビュート用のPRを出します。
冒頭で述べたようにServerless Landを紹介してくれた カックさんのPR を参考に作ってみました。

PR

下記で出してみました。
レビュアーも自動指定されたので、どうなるかしばらく待ってみます。
進展あればまた追記します。
https://github.com/aws-samples/serverless-patterns/pull/2854

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?