© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
v
v
v
v
v
v
v
v
v
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
•
•
•
•
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo: Remote Pair Programming
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Live Remote Pair Programming
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
•
•
•
•
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
•
•
•
•
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
demo – AWS CodeStar
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS
CodeCommit
AWS
CodeBuild
Source Repository Build Deploy
Or
AWS Cloud9
AWS CodeStar
AWS Lambda
Author
AWS
CodePipeline
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda
AWS CodeBuild BuildSpec
Lambda (Python)
AWS CodeStar sample readme
SAM
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
•
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
import json
import datetime
def handler(event, context):
print(event)
data = {
'output': 'Hello World!!!',
'timestamp': datetime.datetime.utcnow().isoformat()
}
return {'statusCode': 200,
'body': json.dumps(data),
'headers': {'Content-Type': 'application/json'}}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
import unittest
import index
class TestHandlerCase(unittest.TestCase):
def test_response(self):
print("testing response.")
result = index.handler(None, None)
print(result)
self.assertEqual(result['statusCode'], 200)
self.assertEqual(result['headers']['Content-Type'], 'application/json')
self.assertIn('Hello World', result['body'])
if __name__ == '__main__':
unittest.main() # run unit test
$ python -m unittest discover tests
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
version: 0.2
phases:
install:
commands:
# Upgrade AWS CLI to the latest version
- pip install --upgrade awscli
pre_build:
commands:
# Discover and run unit tests in the 'tests' directory. For more information, see <https://docs.python.org/3/library/unittest.html#test-discovery>
- python -m unittest discover tests
build:
commands:
# Use AWS SAM to package the application by using AWS CloudFormation
- aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml
artifacts:
type: zip
files:
- template-export.yml
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
- AWS::CodeStar
Parameters:
ProjectId:
Type: String
Description: CodeStar projectId used to associate new resources to team members
# Enable blue/green deployments using this Globals section. For instructions, see the AWS CodeStar User Guide:
# https://docs.aws.amazon.com/codestar/latest/userguide/how-to-modify-serverless-project.html?icmpid=docs_acs_rm_tr
#
# Globals:
# Function:
# AutoPublishAlias: live
# DeploymentPreference:
# Enabled: true
# Type: Canary10Percent5Minutes
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Resources:
HelloWorld:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: python3.6
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Events:
GetEvent:
Type: Api
Properties:
Path: /
Method: get
PostEvent:
Type: Api
Properties:
Path: /
Method: post
Lambda
Lambda
Lambda
Role ARN
: API Gateway (GET)
: API Gateway (POST)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Code Services
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
AWS CodeBuild
+ Third Party
AWS CodeCommit AWS CodeBuild AWS CodeDeploy
AWS CodePipeline
AWS
CodeStar
Source Build Test Deploy Monitor
AWS X-Ray
Amazon
CloudWatch
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Storing your code
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
version: 0.1
environment_variables:
plaintext:
JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"
phases:
install:
commands:
- apt-get update -y
- apt-get install -y maven
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on `date`
- mvn install
post_build:
commands:
- echo Build completed on `date`
artifacts:
type: zip
files:
- target/messageUtil-1.0.jar
discard-paths: yes
•
•
•
•
•
•
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
•
•
•
•
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Happy Python Coding!

「リモートペアプロでマントルを突き抜けろ!」AWS Cloud9でリモートペアプロ&楽々サーバーレス開発

  • 1.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 2.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. v v v v v v v v v
  • 3.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. • • • • •
  • 4.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. •
  • 5.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 6.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Demo: Remote Pair Programming
  • 7.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 8.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. •
  • 9.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 10.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Live Remote Pair Programming
  • 11.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved. • • • • •
  • 12.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
  • 13.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 14.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
  • 15.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. • • • • •
  • 16.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 17.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 18.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 19.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark demo – AWS CodeStar
  • 20.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. AWS CodeCommit AWS CodeBuild Source Repository Build Deploy Or AWS Cloud9 AWS CodeStar AWS Lambda Author AWS CodePipeline
  • 21.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Lambda AWS CodeBuild BuildSpec Lambda (Python) AWS CodeStar sample readme SAM
  • 22.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. • •
  • 23.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. import json import datetime def handler(event, context): print(event) data = { 'output': 'Hello World!!!', 'timestamp': datetime.datetime.utcnow().isoformat() } return {'statusCode': 200, 'body': json.dumps(data), 'headers': {'Content-Type': 'application/json'}}
  • 24.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. import unittest import index class TestHandlerCase(unittest.TestCase): def test_response(self): print("testing response.") result = index.handler(None, None) print(result) self.assertEqual(result['statusCode'], 200) self.assertEqual(result['headers']['Content-Type'], 'application/json') self.assertIn('Hello World', result['body']) if __name__ == '__main__': unittest.main() # run unit test $ python -m unittest discover tests
  • 25.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. version: 0.2 phases: install: commands: # Upgrade AWS CLI to the latest version - pip install --upgrade awscli pre_build: commands: # Discover and run unit tests in the 'tests' directory. For more information, see <https://docs.python.org/3/library/unittest.html#test-discovery> - python -m unittest discover tests build: commands: # Use AWS SAM to package the application by using AWS CloudFormation - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml artifacts: type: zip files: - template-export.yml
  • 26.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. AWSTemplateFormatVersion: 2010-09-09 Transform: - AWS::Serverless-2016-10-31 - AWS::CodeStar Parameters: ProjectId: Type: String Description: CodeStar projectId used to associate new resources to team members # Enable blue/green deployments using this Globals section. For instructions, see the AWS CodeStar User Guide: # https://docs.aws.amazon.com/codestar/latest/userguide/how-to-modify-serverless-project.html?icmpid=docs_acs_rm_tr # # Globals: # Function: # AutoPublishAlias: live # DeploymentPreference: # Enabled: true # Type: Canary10Percent5Minutes
  • 27.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Resources: HelloWorld: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: python3.6 Role: Fn::ImportValue: !Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']] Events: GetEvent: Type: Api Properties: Path: / Method: get PostEvent: Type: Api Properties: Path: / Method: post Lambda Lambda Lambda Role ARN : API Gateway (GET) : API Gateway (POST)
  • 28.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. AWS Code Services
  • 29.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved. AWS CodeBuild + Third Party AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS CodePipeline AWS CodeStar Source Build Test Deploy Monitor AWS X-Ray Amazon CloudWatch
  • 30.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Storing your code
  • 31.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 32.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 33.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 34.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 35.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. version: 0.1 environment_variables: plaintext: JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64" phases: install: commands: - apt-get update -y - apt-get install -y maven pre_build: commands: - echo Nothing to do in the pre_build phase... build: commands: - echo Build started on `date` - mvn install post_build: commands: - echo Build completed on `date` artifacts: type: zip files: - target/messageUtil-1.0.jar discard-paths: yes • • • • • • •
  • 36.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 37.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 38.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 39.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. • • • •
  • 40.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Happy Python Coding!