First of all need AWS credentials in ~/.aws/credentials specified as dev
profile.
Install terraform brew install terraform
Install Golang
go get some ChatGPT Token
change terraform/api-gateway/lambda.tf
aws_lambda_function.textcompletion
environment variables GPT_TOKEN or you can add kind of secret manager resource for managing the token.
if you type secret token value using console it will generate secrets manager in AWS and TOKEN will be automatically included in lambda function as environment variable GPT_TOKEN
example
terraform apply -var chat_secret={\"GPT_TOKEN\":\"sk-\"}
build golang source code.
make build PATH=post/textcompletion
test golang package using vscode debug mode
terraform init
terraform apply
good luck