iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🥨

Building API Gateway + Lambda with Wing (Winglang)

に公開
2023/09/01

I tried out Winglang

I used Winglang to create a "Hello World" API using API Gateway + Lambda.

Winglang

https://www.winglang.io/

Code I wrote

https://github.com/k-ibaraki/aws-lambda-apigw-sample/tree/main/Wing/ibaraki-wing-sample-api

What is Wing (Winglang)?

It is apparently a Cloud Oriented Language.
It seems you can define cloud resources for AWS, Azure, or Google Cloud, and write Lambda code.
It feels like TypeScript, but it's slightly different.
It is reportedly being developed by the creator of AWS CDK.

I tried writing it

https://github.com/k-ibaraki/aws-lambda-apigw-sample/blob/main/Wing/ibaraki-wing-sample-api/ibaraki-sample-api-gateway.w

You can define an API Gateway + Lambda with just this much code. Amazing!

Checking it locally

wing it ibaraki-sample-api-gateway.w

You can check the configuration and verify the API execution locally. Amazing!

Deploying

Wing cannot be deployed as is, so it needs to be converted to Terraform.
While there is a CDK option in the CLI, I got an error when I tried it. It seems only Terraform is supported for now. Unfortunate.

wing compile --target tf-aws ibaraki-sample-api-gateway.w
cd target/ibaraki-sample-api-gateway.tfaws

export AWS_REGION="ap-northeast-1"
export AWS_PROFILE="{profile}"
terraform init
terraform apply

Verifying

It worked!

Destroying

terraform destroy

Conclusion

  • I feel the potential
  • Being able to check the configuration and operation on a local PC is great
  • It is good that the amount of code can be written concisely
    • On the other hand, there are many black-box parts, which is a bit scary
  • The language is TypeScript-like but different, so it is confusing
  • Not many resources are supported yet, so I have high expectations for the future

Discussion