SlackでAWS Chatbotを使ってawsコマンドがたたけるようになったそうなので、試してみた

下記の記事にて AWS ChatbotがSlackからのコマンド実行をβ版サポートしたとのことで、早速試しました

[引用] [re:Invent 2019に向けて　2019年11月後半アップデートのまとめ　第四弾 | Amazon Web Services ブログ](https://aws.amazon.com/jp/blogs/news/reinvent-2019-pre-announce-list-part4/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+aws%2Fjp-blog-news+%28Amazon+Web+Services+%E3%83%96%E3%83%AD%E3%82%B0%29)
![スクリーンショット 2019-11-28 15.23.24.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/14268/f8478dac-761d-2d52-c07c-a6dee78b5a25.png)

画像キャプチャなどもある対応方法は下記のブログ記事で確認したので、操作手順は下記を参照してください。※英語ですが、、、、

[Running AWS commands from Slack using AWS Chatbot | AWS DevOps Blog](https://aws.amazon.com/jp/blogs/devops/running-aws-commands-from-slack-using-aws-chatbot/)

### 上記ブログの「2. Test AWS Chatbot in Slack and get help」のところまできて、 `@aws help` を実行してみたところ
![スクリーンショット 2019-11-28 15.32.21.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/14268/49e0035b-ed62-702b-bc42-dbe7a56db1f4.png)

１つのSlack内で複数のAWSアカウントのAWS Chatbotを利用している場合なんでしょうか。最初にどちらのAWSアカウントをデフォルトアカウントとして、利用するかを確認されました。
マスキングしてますが、アカウントIDの書かれた２つのボタンが表示されてボタンを押すだけです。

その後、 `@aws help` したところ上記ブログと同様のレスポンスがかえってきました
![スクリーンショット 2019-11-28 15.48.46.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/14268/7a2ec79e-a0e4-38f0-a86e-94ba2436d4db.png)

aws cliとほぼ似たようなコマンドで対応できるので、わかりやすいですね :thinking: 
取り急ぎ、EC2まわりを試したいので、 `@aws ec2 --help` してみたところ、結構いろんなコマンドがでてきました。

![スクリーンショット 2019-11-28 15.53.15.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/14268/9db4ee79-5068-cd5c-e0c9-77cb6a4fadfb.png)

```bash:使えるコマンドたち
Here are all the operations I know about for ec2:
• accept-reserved-instances-exchange-quote
• accept-transit-gateway-vpc-attachment
• accept-vpc-endpoint-connections
• accept-vpc-peering-connection
• advertise-byoip-cidr
• allocate-address
• allocate-hosts
• apply-security-groups-to-client-vpn-target-network
• assign-ipv6-addresses
• assign-private-ip-addresses
• associate-address
• associate-client-vpn-target-network
• associate-dhcp-options
• associate-iam-instance-profile
• associate-route-table
• associate-subnet-cidr-block
• associate-transit-gateway-route-table
• associate-vpc-cidr-block
• attach-classic-link-vpc
• attach-internet-gateway
• attach-network-interface
• attach-volume
• attach-vpn-gateway
• authorize-client-vpn-ingress
• authorize-security-group-egress
• authorize-security-group-ingress
• bundle-instance
• cancel-bundle-task
• cancel-capacity-reservation
• cancel-conversion-task
• cancel-export-task
• cancel-import-task
• cancel-reserved-instances-listing
• cancel-spot-fleet-requests
• cancel-spot-instance-requests
• confirm-product-instance
• copy-fpga-image
• copy-image
• copy-snapshot
• create-capacity-reservation
• create-client-vpn-endpoint
• create-client-vpn-route
• create-customer-gateway
• create-default-subnet
• create-default-vpc
• create-dhcp-options
• create-egress-only-internet-gateway
• create-fleet
• create-flow-logs
• create-fpga-image
• create-image
• create-instance-export-task
• create-internet-gateway
• create-key-pair
• create-launch-template
• create-launch-template-version
• create-nat-gateway
• create-network-acl
• create-network-acl-entry
• create-network-interface
• create-network-interface-permission
• create-placement-group
• create-reserved-instances-listing
• create-route
• create-route-table
• create-security-group
• create-snapshot
• create-snapshots
• create-spot-datafeed-subscription
• create-subnet
• create-tags
• create-traffic-mirror-filter
• create-traffic-mirror-filter-rule
• create-traffic-mirror-session
• create-traffic-mirror-target
• create-transit-gateway
• create-transit-gateway-route
• create-transit-gateway-route-table
• create-transit-gateway-vpc-attachment
• create-volume
• create-vpc
• create-vpc-endpoint
• create-vpc-endpoint-connection-notification
• create-vpc-endpoint-service-configuration
• create-vpc-peering-connection
• create-vpn-connection
• create-vpn-connection-route
• create-vpn-gateway
• delete-client-vpn-endpoint
• delete-client-vpn-route
• delete-customer-gateway
• delete-dhcp-options
• delete-egress-only-internet-gateway
• delete-fleets
• delete-flow-logs
• delete-fpga-image
• delete-internet-gateway
• delete-key-pair
• delete-launch-template
• delete-launch-template-versions
• delete-nat-gateway
• delete-network-acl
• delete-network-acl-entry
• delete-network-interface
• delete-network-interface-permission
• delete-placement-group
• delete-queued-reserved-instances
• delete-route
• delete-route-table
• delete-security-group
• delete-snapshot
• delete-spot-datafeed-subscription
• delete-subnet
• delete-tags
• delete-traffic-mirror-filter
• delete-traffic-mirror-filter-rule
• delete-traffic-mirror-session
• delete-traffic-mirror-target
• delete-transit-gateway
• delete-transit-gateway-route
• delete-transit-gateway-route-table
• delete-transit-gateway-vpc-attachment
• delete-volume
• delete-vpc
• delete-vpc-endpoint-connection-notifications
• delete-vpc-endpoint-service-configurations
• delete-vpc-endpoints
• delete-vpc-peering-connection
• delete-vpn-connection
• delete-vpn-connection-route
• delete-vpn-gateway
• deprovision-byoip-cidr
• deregister-image
• describe-account-attributes
• describe-addresses
• describe-aggregate-id-format
• describe-availability-zones
• describe-bundle-tasks
• describe-byoip-cidrs
• describe-capacity-reservations
• describe-classic-link-instances
• describe-client-vpn-authorization-rules
• describe-client-vpn-connections
• describe-client-vpn-endpoints
• describe-client-vpn-routes
• describe-client-vpn-target-networks
• describe-conversion-tasks
• describe-customer-gateways
• describe-dhcp-options
• describe-egress-only-internet-gateways
• describe-elastic-gpus
• describe-export-image-tasks
• describe-export-tasks
• describe-fast-snapshot-restores
• describe-fleet-history
• describe-fleet-instances
• describe-fleets
• describe-flow-logs
• describe-fpga-image-attribute
• describe-fpga-images
• describe-host-reservation-offerings
• describe-host-reservations
• describe-hosts
• describe-iam-instance-profile-associations
• describe-id-format
• describe-identity-id-format
• describe-image-attribute
• describe-images
• describe-import-image-tasks
• describe-import-snapshot-tasks
• describe-instance-attribute
• describe-instance-credit-specifications
• describe-instance-status
• describe-instances
• describe-internet-gateways
• describe-key-pairs
• describe-launch-template-versions
• describe-launch-templates
• describe-moving-addresses
• describe-nat-gateways
• describe-network-acls
• describe-network-interface-attribute
• describe-network-interface-permissions
• describe-network-interfaces
• describe-placement-groups
• describe-prefix-lists
• describe-principal-id-format
• describe-public-ipv4-pools
• describe-regions
• describe-reserved-instances
• describe-reserved-instances-listings
• describe-reserved-instances-modifications
• describe-reserved-instances-offerings
• describe-route-tables
• describe-scheduled-instance-availability
• describe-scheduled-instances
• describe-security-group-references
• describe-security-groups
• describe-snapshot-attribute
• describe-snapshots
• describe-spot-datafeed-subscription
• describe-spot-fleet-instances
• describe-spot-fleet-request-history
• describe-spot-fleet-requests
• describe-spot-instance-requests
• describe-spot-price-history
• describe-stale-security-groups
• describe-subnets
• describe-tags
• describe-traffic-mirror-filters
• describe-traffic-mirror-sessions
• describe-traffic-mirror-targets
• describe-transit-gateway-attachments
• describe-transit-gateway-route-tables
• describe-transit-gateway-vpc-attachments
• describe-transit-gateways
• describe-volume-attribute
• describe-volume-status
• describe-volumes
• describe-volumes-modifications
• describe-vpc-attribute
• describe-vpc-classic-link
• describe-vpc-classic-link-dns-support
• describe-vpc-endpoint-connection-notifications
• describe-vpc-endpoint-connections
• describe-vpc-endpoint-service-configurations
• describe-vpc-endpoint-service-permissions
• describe-vpc-endpoint-services
• describe-vpc-endpoints
• describe-vpc-peering-connections
• describe-vpcs
• describe-vpn-connections
• describe-vpn-gateways
• detach-classic-link-vpc
• detach-internet-gateway
• detach-network-interface
• detach-volume
• detach-vpn-gateway
• disable-ebs-encryption-by-default
• disable-fast-snapshot-restores
• disable-transit-gateway-route-table-propagation
• disable-vgw-route-propagation
• disable-vpc-classic-link
• disable-vpc-classic-link-dns-support
• disassociate-address
• disassociate-client-vpn-target-network
• disassociate-iam-instance-profile
• disassociate-route-table
• disassociate-subnet-cidr-block
• disassociate-transit-gateway-route-table
• disassociate-vpc-cidr-block
• enable-ebs-encryption-by-default
• enable-fast-snapshot-restores
• enable-transit-gateway-route-table-propagation
• enable-vgw-route-propagation
• enable-volumeio
• enable-vpc-classic-link
• enable-vpc-classic-link-dns-support
• export-client-vpn-client-certificate-revocation-list
• export-client-vpn-client-configuration
• export-image
• export-transit-gateway-routes
• get-capacity-reservation-usage
• get-console-output
• get-ebs-default-kms-key-id
• get-ebs-encryption-by-default
• get-host-reservation-purchase-preview
• get-launch-template-data
• get-password-data
• get-reserved-instances-exchange-quote
• get-transit-gateway-attachment-propagations
• get-transit-gateway-route-table-associations
• get-transit-gateway-route-table-propagations
• import-client-vpn-client-certificate-revocation-list
• import-image
• import-instance
• import-key-pair
• import-snapshot
• import-volume
• modify-capacity-reservation
• modify-client-vpn-endpoint
• modify-ebs-default-kms-key-id
• modify-fleet
• modify-fpga-image-attribute
• modify-hosts
• modify-id-format
• modify-identity-id-format
• modify-image-attribute
• modify-instance-attribute
• modify-instance-capacity-reservation-attributes
• modify-instance-credit-specification
• modify-instance-event-start-time
• modify-instance-metadata-options
• modify-instance-placement
• modify-launch-template
• modify-network-interface-attribute
• modify-reserved-instances
• modify-snapshot-attribute
• modify-spot-fleet-request
• modify-subnet-attribute
• modify-traffic-mirror-filter-network-services
• modify-traffic-mirror-filter-rule
• modify-traffic-mirror-session
• modify-transit-gateway-vpc-attachment
• modify-volume
• modify-volume-attribute
• modify-vpc-attribute
• modify-vpc-endpoint
• modify-vpc-endpoint-connection-notification
• modify-vpc-endpoint-service-configuration
• modify-vpc-endpoint-service-permissions
• modify-vpc-peering-connection-options
• modify-vpc-tenancy
• modify-vpn-connection
• modify-vpn-tunnel-certificate
• modify-vpn-tunnel-options
• monitor-instances
• move-address-to-vpc
• provision-byoip-cidr
• purchase-host-reservation
• purchase-reserved-instances-offering
• purchase-scheduled-instances
• reboot-instances
• register-image
• reject-transit-gateway-vpc-attachment
• reject-vpc-endpoint-connections
• reject-vpc-peering-connection
• release-address
• release-hosts
• replace-iam-instance-profile-association
• replace-network-acl-association
• replace-network-acl-entry
• replace-route
• replace-route-table-association
• replace-transit-gateway-route
• report-instance-status
• request-spot-fleet
• request-spot-instances
• reset-ebs-default-kms-key-id
• reset-fpga-image-attribute
• reset-image-attribute
• reset-instance-attribute
• reset-network-interface-attribute
• reset-snapshot-attribute
• restore-address-to-classic
• revoke-client-vpn-ingress
• revoke-security-group-egress
• revoke-security-group-ingress
• run-instances
• run-scheduled-instances
• search-transit-gateway-routes
• send-diagnostic-interrupt
• start-instances
• stop-instances
• terminate-client-vpn-connections
• terminate-instances
• unassign-ipv6-addresses
• unassign-private-ip-addresses
• unmonitor-instances
• update-security-group-rule-descriptions-egress
• update-security-group-rule-descriptions-ingress
• withdraw-byoip-cidr
```

コマンド多すぎてやばい・・・ :sweat: 
ついでに、 `@aws ec2 describe-instance --region ap-northeast-1` してみたら、結構表示が細かい情報まで表示される仕組みのようで、
「Show more」も出るしで、インスタンスがたくさんあると大変そうでした・・・ :sweat_drops: もう少し見やすい表示にならないかなー :thinking: 
![スクリーンショット 2019-11-28 15.57.35.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/14268/4c7b3022-3dee-63c6-074e-0d968bfa1f21.png)

# まとめ
まあまだ導入したばかりなので、もっと使い倒してみます。その流れで NoOpsが加速するといいですね :thumbsup: 
lambda使えたりとか、サポートへ質問できたりもするみたいなので、便利そうですね。
サポートへ質問できるところはSlackの `/feedback` と同じようにしてたくさん意見もらえるようにしたのかなー