Open rainit2006 opened 7 years ago
http://media.amazonwebservices.com/jp/csd20140909/TA-02.pdf
S3和EBS
S3について •Amazon EC2上から外部のデータサーバーとしてアクセスできる。 •HTTPリクエストでどこからでもアクセス可能 Amazon S3 represents an object storage for data that deals with user files like Google Docs does it (flat file structure). Amazon S3 stores data as objects in a flat environment (without a hierarchy). Each object (file) in the storage contains a header with associated sequence of bytes from 0 byte to 5 TB. Objects in Amazon S3 are associated with a unique identifier (key), so access to them can be obtained through web requests from anywhere. As compared to Amazon EBS, the process of requesting an object in Amazon S3 is slower, but Amazon S3 is a highly scalable storage service with 99,999999999% data durability. Thus, it’s better to use it to store and deliver objects that don’t require a lot of read/write operations
EBSについて •Amazon EC2上のインスタンスからボリュームをマウントし、利用する。 「Amazon EBS」では、1GB~1TBまで1GB単位で仮想ディスクを生成することが可能です。通常利用の他にも、RAID0のように複数のボリュームを束ねて(ストライピング)使うことで高いI/Oパフォーマンスを実現させる使い方ができます。また、EBSボリュームのスナップショットを「Amazon S3」のストレージ上に保存させるようなAPIも公開されています。 Amazon EBS is an example of a block level storage similar to your desktop’s drive or virtual disk in virtualized environments. It’s important as once you configure the volume in Amazon EBS, it can’t be easily scaled. If you need more storage space, you will need to buy and configure a new volume of a bigger size.
考察 •EBS側に置くと良さげなデータ ◦各種ログやDBデータなど頻繁にインスタンスからアクセスするデータ ◦外からアクセスする必要の無いデータ •S3側に置くと良さげなデータ ◦画像ファイルなどの静的ファイル系データ ◦イメージファイルなどやバックアップファイルなどファイルサイズが大きく、あまりアクセスしないもの ◦HTTP経由でアクセスできる必要があるデータ
Amazon Glacierとは? バックアップやアーカイブのために開発された、セキュアかつ堅牢性の高いストレージ Amazon S3と同等の99.999999999%の耐久性を確保しつつ、S3の約1/3の費用で利用できる データの取り出し命令を発行してから実際にデータを取り出せる状態になるまで、通常3~5時間の時間が必要 オンプレミス環境ではテープライブラリに保存するような、各種ログやバックアップデータなどの大容量でアクセス頻度の低いデータの長期保存に最適 S3連携機能: S3BucketにLifecycleポリシーを設定すると、一定期間が経過したファイルは自動的にGlacierに待避される
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
EC2有四种pricing方式: 1, On demand: 按小时收费 オンデマンドインスタンスでは、長期間の契約や前払いは必要なく、コンピューティング性能に対して時間あたりの料金をお支払いいただきます。 通常、EC2インスタンスを起動すればこの費用体系が適用されます。
AWS SDK for Java この SDK は、Amazon S3、Amazon EC2、DynamoDB など、多くの AWS サービス向けの Java API を提供するため、コーディングの複雑さが軽減されます。 https://aws.amazon.com/jp/sdk-for-java/
AWS CLI のインストールと設定 http://docs.aws.amazon.com/ja_jp/streams/latest/dev/kinesis-tutorial-cli-installation.html
CloudFormation https://dev.classmethod.jp/beginners/chonyumon-cloudformation/
项目里利用Boto来实现cloudformation生成的程序实现。 http://boto3.readthedocs.io/en/latest/reference/services/cloudformation.html Boto は Python のパッケージで、 Amazon S3 を含む AWS へのインターフェイスです。
CloudFormationの要素
AWSTemplateFormatVersion: "version date" #必須:2010−09−09で固定
Description: #任意:テンプレートの説明
String
Metadata: #任意:テンプレートに関する追加情報
template metadata
Parameters: #任意:テンプレートに渡すことができる値
set of parameters
Mappings: #任意:条件によるキーと値のマッピング
set of mappings
Conditions: #任意:条件の定義
set of conditions
Transform: #任意:AWS Serverless Application Modelのバージョンを指定
set of transforms
Resources: #必須:スタックで構築するリソースを指定
set of resources
Outputs: #任意:スタックのプロパティから返される値の表示
set of outputs
https://dev.classmethod.jp/cloud/aws/cloudformation-beginner01/
AWSTemplateFormatVersion: '2010-09-09'
Resources:
FirstVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
Tags:
- Key: Name
Value: FirstVPC
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: FirstVPC-IGW
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref FirstVPC
InternetGatewayId: !Ref InternetGateway
FrontendRouteTable:
Type: AWS::EC2::RouteTable
DependsOn: AttachGateway
Properties:
VpcId: !Ref FirstVPC
Tags:
- Key: Name
Value: FirstVPC-FrontendRoute
FrontendRoute:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref FrontendRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
FrontendSubnet:
Type: AWS::EC2::Subnet
DependsOn: AttachGateway
Properties:
CidrBlock: 10.0.1.0/24
MapPublicIpOnLaunch: 'true'
VpcId: !Ref FirstVPC
Tags:
- Key: Name
Value: FirstVPC-FrontendSubnet
FrontendSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref FrontendSubnet
RouteTableId: !Ref FrontendRouteTable
DependsOn(リソース依存関係の定義) 特定リソースが他のリソースに続けて作成されるように指定します。 上のテンプレートファイル例では、FrontendRouteTableの作成時、DependsOnで、AttachGatewayリソースに対して、依存関係を設定しています。
Resource リソースの名前はテンプレートの中で一意である必要があります。悲しきかな、リソースの名前は[a-zA-Z0-9]+しか使えないようです。最初、ハイフンとかアンスコを駆使した名前でテンプレートを作ってしまい、地獄を見ました。使えればいいのになぁ。あと、リソース名は大文字から始めるのが慣例のようです。 リソースの定義順は任意で構いません。CloudFormationが依存関係を計算し、適切な順番でリソースを作成してくれます。逆に言えば、リソースの作成順序を制御することはできません。
Resource type Type: AWS::EC2::VPC Type: AWS::EC2::InternetGateway Type: AWS::EC2::VPCGatewayAttachment Type: AWS::EC2::RouteTable Type: AWS::EC2::Route Type: AWS::EC2::Subnet Type: AWS::EC2::SubnetRouteTableAssociation https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
組み込み関数 https://qiita.com/bisque33/items/51147a65c2ba40417d01 Fn::Join : 指定された配列を、指定された連結文字列で結合します。
"Value": { "Fn::Join" : [ ",", { "Ref": "DMZSubnets" } ] }
例えば、パラメータのDMZSubnetsが["subnet-aaaaaa","subnet-bbbbbb"]だとすると、
"Value": { "Fn::Join" : [ ",", ["subnet-aaaaaa","subnet-bbbbbb"] ] }となって、
"Value": "subnet-aaaaaa,subnet-bbbbbb"になります。
Fn::GetAtt :指定されたオブジェクトから特定の属性値を取得します。
Fn::Base64 : EC2にミドルウェアを設定する時に環境固有の情報をパラメータから入力します。しかし日本語のようなマルチバイト文字を入力すると全て『?』と表示されてしまう。結論として、マルチバイト文字を入力する方法はありませんでした。EC2のUserDataやMetadataへ流し込む時にマルチバイトが文字化けしてしまいます。その代わり一旦ASCII文字に変換すれば、ASCII文字を入力することになるので使用できることがわかりました。CloudFormationで使用できる組み込み関数の中でASCII文字に変換できるのはFn::Base64です。Fn::Base64を使用してBase64エンコーディングしてASCII文字として入力します。 https://dev.classmethod.jp/cloud/aws/cfn-multibyte-character-input/
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters" : {
"KeyName" : {★★
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"Type" : "String"
}
},
"Resources": {
(略)
"WebServer" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : "ami-54cf5c3d",
"InstanceType" : "t1.micro",
"KeyName" : { "Ref" : "KeyName" }, ★★
"SecurityGroupIds" : [
{ "Ref" : "SSHGroup" },
{ "Ref" : "WebGroup" }
]
}
},
(略)
}
}
Conditions 定义一些条件,在Resource里可以指定某个条件,当满足这个条件时才有效。 可参考下面URL里的例子。 https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html テスト環境と本稼働環境など、異なるコンテキストでリソースを作成できるテンプレートを再利用する場合に、条件を使用することがあります。テンプレートで EnvironmentType 入力パラメーターを追加できます。このパラメーターは入力として prod または test を受け取ることができます。本稼働環境では特定の機能に Amazon EC2 インスタンスを含め、テスト環境ではコスト削減のために使用する機能数を減らす場合があります。条件を使用すると、どのリソースを作成するかや、それらを各環境タイプでどのように設定するかを定義できます。
AWS::Region AWS CloudFormation によって事前定義されたパラメータ(擬似パラメーター)です。テンプレートでは宣言しません。 他の疑似パラメータ: AWS::AccountId : スタックが作成されているアカウントの AWS アカウント ID。 AWS::Partition、AWS::StackNameなど https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html
スタックを作成した結果分かったことを教えて欲しい「アウトプット」 https://dev.classmethod.jp/cloud/aws/cloudformation-firstcontact/ スタックが完成した後、CloudFormationのOutputsというタブで、この情報が確認できるようになります。
cfn-init https://dev.classmethod.jp/cloud/aws/cfn-init/ 「機能特化したAMIは作らず、プレーンなAMIにUserDataを与え、起動したら勝手に特化するように仕組む」という場面に利用。CloudFormationはcfn-initというヘルパースクリプトを用意しています。
cfn-initは、CloudFormationテンプレートのMetadataに書いた内容を読み込んで処理してくれる。
$ cfn-init -s STACK_NAME -r Logical_ID --region REGION
STACK_NAME | CloudFormationのスタック名
Logical ID | Resourceの名前。
REGION | リージョン
UserData UserDataに定義したスクリプトが実行されます。 httpdインストールしましょうか?
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"yum -y update\n",
"yum -y install httpd\n",
"chkconfig httpd on\n",
"service httpd start\n"
]]}}
User Dataの指定方法 "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [〜]]}} というのはイディオムなので覚えておきましょう。
Boto Boto は Python のパッケージで、 Amazon S3 を含む AWS へのインターフェイスです。
VPC Virtual Private Cloud (VPC) は、AWS アカウント専用の仮想ネットワークです。VPC は、AWS クラウドの他の仮想ネットワークから論理的に切り離されており、AWS のリソース (例えば Amazon EC2 インスタンス) を VPC 内に起動できます。
VPC を作成するときに、その VPC に対して、IPv4 アドレスの範囲を Classless Inter-Domain Routing (CIDR) ブロックの形式で指定する必要があります (例: 10.0.0.0/16)。これは VPC のプライマリ CIDR ブロックです。
次の図は、IPv4 CIDR ブロックとメインルートテーブルがある新しい VPC を示しています。
IPv4 用の VPC とサブネットのサイズ設定 VPC を作成するときに、その VPC の IPv4 CIDR ブロックを指定する必要があります。許可されるブロックサイズは、/16 ネットマスク(65,536 個の IP アドレス)から /28 ネットマスク(16 個の IP アドレス)の間です。VPC を作成したら、VPC とセカンダリ CIDR ブロックを関連付けることができます。詳細については、「IPv4 CIDR ブロックを VPC に追加する」を参照してください。
VPC を作成する場合は、/16RFC 1918 に指定されているように、プライベート IPv4 アドレス範囲から CIDR ブロック ( 以下) を指定することをお勧めします。 10.0.0.0 - 10.255.255.255 (10/8 プレフィックス) 172.16.0.0 - 172.31.255.255 (172.16/12 プレフィックス) 192.168.0.0 - 192.168.255.255 (192.168/16 プレフィックス) https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Subnets.html
サブネットをインターネットに接続 サブネットをインターネットに接続するには、「インターネットゲートウェイ(Internet Gateway)」を用いる。これは、「自分のネットワークにインターネット回線を引き込む」というイメージの作業。 インターネットゲートウェイを作成する [Internet Gateways] > [Create Internet Gateway] VPC領域に結びつける. 作成したインターネットゲートウェイにチェックをつけてから、[Attach to VPC]をクリック。結びつけるVPC領域を選択。
インターネットゲートウェイ EC2::InternetGateway インターネットゲートウェイは、VPC のインスタンスとインターネットとの間の通信を可能にする VPC コンポーネント。 インターネットゲートウェイは 2 つの目的を果たします。1 つは、インターネットでルーティング可能なトラフィックの送信先を VPC のルートテーブルに追加することです。もう 1 つは、パブリック IPv4 アドレスが割り当てられているインスタンスに対してネットワークアドレス変換 (NAT) を行うことです。 インターネットゲートウェイは、IPv4 トラフィックおよび IPv6 トラフィックをサポートしています。 https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Internet_Gateway.html
ルートテーブル VPC の各サブネットをルートテーブルに関連付ける必要があります。サブネットのルーティングは、このテーブルによってコントロールされます。1 つのサブネットは同時に 1 つのルートテーブルにしか関連付けることはできませんが、異なる複数のサブネットを 1 つのルートテーブルに関連付けることはできます。
各サブネットをルートテーブルに関連付ける必要があります。サブネットのルーティングは、このテーブルによってコントロールされます。サブネットを特定のルートテーブルに明示的に関連付けないと、そのサブネットは、メインルートテーブルに暗示的に関連付けられます。 https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Route_Tables.html
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
VPCとサブネットについて
サブネットの種類
パブリックサブネット -> インターネットゲートウェイにルーティングされている
プライベートサブネット -> インターネットゲートウェイへのルートがない
VPNのみのサブネット -> インターネットゲートウェイへのルートがなく、トラフィックがVPN接続の仮想プライベートゲートウェイにルーティングされている
public subnet里有网络gate (上图绿色字体的igw-id),而private subnet里没有 http://www.simpline.co.jp/tech/?p=1877
[新機能] VPCのCIDRが拡張可能になりました!IPアドレス範囲を追加可能です! https://dev.classmethod.jp/cloud/aws/expanding-vpc-cidr/
AWSアカウントとVPC、分ける? 分けない?: 分割パターンのメリット・デメリット https://dev.classmethod.jp/cloud/aws/account-and-vpc-dividing-pattern/
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー 常識: サブネット化のメリット サブネット化しない場合の問題点: 1.ホストの台数が増えることによって同じネットワークだと余計な通信が発生します。余計な通信とはブロードキャストです。ブロードキャストは、同じネットワークに対して出す通信です。 2.セキュリティの問題。 例えば人事部が持っている社員の評価が書いてあるデータを他の部門の人にアクセスさせたくない場合。同じネットワークにいるとセキュリティを高めることがすごく難しくなります。
サブネットに分割する理由
サブネットマスク IPアドレスの32ビットのうち何ビットをネットワークアドレスに使うのかを定義するための32ビットの数値のことです。例:「192.168.1.0/24」または「192.168.1.0 255.255.255.0」
現在の日本国内の社内ネットワークなどで最も使用されているサブネット化は、クラスAまたはクラスBのネットワークで「ホスト部を 8 ビットだけにする」というパターンです。つまり、1つのネットワークに最大254台のホスト数が、ブロードキャストの分割、IPアドレス計画、ルーティング設計、セキュリティの観点から最も都合が良いからです。
什么是公有IP地址(公网IP): 组建一个企业级网络,需要去向“电信运营商ISP”申请一个接入Internet的宽带,同时ISP还会给我们分配一个或多个IP地址,这些IP地址可以供我们企业内部上网,这些ISP分配给我们的IP,就是公有IP。 公有地址(Public address,也可称为公网地址)由Internet NIC(Internet Network Information Center因特网信息中心)负责。这些IP地址分配给注册并向Internet NIC提出申请的组织机构。通过它直接访问因特网,它是广域网范畴内的。
什么是私有IP地址(私网IP): 我们企业或家庭内部组建局域网用的IP,一般都会用私有IP。 私有地址(Private address,也可称为专网地址)属于非注册地址,专门为组织机构内部使用,它是局域网范畴内的,私有IP禁止出现在Internet中,在ISP连接用户的地方,将来自于私有IP的流量全部都会阻止并丢掉。 如果在企业内部的电脑要访问Internet,则需要在企业边界上用“NAT技术”将私网IP转成公网IP才能正常的上网。
公有IP地址的范围: A类的公有IP: 1.0.0.0~9.255.255.255 11.0.0.0~126.255.255.255 B类的公有IP: 128.0.0.0~172.15.255.255 172.32.0.0~191.255.255.255 C类的公有IP: 192.0.0.0~192.168.255.255 192.169.0.0~223.255.255.255
私有IP地址的范围: A类私有IP地址: 10.0.0.0~10.255.255.255 B类私有IP地址: 172.16.0.0~172.31.255.255 C类私有IP地址: 192.168.0.0~192.168.255.255
局域网在选取使用私有地址时,一般会按照实际需要容纳的主机数来选择私有地址段。常见的局域网由于容量小,一般选择C类的192.168.0.0作为地址段使用,一些大型企业就需要使用B类甚至A类地址段作为内部网络的地址段。最后需要补充说明的是,由于NAT和子网掩码的存在,实际在使用中,一个C类大小的局域网也可以选择A类的10.0.0.0网段作为自己的IP地址段。大多数局域网之所以仍然选择192.168.0.0/24或者192.168.1.0/24作为自己的IP地址段,更多的是因为约定成俗或者说网管个人习惯的关系。
NAT NATとは. NAT(Network Address Translation)はIPアドレスを変換する技術です。一般的には、プライベート IPアドレスをグローバルIPアドレスに変換する技術とされています。インターネットでは、グローバル IPアドレスを使用して構築したネットワークですが、企業ネットワークでは、プライベートIPアドレス を使用して構築されたネットワークなので、企業LANネットワークのクライアントPCがインターネット 接続する場合、プライベートIPアドレスをグローバルIPアドレスに変換(NAT)をする必要があります。
Availability Zone (AZ) 各リージョンは完全に独立しています。各アベイラビリティーゾーンは独立していますが、同じリージョン内のアベイラビリティーゾーンどうしは低レイテンシーのリンクで接続されています。
リージョンというのは、 東京 や バージニア 、 サンパウロ などです。リージョンはそれぞれ、地理的に離れた領域です。1 つのリージョンに複数のそれぞれ独立したロケーションがあり、このロケーションを「アベイラビリティーゾーン」といいます。Amazon EC2 では、お客様がインスタンスなどのリソースとデータを複数のロケーションに配置できます。複数のリージョンにまたがってリソースのレプリケーションを行うには、お客様がそのように指定する必要があります。
インターネットゲートウェイ https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Internet_Gateway.html インターネットゲートウェイは、VPC のインスタンスとインターネットとの間の通信を可能にする VPC コンポーネント。
VPC はインターネットとは切り離された存在です。VPC とインターネットの中継ポイントとしてインターネットゲートウェイを作成する必要があります。Internet Gateways の Create Internet Gateway から作成します。
Name tag: mygateway
作成したら Attach to VPC で myvpc にアタッチします。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー NAT ゲートウェイ ネットワークアドレス変換 (NAT) ゲートウェイを使用して、プライベートサブネットのインスタンスからはインターネットや他の AWS サービスに接続できるが、インターネットからはこれらのインスタンスとの接続を開始できないようにする。 https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/vpc-nat-gateway.html
NAT ゲートウェイを作成するには、NAT ゲートウェイの常駐先のパブリックサブネットを指定する必要があります。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー ルートテーブル https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Route_Tables.html#RouteTables 各サブネットをルートテーブルに関連付ける必要があります。サブネットのルーティングは、このテーブルによってコントロールされます。サブネットを特定のルートテーブルに明示的に関連付けないと、そのサブネットは、メインルートテーブルに暗示的に関連付けられます。
Each route in a table specifies a destination CIDR and a target (for example, traffic destined for the external corporate network 172.16.0.0/12 is targeted for the virtual private gateway). テーブル内の各ルートは送信先 CIDR とターゲットを指定します (たとえば、送信先が外部の企業ネットワーク 172.16.0.0/12 のトラフィックのターゲットは仮想プライベートゲートウェイです)。AWS では、トラフィックと一致する最も具体的なルートを使用して、トラフィックをルーティングする方法を決定します。
Every route table contains a local route for communication within the VPC over IPv4. If your VPC has more than one IPv4 CIDR block, your route tables contain a local route for each IPv4 CIDR block. If you've associated an IPv6 CIDR block with your VPC, your route tables contain a local route for the IPv6 CIDR block. You cannot modify or delete these routes.
インターネットゲートウェイ、Egress-Only インターネットゲートウェイ、仮想プライベートゲートウェイ、NAT デバイス、ピアリング接続、または VPC エンドポイントを VPC に追加するときに、これらのゲートウェイまたは接続を使用するサブネットのルートテーブルを更新する必要があります。 VPC ごとに、作成できるルートテーブルの数と、ルートテーブルごとに追加できるルートの数には制限があります。
例:
Destination: 192.168.0.0/16 (VPC のプライベートアドレス空間)
Target: local
このエントリによって、この VPC 内のインスタンスが相互に通信できるようになります。 Target local とは VPC 内に存在するはずだから適切なサブネットにルーティングすればよいという AWS VPC 独特の表記です。これによってサブネット間の通信が可能になっています。こちらの記事で想像されているように、仮想ルータ同士はお互いに接続されているのです。
0.0.0.0/0 is also known as default. You can call it "everything else" other than what is already specified in your routing table.
Amazon VPC の制限 https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Appendix_Limits.html
ルーティングテーブル ルーターやネットワーク接続されたコンピュータが持つ、個々のネットワークの宛先への経路の一覧を保持しているテーブル状のデータ構造である。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー Elastic IP 動的なクラウドコンピューティング向けに設計された静的なパブリック IPv4 アドレスです。 Elastic IP アドレスは、アカウントのすべての VPC の任意のインスタンスまたはネットワークインターフェイスに関連付けることができます。
Amazon EC2 リソースにタグを付ける https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/Using_Tags.html
タグを使用すると、AWS リソースを目的、所有者、環境などさまざまな方法で分類することができます。 タグはそれぞれ、1 つのキーとオプションの 1 つの値で構成されており、どちらもお客様側が定義します。 図の中では、インスタンスのそれぞれに 2 つのタグを割り当てています。1 つは Owner、もう 1 つは Stack という名前です。各タグには値も関連付けられています。
タグには以下のような基本制限があります。
リソース Amazon EC2 にはさまざまなリソースが用意されており、それらを作成して利用することができます。これらのリソースには、イメージ、インスタンス、ボリューム、スナップショットなどがあります。リソースを作成すると、リソースに一意のリソース ID が割り当てられます。
セキュリティグループ セキュリティグループは、インスタンスの仮想ファイアウォールとして機能し、インバウンドトラフィックとアウトバウンドトラフィックをコントロールします。
VPC 内でインスタンスを起動した場合、そのインスタンスには最大 5 つのセキュリティグループを割り当てることができます。
セキュリティグループは、サブネットレベルでなくインスタンスレベルで動作します。
セキュリティグループごとに、インスタンスへのインバウンドトラフィックをコントロールするルールと、アウトバウンドトラフィックをコントロールする一連のルールを個別に追加します。
セキュリティグループとネットワーク ACL の基本的な違い https://docs.aws.amazon.com/ja_jp/AmazonVPC/latest/UserGuide/VPC_Security.html#VPC_Security_Comparison
ネットワークACL
IAM
Lock Away Your AWS Account Root User Access Keys
Create Individual IAM Users
Use AWS Defined Policies to Assign Permissions Whenever Possible
Use Groups to Assign Permissions to IAM Users All the users in an IAM group inherit the permissions assigned to the group. That way, you can make changes for everyone in a group in just one place. As people move around in your company, you can simply change what IAM group their IAM user belongs to.
Grant Least Privilege One feature that can help with this is the Access Advisor tab. This tab is available on the IAM console details page whenever you inspect a user, group, role, or policy. The tab includes information about which services are actually used by a user, group, role, or by anyone that uses a policy.
Use Access Levels to Review IAM Permissions AWS categorizes each service action into one of four access levels based on what each action does: List, Read, Write, or Permissions management. You can use these access levels to determine which actions to include in your policies.
To see the access levels for a policy, you must first locate the policy's summary. The policy summary is included on the Policies page for managed policies, and on the Users page for policies that are attached to a user.
The MFA device can either be a special piece of hardware, or it can be a virtual device (for example, it can run in an app on a smartphone).
When you launch an EC2 instance, you can specify a role for the instance as a launch parameter. Applications that run on the EC2 instance can use the role's credentials when they access AWS resources. The role's permissions determine what the application is allowed to do.
User是给人用,role是给App用(?)
Delegate by Using Roles Instead of by Sharing Credentials You might need to allow users from another AWS account to access resources in your AWS account. If so, don't share security credentials, such as access keys, between accounts. Instead, use IAM roles.
Rotate Credentials Regularly
Remove Unnecessary Credentials
Use Policy Conditions for Extra Security
Monitor Activity in Your AWS Account You can use logging features in AWS to determine the actions users have taken in your account and the resources that were used. The log files show the time and date of actions, the source IP for an action, which actions failed due to inadequate permissions, and more.
# Policy Summary (List of Services) https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_understand-policy-summary.html Policies are summarized in three tables: the policy summary, the service summary, and the action summary.
Note: Amazon EC2 uses SSH keys, Windows passwords, and security groups to control who has access to the operating system of specific Amazon EC2 instances. There's no method in the IAM system to allow or deny access to the operating system of a specific instance.
Amazon S3 doesn't automatically give a user who creates a bucket or object permission to perform other actions on that bucket or object. Therefore, in your IAM policies, you must explicitly give users permission to use the Amazon S3 resources they create.
Logging IAM Events with AWS CloudTrail
AMI
HVM AMIs 和 PV AMI https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html
HVM クラスタインスタンスがリリースされた際に HVM (Hardware-assited VM) という方式がサポート(というか必須)されました。 HVM AMIs are presented with a fully virtualized set of hardware and boot by executing the master boot record of the root block device of your image. This virtualization type provides the ability to run an operating system directly on top of a virtual machine without any modification, as if it were run on the bare-metal hardware. Unlike PV guests, HVM guests can take advantage of hardware extensions that provide fast access to the underlying hardware on the host system. All instance types support HVM AMIs.
AWS応用例