Day3-1400-AWS CLI SDK · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved....
Transcript of Day3-1400-AWS CLI SDK · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved....
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Keisuke Tsukagoshi
Mobile Specialist SA, Amazon Web Services Japan
3-H1-1-14
AWS CLI / SDK ��
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
About Me
���� (Tsukagoshi Keisuke)• Specialist Solution Architect
Mobile / Serverless / DevOps• Background
• Web��������• �������� ���
• �������• AWS AppSync
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS���������������
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Key Take Away
Programmable����������AWS�:8�-� CLI / SDK ��Programmable��$$�� ����3.��!���"$��$��#�7:���Programmable��$�� ����:8�� ���,)1�+��052/�69 ��'(�*4�� �����
���!���"$��$��#%&�AWS�2/�
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Programmable
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Programmable����������• API����$�"� ��� �',
• ��*������� API�(���• ���#��%���$�"� ��� ����• �����+)&���!��#���(
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS������ API��
• 7��' � API�B>�����5E• ,&�.4%�4!�1� AWS CLI������API���1���
• )3�/-4���API���1�����5E• 7?6F:;G�SDK�D9
• SIG V4*$#�A�H�< �����8• =2+1 )3�/-4��4"�(�� �D9
• HTTP REST API�C@0�� %�����5E
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS���������
b d
E S APM AP
bE S
3
2
TAIRKWAP
a cBCD) E LK A
A A
(
>
(
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
�� Programmable����• �"�61����2:(
• 2:(�09(�);���• Agile , DevOps , Microservices ���������2:(�=5• �����34�>+������2:(�������
• �%�"�B@� �#&��!$'�/8• �#&��!$'�?��,.�/8��• *<,.��-7�B@���=A���
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Programmable Interface Overview
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS�����������
�����
• AWS CLI• AWS SDK
��
• Mobile CLI• Mobile SDK
������
• Amplify
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
�����
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Command Line Interface (CLI)
• AWS �����$#��������������• ������� AWS ������������%"� ����!&�(' &
$ aws s3 cp myvideo.mp4 s3://mybucket/
3
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Command Line Interface (CLI)
• Linux ���• Bash , Zsh, ��(.-�� $�%�"��*,����&��+/���
• Windows �����• PowerShell�Windows ��&��%����)����&��+/���
• Remote• # '��'��$�EC2 ������'�!'���*,��# '����&��+/���
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
��������
aws <service> <operation> [parameters]
ec2, s3������� ���� configure, help���� ������
�����������
$ aws ec2 describe-instances --max-items 2
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CLI ������Web�����
http://docs.aws.amazon.com/cli/latest/reference/index.html
����aws helpaws <service> helpaws <service> <operation> help
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS SDK
• AWS �������������"����SDK• AWS�������#���� API� wrap� �• � ����� SDK �!$����
import boto3 bucket_name = "my-bucket-name"file_path = “/Users/me/files/myvideo.mp4”
s3 = boto3.resource('s3’) s3.Bucket(bucket_name).upload_file(file_path, 'server.jpg')
3
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS SDK
Ruby AWS CLI
Python (boto)Mobile SDK Node.js
AWS Toolkit
for Visual Studio
.NET
AWS Toolkit
for Eclipse
PHP
AWS Tools for
Windows PowerShell
C++
JavaScriptJava
Go
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SDK for Services ��• ������ �������
–�����!$• ������ �
– ����������• � ���� �
– ���������������• ������ �
– Pub / Sub ������• ������ ��������
– NoSQL�� ������• ������ �
– E ���# "��������
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
����
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS ����W W
M
K b
D
F A33 A
F A3
)
F B AC 3 A 3A
F3A
F (3
F
A A
K
F A
SC 3
F ) D
F A
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Mobile SDK•
• BCM S DK• ������� �����������
• https://aws.amazon.com/documentation/mobile-sdk/
A D
3
3
3
K D
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Mobile SDK
• ��� ������������• AWS Mobile SDK for iOS• AWS Mobile SDK for Android• AWS Mobile SDK for .NET and Xamarin• AWS Mobile SDK for Unity
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Mobile CLI
• JavaScript�#$��$�734����!'�AWS�%���6,�0)*������$� �$�$�%�����.&
• �%��"� /-6,��AWS Mobile Hub�.&�����15�(2+5
$ awsmobile init
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
�����������������
select features: � user-signin� user-files � cloud-api� database � analytics � hosting � appsync
$ awsmobile feature
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
�����������������$ awsmobile push
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
�������
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify
• ������������� #���������%"$�JavaScript����
• ��������!����������
import { Storage } from 'aws-amplify';
Storage.put ('test.txt’ , 'Hello’ ).then (result => console.log(result)).catch(err => console.log(err));
3
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify
�����JavaScript������• React• React Native• Angular• Ionic• Vue.js coming soon
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
UI Component Photo Picker
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
UI Component S3 Album
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Service Worker ����• ����#�����"�� 03�����
postMessage� $��&�/-��������• ��"�$+2�����!+2�)'%1• Progressive Web Apps �(.�*,�
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Basic Steps of AWS CLI
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Steps of AWS CLI
• AWS��������• �����������• AWS CLI��������� ������• AWS SDK������
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Steps of AWS CLI
• �#�#�� #�$.• IAM�#�#$.• IAM� #�$.• � #�����#83• �#�#� #��7(• �����#ID��#�!�������#2.
• AWS��"����)�'����#�#1409�-5• IAM�����#ID��#�!�������#�6�• �� �,&�*/�%+
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CLI������������ �
• AWS CLI�������
$ pip install awcscli --upgrade –user$ aws configure
• AWS CLI��
$ aws configureAWS Access Key ID [None]: ACCESSKEYEXAMPLEAWS Secret Access Key [None]: wJalrXUtnFEMI/SECRETKEYEXAMPLEKEYDefault region name [None]:ap-northeast-1Default output format [None]: json
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
������
bash
$ complete -C '/usr/local/bin/aws_completer' aws
tcsh
> complete aws 'p/*/`aws_completer`/'
zsh
% source /usr/local/bin/aws_zsh_completer.sh
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
������
bash
$ aws sTABS3 ses sqs sts swfs3api sns storagegateway support
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
����
• �(� 1/-'�#.%0• IDE�)*������+!
• AWS Toolkit for Visual Studio• AWS Toolkit for Eclipse
• "� AWS SDK ���������� � �����&�������$,���https://aws.amazon.com/jp/tools/
��������� ��AWS Cloud9� �• LeI S W MD
m SDr D D AC
• LeIm C E L d S D b
S m• o L S D
t• e
a d
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• JavaScript�Python�Go�0' ��%9*+��"�6-
• AWS CLI��#���".�• Amazon EC2�#��#���� SSH):�7/ Linux����&(�%9&(�,5$8
• AWS Cloud9���! ���<;���31 AWS Cloud9 &(�2�4�$8
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SDK����
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
������� ��S3����������import boto3
def listBuckets(bucketName):s3client = boto3.client('s3')resource = s3client.list_buckets()for bucket in resource['Buckets']:
if bucket['Name'].startswith(bucketName):print("Bucket: %s" % bucket['Name'])
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
S3���������import boto3
def createBucket(bucketName) :s3client = boto3.client('s3')s3client.create_bucket(Bucket=bucketName)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
S3���������import boto3
def deleteBucket(bucketName) :s3client = boto3.client('s3')s3client.delete_bucket(Bucket=bucketName)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SQS���������import boto3
def createQueue(name):sqs = boto3.resource('sqs')queue = sqs.create_queue(
QueueName=name, Attributes={'DelaySeconds':'5'})return queue.url
url = createQueue("myqueue")print("url : %s" % url)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SQS���������import boto3
def getQueue(name):sqs = boto3.resource("sqs")queue = sqs.get_queue_by_name(QueueName=name)return queue
queue = getQueue("myqueue")print("queue url: %s" % queue.url)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SDK���
• AWS SDK• ������������ SDK
• AWS mobile SDK• ������������� SDK
• Amplify• ��� ������� js���OSS
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CLI���
• AWS CLI• AWS ����� Terminal���
• AWS Mobile CLI• mobile hub� Terminal���
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
���Programmable�� �������AWS�:8�-� CLI / SDK ��Programmable��$$�� ����3.��!���"$��$��#�7:���Programmable��$�� ����:8�� ���,)1�+��052/�69 ��'(�*4�� �����
���!���"$��$��#%&�AWS�2/�
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
F b aS ARc R d
d
Q 3 Wc
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.