AWS Black Belt Online Seminar · 0. ハイブリッド環境用のIAM...
Transcript of AWS Black Belt Online Seminar · 0. ハイブリッド環境用のIAM...
【AWS Black Belt Online Seminar】
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
サービス名 概要
メンテナンスウィンドウ 定期的に行う管理作業やサービス停止の実施時間帯を定義する
Run Command 安全にインスタンス上の管理作業を実施するSSHやRDPを使用せず多数のサーバを一括操作
Automation 一連の作業フローを定義するパッチを適用してAMIを作成する、インスタンススペックを変更するなど
ステートマネージャー あるべきOSの設定値を定義し維持するポリシーに準拠したファイアウォール設定やアンチマルウェアツールの設定
インベントリ インストール済みソフトウェアの一覧を収集・検索する
Patch Manager OSパッチの選択と適用を自動的に実施する
ドキュメント Systems Managerの各サービスの挙動を定義する設定ドキュメントコマンド、ポリシー、自動化の3種類がある
パラメータストア 設定値やパスワードなどを集中管理する階層型ストレージアクセス制御や他のサービスからの参照が容易に行える
•
•
•
•
• Windows Server
• Windows Server 2003 から Windows Server 2016(R2 バージョンを含む)
• Linux
• 64 ビットおよび 32 ビットシステム
• Amazon Linux 基本 AMI 2014.09、2014.03 以降
• Ubuntu Server 18.04 LTS、16.04 LTS、14.04 LTS、または 12.04 LTS
• Red Hat Enterprise Linux (RHEL) 6.5
• CentOS 6.3 以降
• 32 ビットシステムのみ
• Raspbian Jessie
• Raspbian Stretch
• 64 ビットシステムのみ
• Amazon Linux 2015.09、2015.03 以降
• Amazon Linux 2
• Red Hat Enterprise Linux (RHEL) 7.4
• CentOS 7.1 以降
• SUSE Linux Enterprise Server (SLES) 12 以上
2018/07/25 : https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/systems-manager-prereqs.html
https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/patch-manager-supported-oses.html
• SSM AgentはSystems Manager APIを呼び出す
• 以下のいずれかのネットワークを構成する
1. インターネットへのアウトバウンドアクセス
• インバウンドアクセスは不要
• パブリックサブネットやNAT Gatewayを使用
2. VPC エンドポイントへのアクセス
• プライベートネットワークによる接続が可能
• インターフェイスエンドポイント
• com.amazonaws.region.ssm
• com.amazonaws.region.ec2messages
• com.amazonaws.region.ec2
• ゲートウェイエンドポイント
• S3
Systems Manager APIを呼び出すためのインスタンスプロファイル
を作成してEC2にアタッチ
• IAM Roleを作成
• IAM ポリシー「AmazonEC2RoleforSSM」を割り当て
• Trusted EntityをEC2とする
(EC2にこのロールを付与できるようにする)
サーバにSSM Agentを導入しサービスを起動
• 次のAMIはデフォルトでSSM Agent導入済み
• Windows Server
• Amazon Linux
• Amazon Linux2
• Ubuntu Server 18.04
• AgentのインストーラはS3に配置https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/ssm-agent.html
• CloudWatch AgentやInspector Agentは後からSSMを使用してインストールすれば良い
0. ハイブリッド環境用のIAM Roleを作成(初回のみ)1. オンプレミスサーバにSSM Agentを導入2. Systems Manager APIへのアクセス経路を確保
• DirectConnectやProxyによりVPCエンドポイントの利用も可能
3. SSMでアクティベーションコードを生成4. インスタンスにアクティベーションコードを設定
••
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
••
•
•
•
---schemaVersion: "2.2"description: "MyConfigurationAsCode"mainSteps:- action: "aws:runDocument"name: "InstallApache"inputs:documentType: "SSMDocument"documentPath: "arn:aws:ssm:us-west-1::document/InstallApache"documentParameters: "{ }"
- action: "aws:downloadContent"name: "AnsiblePlaybookfromGitHub"inputs:sourceType: "GitHub"sourceInfo: "{¥"owner¥":¥“Amjad¥", ¥"repository¥":¥"MyPrivateRepo¥",¥"path¥"¥:¥"documents/nginx.yml¥", ¥"tokenInfo¥":¥"{{ ssm-secure:MyAccessToken }}¥"}"
destinationPath: ""- action: "aws:runShellScript"name: "RunPlaybook"inputs:commands:- "ansible-playbook -i ¥"localhost,¥" -c local nginx.yml"
1 AWS-ApplyPatchBaseline Windows
2 AWS-ConfigureAWSPackage Windows Linux
3 AWS-ConfigureCloudWatch Windows
4 AWS-ConfigureDocker Windows Linux
5 AWS-ConfigureWindowsUpdate Windows
6 AWS-FindWindowsUpdates Windows
7 AWS-InstallApplication Windows
8 AWS-InstallMissingWindowsUpdates Windows
9 AWS-InstallPowerShellModule Windows
10 AWS-InstallSpecificWindowsUpdates Windows
11 AWS-InstallWindowsUpdates Windows
12 AWS-JoinDirectoryServiceDomain Windows
13 AWS-ListWindowsInventory Windows
14 AWS-RefreshAssociation Windows Linux
15 AWS-RunAnsiblePlaybook Linux
16 AWS-RunDockerAction Windows Linux
17 AWS-RunDocument Windows Linux
18 AWS-RunInspecChecks Windows Linux
19 AWS-RunPatchBaseline Windows Linux
20 AWS-RunPowerShellScript Windows Linux
21 AWS-RunRemoteScript Windows Linux
22 AWS-RunSaltState Linux
23 AWS-RunShellScript Linux
24 AWS-UpdateEC2Config Windows
25 AWS-UpdateSSMAgent Windows Linux
26 AWSSupport-RunEC2RescueForWindowsTool Windows
27 AmazonInspector-ManageAWSAgent Windows Linux
28 AWSEC2-CreateVssSnapshot Windows
29 AWSEC2-ManageVssIO Windows
30 AWSEC2-RunSysprep Windows
31 AmazonCloudWatch-ManageAgent Windows Linux
32 AmazonCloudWatch-MigrateCloudWatchAgent Windows
名前 概要 プラットフォーム
AWS-GatherSoftwareInventory サーバ上のソフトウェア一覧情報を取得する Windows Linux
1 AWS-ASGEnterStandby Windows Linux
2 AWS-ASGExitStandby Windows Linux
3 AWS-AttachEBSVolume Windows Linux
4 AWS-AttachIAMToInstance Windows Linux
5 AWS-ConfigureCloudWatchOnEC2Instance Windows Linux
6 AWS-CopySnapshot Windows Linux
7 AWS-CreateManagedLinuxInstance Windows Linux
8 AWS-CreateManagedLinuxInstanceWithApproval Windows Linux
9 AWS-CreateManagedWindowsInstance Windows Linux
10 AWS-CreateManagedWindowsInstanceWithApproval Windows Linux
11 AWS-CreateSnapshot Windows Linux
12 AWS-DeleteCloudFormationStack Windows Linux
13 AWS-DeleteCloudFormationStackWithApproval Windows Linux
14 AWS-DeleteSnapshot Windows Linux
15 AWS-DetachEBSVolume Windows Linux
16 AWS-RebootRdsInstance Windows Linux
17 AWS-ResizeInstance Windows Linux
18 AWS-RestartEC2Instance Windows Linux
19 AWS-RestartEC2InstanceWithApproval Windows Linux
20 AWS-SetupInventory Windows Linux
21 AWS-SetupManagedInstance Windows Linux
22 AWS-SetupManagedRoleOnEc2Instance Windows Linux
23 AWS-StartEC2Instance Windows Linux
24 AWS-StartEC2InstanceWithApproval Windows Linux
25 AWS-StartRdsInstance Windows Linux
26 AWS-StopEC2Instance Windows Linux
27 AWS-StopEC2InstanceWithApproval Windows Linux
28 AWS-StopRdsInstance Windows Linux
29 AWS-TerminateEC2Instance Windows Linux
30 AWS-TerminateEC2InstanceWithApproval Windows Linux
31 AWS-UpdateCloudFormationStack Windows Linux
32 AWS-UpdateCloudFormationStackWithApproval Windows Linux
33 AWS-UpdateLinuxAmi Windows Linux
34 AWS-UpdateWindowsAmi Windows Linux
35 AWSSupport-ActivateWindowsWithAmazonLicense Windows Linux
36 AWSSupport-ExecuteEC2Rescue Windows Linux
37 AWSSupport-GrantPermissionsToIAMUser Windows Linux
38 AWSSupport-ManageRDPSettings Windows Linux
39 AWSSupport-ManageWindowsService Windows Linux
40 AWSSupport-ResetAccess Windows Linux
41 AWSSupport-SendLogBundleToS3Bucket Windows Linux
42 AWSSupport-TroubleshootRDP Windows Linux
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•No more plaintext secrets !
Dev Test Prod
App App App
/test/app/db_password /prod/app/db_password
notification
Rotate password
event
(event-based)
SSM Parameter Store
•
aws ssm put-parameter --name /MySystem/Prod/DB/User --type String --value myuser
aws ssm get-parameter --name /MySystem/Prod/DB/User
{
"Parameter": {
"Name": "/MySystem/Dev/DB/User",
"Type": "String",
"Value": "ohmurayu",
"Version": 1
}
}
SSM Parameter Store (CloudFormation)
CFn Parameters
自身で設定した値を使用
AWSが提供する値を使用
Parameters:
MyAMIID:
Type : AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
Default: /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2
# Default: /aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base
注:SecureStringは2018/6/1時点で未対応
Parameters:
Env:
Type: AWS::SSM::Parameter::Value<String>
Default: /MySystem/Prod/DB/User
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Document
Run the automation
Role and permissioninput
•
•
•
•
•
•
•
•
•
•
•
https://aws.amazon.com/jp/blogs/news/streamline-ami-maintenance-and-patching-using-amazon-ec2-systems-manager-automation/
https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/integration-vss.html
https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/integration-chef-inspec.html
•
•
•
•
•
•
•
•
•
••
•
••
••
•
•
•
•
AWS cloudcorporate data
center
IT Admin, DevOps Engineer
Role-based Access Control
aws ssm send-command
--document-name MyDoc
--targets Key=tag:tag_key,Values=tag_value
•
•
•
•
•
•
•
•
•
•
•
••
•
••
•
AWS cloudCorporate data
center
Amazon
Athena
Amazon
QuickSight
SSM
Amazon S3 data lake
Custom
Analytic ToolAWS Config
AWS Config Rules
•
•
•
•
•
--------- Custom Inventory -----------
aws ssm put-inventory --instance-id "ID" --items '[{"CaptureTime": "2016-08-22T10:01:01Z", "TypeName": "Custom:RackInfo", "Content":[{"RackLocation": "Bay B/Row C/Rack D/Shelf E"}], "SchemaVersion": "1.0"}]‘
SSM Inventory
AWS Config
Blacklist
AWS Config Rule
CloudWatch Events &
Lambda
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Corp data center
Patch Group = DBServers
Patch Group = WebServers
Patch Group = SQL Cluster
DB Server
Patch Baseline
Web Server
Patch Baseline
Patch Manager
Maintenance
Window
ComplianceNotifications!
PatchGroup=HR, Batch
PatchGroup=Web
Tag: PatchGroup=HR
Tag: PatchGroup=Batch
Tag: PatchGroup=Web
OS• Windows Server
• Windows Server 2008 から Windows Server 2016(R2 バージョンを含む)
• Microsoft からパッチがリリースされてから数時間以内に、すべてのサポート対象のオペレーティングシステムにパッチを提供
• Linux• 64 ビットおよび 32 ビットシステム
• Red Hat Enterprise Linux (RHEL) 6.5 - 6.9
• Ubuntu Server 14.04 LTS および 16.04 LTS
• Amazon Linux 2012.03 - 2017.03
• CentOS 6.5 以降
• 64 ビットシステムのみ
• Red Hat Enterprise Linux (RHEL) 7.0 - 7.4
• SUSE Linux Enterprise Server (SLES) 12
• Amazon Linux 2015.03 - 2018.03
• CentOS 7.1 以降https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/patch-manager-supported-oses.html
•
•
•
•
•
•
•
•
SSM
•
•
•
•
•
••
•
••
•
•
••
•
••
•
json
jsonjson
$ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard ============================================================== Welcome to the AWS CloudWatch Agent Configuration Manager ==============================================================On which OS are you planning to use the agent?1. linux2. windowsdefault choice: [1]:1Trying to fetch the default region based on ec2 metadata...Are you using EC2 or On-Premises hosts?1. EC22. On-Premisesdefault choice: [1]:1Do you want to monitor any host metrics? e.g. CPU, memory, etc.1. yes2. nodefault choice: [1]:1Do you want to monitor cpu metrics per core? Additional CloudWatch charges may apply.1. yes2. nodefault choice: [1]:1Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName) into all of your metrics if the info is available?
1. yes2. nodefault choice: [1]:1Would you like to collect your metrics at high resolution (sub-minute resolution)? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output json file.1. 1s2. 10s3. 30s4. 60sdefault choice: [4]:4Which default metrics config do you want?1. Basic2. Standard3. Advanced4. Nonedefault choice: [1]:3Are you satisfied with the above config? Note: it can be manually customized after the wizard completes to add additional items.1. yes2. nodefault choice: [1]:1
Do you have any existing CloudWatch Log Agent (http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AgentReference.html) configuration file to import for migration?1. yes2. nodefault choice: [2]:1What is the file path for the existing cloudwatch log agent configuration file?default choice: [/var/awslogs/etc/awslogs.conf]
Do you want to monitor any log files?1. yes2. nodefault choice: [1]:1Log file path:/var/log/messagesLog group name:default choice: [messages]
Do you want to specify any additional log files to monitor?1. yes2. nodefault choice: [1]:2Saved config file to /opt/aws/amazon-cloudwatch-agent/bin/config.json successfully.
Do you want to store the config in the SSM parameter store?1. yes2. nodefault choice: [1]:1What parameter store name do you want to use to store your config? (Use 'AmazonCloudWatch-' prefix if you use our managed AWS policy)default choice: [AmazonCloudWatch-linux]
Trying to fetch the default region based on ec2 metadata...Which region do you want to store the config in the parameter store?default choice: [ap-northeast-1]
Which AWS credential should be used to send json config to parameter store?1. ASIAIWED4ZE2H6FGPZRA(From SDK)2. Otherdefault choice: [1]:1Successfully put config to parameter store AmazonCloudWatch-linux.Program exits now.
•
•
•
•
•
•
•
•
•
••
••
••
•
•
••
••
•
••
•
•
•
•
•
•
•
•
@awscloud_jp検索
最新技術情報、イベント情報、お役立ち情報、お得なキャンペーン情報などを日々更新しています!
もしくはhttp://on.fb.me/1vR8yWm