[JAVA] Serverless Framework-Vorlage zum Planen des EC2-Starts / Stopps in Lambda

Dies ist der Artikel zum 16. Tag von AWS Lambda Adventskalender 2017.

Serverless Framework

Einführung

Umgebung einrichten

Bereitstellung mit Serverless Framework

Quelle abrufen

$ git clone https://github.com/ukitiyan/operation-ec2-instance.git

In STS importieren (Eclipse)

Ändern Sie serverless.yml + Build

serverless.yml


- schedule:
    rate: cron(30 11 * * ? *)
    input:
      goal: stop
      instanceId: i-XXXXXXXXXXXXXXXXX
- schedule:
    rate: cron(0 23 * * ? *)
    input:
      goal: start
      instanceId: i-XXXXXXXXXXXXXXXXX

Deploy

$ cd operation-ec2-instance
$ serverless deploy -v
Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
・
・
Serverless: Stack update finished...
Service Information
service: operation-ec2-instance
stage: prod
region: ap-northeast-1
api keys:
  None
endpoints:
  None
functions:
  aws-java-maven-prod-hello: arn:XXXXXXXX
{
  "goal": "stop",
  "instanceId": "i-XXXXXXXXXXXXXXXXX"
}

Zusammenfassung

Recommended Posts

Serverless Framework-Vorlage zum Planen des EC2-Starts / Stopps in Lambda
So stellen Sie Java mit Serverless Framework für AWS Lambda bereit
Sie können dies sofort mit Serverless Framework Serverless mit AWS tun (API + Lambda [Java] ist einfach einzurichten).