Skip to content

Sample application managed with AWS CDK v2 (golang).

License

Notifications You must be signed in to change notification settings

michimani/honyakutter

Repository files navigation

honyakutter

This is an application that translates text entered in Japanese into English and tweets it, defined using AWS CDK v2 (golang) and using AWS Step Functions to connect the translation and tweeting processes.

Preparation

  1. Check your AWS CDK version.

    cdk --version

    If you have not installed it, please use the following command to install it.

    npm install -g aws-cdk

    This application is intended for use with AWS CDK v2.0.0 or higher.

  2. Getting Twitter API's some tokens.

    ⚠️ You will need the Twitter API key and secret, as well as the access token and access token secret. Please create an app on the Twitter Developer page and obtain each token.

  3. Create .env file.

    cp .env.sample .env

    And, replace values of each environment variables.

  4. Load environment variables.

    source .env

Build

  1. Build Tweet Lambda Function

    cd resources/lambda_functions/tweet \
    && GOARCH=amd64 GOOS=linux go build -o bin/main

Deploying

  1. bootstrap

    cdk bootstrap
  2. Build Lambda functions

    make build-tweet
  3. Load environment values

    source .env
  4. Generate CFn template

    cdk synth
  5. deploy

    cdk deploy

Testing

go test .

Manual execution

Execute Lambda functions and Step Functions state machine manually by using AWS CLI.. (The latest versions at the time of this writing are v2.4.4 and 1.22.18.)

Tweet Lambda Function

aws lambda invoke \
--function-name honyakutter-go-tweet-function \
--invocation-type Event \
--region ap-northeast-1 \
--payload fileb:https://testdata/tweet_lambda_payload.json \
out

Start state machine

  1. Get state machine ARN

    STATEMACHINE_ARN=$(
        aws stepfunctions list-state-machines \
        --query "stateMachines[?name=='honyakutter-go-translate-tweet-state-machine'].stateMachineArn" \
        --output text
    ) && echo "${STATEMACHINE_ARN}"
  2. execute

    aws stepfunctions start-execution \
    --state-machine-arn "${STATEMACHINE_ARN}" \
    --input file:https://testdata/statemachine_input.json

Licence

MIT

Author

michimani210

About

Sample application managed with AWS CDK v2 (golang).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published