AWS Black Belt Online Seminar
サービス名 メンテナンスウィンドウ Run Command Automation ステートマネージャーインベントリ Patch Manager ドキュメントパラメータストア 概要 定期的に行う管理作業やサービス停止の実施時間帯を定義する 安全にインスタンス上の管理作業を実施する SSH や RDP を使用せず多数のサーバを一括操作 一連の作業フローを定義するパッチを適用して AMI を作成する インスタンススペックを変更するなど あるべき OS の設定値を定義し維持するポリシーに準拠したファイアウォール設定やアンチマルウェアツールの設定 インストール済みソフトウェアの一覧を収集 検索する OS パッチの選択と適用を自動的に実施する Systems Manager の各サービスの挙動を定義する設定ドキュメントコマンド ポリシー 自動化の 3 種類がある 設定値やパスワードなどを集中管理する階層型ストレージアクセス制御や他のサービスからの参照が容易に行える
Windows Server Linux Windows Server 2003 から Windows Server 2016(R2 バージョンを含む ) 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
Dev Test Prod App App App /test/app/db_password Rotate password /prod/app/db_password event (event-based) email notification No more plaintext secrets!
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 自身で設定した値を使用 AWS が提供する値を使用 Parameters Parameters: Env: Type: AWS::SSM::Parameter::Value<String> Default: /MySystem/Prod/DB/User 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 時点で未対応
Document input Role and permission Run the automation
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 cloud corporate data center Role-based Access Control IT Admin, DevOps Engineer
aws ssm send-command --document-name MyDoc --targets Key=tag:tag_key,Values=tag_value
AWS cloud Corporate data center AWS Config AWS Config Rules SSM Amazon S3 data lake Amazon QuickSight Amazon Athena Custom Analytic Tool
--------- 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 = WebServers Patch Group = DBServers DB Server Patch Baseline Patch Group = SQL Cluster Web Server Patch Baseline Patch Manager Maintenance Window Compliance Notifications!
Tag: PatchGroup=HR PatchGroup=HR, Batch Tag: PatchGroup=Batch PatchGroup=Web Tag: PatchGroup=Web
Windows Server Linux OS Windows Server 2008 から Windows Server 2016(R2 バージョンを含む ) Microsoft からパッチがリリースされてから数時間以内に すべてのサポート対象のオペレーティングシステムにパッチを提供 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 json json
$ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatchagent-config-wizard ============================================================= = Welcome to the AWS CloudWatch Agent Configuration Manager = ============================================================= On which OS are you planning to use the agent? 1. linux 2. windows default choice: [1]: 1 Trying to fetch the default region based on ec2 metadata... Are you using EC2 or On-Premises hosts? 1. EC2 2. On-Premises default choice: [1]: 1 Do you want to monitor any host metrics? e.g. CPU, memory, etc. 1. yes 2. no default choice: [1]: 1 Do you want to monitor cpu metrics per core? Additional CloudWatch charges may apply. 1. yes 2. no default choice: [1]: 1 Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName) into all of your metrics if the info is available? 1. yes 2. no default choice: [1]: 1 Would you like to collect your metrics at high resolution (subminute resolution)? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output json file. 1. 1s 2. 10s 3. 30s 4. 60s default choice: [4]: 4 Which default metrics config do you want? 1. Basic 2. Standard 3. Advanced 4. None default choice: [1]: 3 Are you satisfied with the above config? Note: it can be manually customized after the wizard completes to add additional items. 1. yes 2. no default choice: [1]: 1
Do you have any existing CloudWatch Log Agent (http://docs.aws.amazon.com/amazoncloudwatch/latest/logs/agentre ference.html) configuration file to import for migration? 1. yes 2. no default choice: [2]: 1 What 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. yes 2. no default choice: [1]: 1 Log file path: /var/log/messages Log group name: default choice: [messages] Do you want to specify any additional log files to monitor? 1. yes 2. no default choice: [1]: 2 Saved config file to /opt/aws/amazon-cloudwatchagent/bin/config.json successfully. Do you want to store the config in the SSM parameter store? 1. yes 2. no default choice: [1]: 1 What 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. Other default choice: [1]: 1 Successfully put config to parameter store AmazonCloudWatchlinux. Program exits now.
@awscloud_jp 検索 もしくは http://on.fb.me/1vr8ywm 最新技術情報 イベント情報 お役立ち情報 お得なキャンペーン情報などを日々更新しています!