2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShellでAWS

Last updated at Posted at 2015-12-08

#事前準備
##必要環境
・Windows XP以降
・PowerShell 2.0以降

##実施環境
・Windows 8.1
・PowerShell 4.0

##AWS Tools for Windows PowerShellインストール
以下よりインストーラをダウンロードし、インストールします。
http://aws.amazon.com/jp/powershell/

#初期設定
##モジュールのインポート
インストール完了後、モジュールをインポートする。

get-moduleコマンドlistavailableオプションでインポート可能なモジュールからAWSPowerShellを確認する。

PS C:\> get-module -ListAvailable
    ディレクトリ: C:\Program Files (x86)\AWS Tools\PowerShell
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     3.1.20.0   AWSPowerShell                       {Add-ASInstances, Add-ASLoadBalancer, Complete-ASLifecycle.

AWSPowerShellをインポートする。

PS C:\> Import-Module AWSPowerShell

インポート完了。

PS C:\> get-module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     3.1.20.0   AWSPowerShell                       {Add-ASAAttachmentsToSet, Add-ASACommunicationToCase, Add-.


このままではPowerShellを立ち上げるたびに、モジュールをインポートする必要があるので、
面倒な場合はプロファイルに「Import-Module AWSPowerShell」と記載しておくとよろしいかと。

##認証情報とデフォルトリージョンの設定


PS C:\> Initialize-AWSDefaults
Credentials
Please enter your AWS Access and Secret Keys
AWS Access Key: ********************
AWS Secret Key: ****************************************

Specify region
Please choose one of the following regions to use or specify one by system name
[] <Specify a different region>  [] us-east-1  [] us-west-1  [] us-west-2  [] eu-west-1  [] eu-central-1
[] ap-northeast-1[] ap-southeast-1  [] ap-southeast-2  [] sa-east-1  [] us-gov-west-1  [] cn-north-1  [?] ヘルプ
(既定値は "<Specify a different region>"):ap-northeast-1
Default credentials and/or region have been stored to credentials profile 'default' and set active for this shell.

#バージョン確認
##PowerShell


PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.3.9600.17400
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

##PowerShell tools
sdk for .netのバージョンも一緒に確認できます。


PS C:\> Get-AWSPowerShellVersion

AWS Tools for Windows PowerShell
Version 3.1.20.0
Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Version 3.1.3.0
Copyright 2009-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Release notes: https://aws.amazon.com/releasenotes/PowerShell

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]

#S3バケットの作成と削除

##Sakusei

PS C:\Users\m> New-S3Bucket -BucketName samplepsbucket

CreationDate                                                BucketName
------------                                                ----------
2015/12/08 15:40:03                                         samplepsbucket


PS C:\> Get-S3Bucket

CreationDate                                                BucketName
------------                                                ----------
2015/12/09 0:39:53                                          samplepsbucket

##Sakujo

PS C:\> Remove-S3Bucket -BucketName samplepsbucket

確認
この操作を実行しますか?
対象 "samplepsbucket" に対して操作 "Remove-S3Bucket (DeleteBucket)" を実行しています。
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): Y

ResponseMetadata                        ContentLength                           HttpStatusCode
----------------                        -------------                           --------------
Amazon.Runtime.ResponseMetadata         -1                                      NoContent


PS C:\> Get-S3Bucket

CreationDate                                                BucketName
------------                                                ----------


Dekita!
Oshimai!

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?