vagrant ssh-config

VagrantfileがあるディレクトリでOpenSSHの設定を行う。

>vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/hoge/MyVagrant/Cent/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

ん?なんじゃこりゃ。

取得できるファイルをssh.configに書き込み。
>vagrant ssh-config > ssh.config

>scp -F ssh.config vagrant@default:package-lock.json ./
package-lock.json 100% 11KB 11.5KB/s 00:00

まじこれ?
要するにvagrantにscp接続できたってこと?

うおおおおおおおおおおおお、全然追いつける気がしない。

OpenSSH

OpenSSH(Open Secure Shell) is software for using the SSH protocol, including an SSH server and an SSH client. OpenSSH is developed by the OpenBSD project and released under the BSD license. There are several other implementations of SSH, including the original SSH implementation SSH Tectia, but as of 2008, OpenSSH is the most used SSH implementation in the world.

Windows 10に OpenSSHが正式に組み込まれて使用できるとのこと。
アプリと機能を開きます。

オプション機能の管理→OpenSSHクライアント

あ、既にインストールされていますね。

続いて、Windows PowerShellを開きます。
> ssh localhost
ssh: connect to host localhost port 22: Connection refused

> New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow – DisplayName SS
H
New-NetFirewallRule : 引数 ‘-‘ を受け入れる位置指定パラメーターが見つかりません。
発生場所 行:1 文字:1
+ New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -A …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-NetFirewallRule]、ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,New-NetFirewallRule

> New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH

New-NetFirewallRule : アクセスが拒否されました。
発生場所 行:1 文字:1
+ New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -A …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (MSFT_NetFirewallRule:root/standardcimv2/MSFT_NetFirewallRule) [New-Ne
tFirewallRule], CimException
+ FullyQualifiedErrorId : Windows System Error 5,New-NetFirewallRule

アクセスが拒否されました。
なんでやー

SCP command

The “SCP” command is an abbreviation of “Secure Copy”, and it uses ssh to encrypt the communication between the remote host and the local host, and then copy and send the file.

Hoot24

Hoot24とは?
->「HOOT24」とはサイトロック社とクラメソで提供する、24時間365日AWS環境(EC2, ELB, RDS)の”有人”監視サービス

1)「AWS環境の監視体制」をご提供:お客様側で監視サーバーの準備が不要。必要なものは最小限のIAM権限とIPアクセス許可のみ
2)「通知手段の選択」をご提供:有人監視であることにより、「電話連絡」という手段が選択できる
3)「自動障害対応」をご提供:監視項目ごとに対応を決めることができる。インスタンス再起動などの個別アクションも指定可能
4)「監視設定の支援」をご提供:弊社オペレーションチームのサポートにより、容易に監視設定ができる

ref: https://dev.classmethod.jp/etc/cm-hoot24-intro/

有人の電話連絡といっても、まぁ、システムの稼働状況によるでしょう。
休日や深夜帯にユーザーが使用しなければ、そこまで優先度は高くないですが、深夜や営業時間外でも稼働が必須の場合は、重宝されそうですね。
クラメソの監視とのことですが、他のサービスの対応を見ていると、なんとなく、これも良さそうには見えますね。

php zip

インストール済みを確認します。
[vagrant@localhost ~]$ yum list installed | grep zip
bzip2.x86_64 1.0.5-7.el6_0 @anaconda-CentOS-201605220104.x86_64/6.8
bzip2-devel.x86_64 1.0.5-7.el6_0 @base
bzip2-libs.x86_64 1.0.5-7.el6_0 @anaconda-CentOS-201605220104.x86_64/6.8
gzip.x86_64 1.3.12-24.el6 @base
libzip5.x86_64 1.5.2-1.el6.remi @remi-safe
php-pecl-zip.x86_64 1.15.3-1.el6.remi.7.1 @remi-php71
unzip.x86_64 6.0-5.el6 @base

ん?
php-pecl-zipか??

[vagrant@localhost ~]$ php –ri zip

zip

Zip => enabled
Zip version => 1.15.3
Libzip headers version => 1.5.1
Libzip library version => 1.5.2

はいってるっぽいですね。
これのこと?

php70-zipとphp-pecl-zipの違いが分からんぞ。

SFTP(SSH File Transfer Protocol)とは

What is SFTP?
A protocol that encrypts information transferred by FTP using “SSH(Secure Shell)”.

SSH?
A protocol that encrypts all information communicated when operating a remote server from a terminal.

“SSH” can be used with “OpenSSH” software etc. It is installed by default in Linux. Windows can also be used with “Cygwin”, “WinSCP”, or “Git Bash” bundled with Git. In any case, an environment where “SSH” can be used is required.

あれ、なんや、基本っぽいな。

古いCloudFront APIバージョンの廃止

古いCloudFront APIバージョンの廃止があるらしい。

Full list of versions to be deprecated on June 6, 2019:
2008-06-30, 2009-04-02, 2009-09-09, 2009-12-01, 2010-03-01, 2010-05-01, 2010-06-01, 2010-07-15, 2010-08-01,  2010-11-01, 2012-03-15, 2012-05-05,  2012-07-01, 2013-05-12, 2013-08-26, 2013-09-27, 2013-11-11, 2013-11-22, 2014-01-31, 2014-05-31, 2014-08-31, 2014-10-21,  2014-11-06, 2015-04-17, 2015-07-27, 2015-09-17, 2015-12-22

For more information regarding this deprecation and the actions you should take, refer to our Developer Forum post here:
https://forums.aws.amazon.com/ann.jspa?annID=6697

で、CloudFrontを使っているから、って調べていたんだが、CloudFrontとCloudFront APIは違うんだね。すげー勘違いしていた。。。CloudFront APIは、その名の通り、CloudFrontにAPI接続する仕様。

<script src="https://sdk.amazonaws.com/js/aws-sdk-2.316.0.min.js"></script>
<script>
var config = new AWS.Config({
	accessKeyId : xxxxxxxxxxxxxxx,
	secretAccessKey : xxxxxxxxxxxxxxx,
	region : xxxxxxxxxxxx
});
cloudfront = new AWS.CloudFront(config)
</script>

うーん、なんだかなー

CloudFormationを書いていこう

{
	"AWSTemplateFormatVersion" : "2010-09-09",

	"Description" : "Test template.",

	"Resources" : {

		"VPC" : {
			"Type" : "AWS::EC2::VPC",
			"Properties" : {
				"CidrBlock" : "10.0.0.0/16",
				"Tags" : [{"Key": "Application", "Value" : {"Ref" : "AWS::StackId"} }]
			}
		},

		"PublicSubnet" : {
			"Type" : "AWS::EC2::Subnet",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC" },
				"CidrBlock" : "10.0.0.0/24",
				"Tags" : [{"Key" : "Application", "Value" : { "Ref" : "AWS::StackId"}}]
			}
		},

		"PrivateSubnet" : {
			"Type" : "AWS::EC2::Subnet",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC"},
				"CidrBlock" : "10.0.1.0/24",
				"Tags" : [{"Key": "Application", "Value" : {"Ref": "AWS::StackId"}}]
			}
		},

		"InternetGateway" : {
			"Type" : "AWS::EC2::InternetGateway",
			"Properties" : {
				"Tags" : [ {"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"}}]
			}
		},

		"AttachGateway" : {
			"Type" : "AWS::EC2::VPCGatewayAttachment",
			"Properties" : {
				"VpcId" : {"Ref": "VPC"},
				"InternetGatewayId" : {"Ref" : "InternetGateway"}
			}
		},

		"RouteTable" : {
			"Type" : "AWS::EC2::RouteTable",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC"},
				"Tags" : [{"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"}}]
			}
		},

		"Route" : {
			"Type" : "AWS::EC2::Route",
			"DependsOn" : "AttachGateway",
			"Properties" : {
				"RouteTableId" : {"Ref" : "RouteTable"},
				"DestinationCidrBlock": "0.0.0.0/0",
				"GatewayId" : {"Ref" : "InternetGateway"}
			}
		},

		"SubnetRouteTableAssociation" : {
			"Type" : "AWS::EC2::SubnetRouteTableAssociation",
			"Properties" : {
				"SubnetId" : {"Ref" : "PublicSubnet"},
				"RouteTableId" : {"Ref" : "RouteTable"}
			}
		},

		"NetworkAcl" : {
			"Type" : "AWS::EC2::NetworkAcl",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC"},
				"Tags" : [ {"Key" : "Application", "Value": {"Ref" : "AWS::StackId"}}]
			}
		},

		"SubnetNetworkAclAssociation" : {
			"Type" : "AWS::EC2::SubnetNetworkAclAssociation",
			"Properties" : {
				"SubnetId" : {"Ref" : "PublicSubnet" },
				"NetworkAclId" : {"Ref" : "NetworkAcl"}
			}
		}
	}
}

なんじゃこりゃーーーーーーーーーーーー
エンジニアってどうやってモチベーション保ってんだろう。。
まったく、意味が分からんよ。

CentOSにaws cliをインストールする

公式を参考にします。
LinuxにAWS CLIをインストールする

[vagrant@localhost ~]$ aws –version
-bash: aws: コマンドが見つかりません
[vagrant@localhost ~]$ pip3 –version
pip 18.0 from /home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pip (python 3.5)
[vagrant@localhost ~]$ python3 –version
Python 3.5.2

pip3は入ってます。インストールしていきます。

[vagrant@localhost ~]$ pip3 install awscli –upgrade –user
Installing collected packages: botocore, s3transfer, awscli
Found existing installation: botocore 1.12.86
Uninstalling botocore-1.12.86:
Successfully uninstalled botocore-1.12.86
Found existing installation: s3transfer 0.1.13
Uninstalling s3transfer-0.1.13:
Successfully uninstalled s3transfer-0.1.13
Found existing installation: awscli 1.16.96
Uninstalling awscli-1.16.96:
Successfully uninstalled awscli-1.16.96
Successfully installed awscli-1.16.198 botocore-1.12.188 s3transfer-0.2.1

[vagrant@localhost ~]$ aws –version
-bash: aws: コマンドが見つかりません
successfully installedとなっているのに、なぜ?

[vagrant@localhost ~]$ which aws
/usr/bin/which: no aws in (/home/vagrant/.pyenv/plugins/pyenv-virtualenv/shims:/home/vagrant/.pyenv/shims:/home/vagrant/.pyenv/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/home/vagrant/.nvm/versions/node/v10.7.0/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin)
[vagrant@localhost ~]$ which python
~/.pyenv/shims/python

なんでだろー、わからん。。

AWS CloudFormation

AWS CloudFormation is a service that help you model and set up Amazon Web Services resources. You can spend less time managing resources and focus more on the applications that run on AWS. If you create a template that describes all of the AWS resources that you wan to use, such as Amazon EC2 instances or Amazon RDS DB instances, AWS CloudFormation will be responsible for provisioning and configuring these resources on your behalf. You don’t have to create and design individual AWS resources and think about their dependencies. AWS CloudFormation handles everything.

{
	"AWSTempleteFormatVersion": "2010-09-09",

	"Description": "CloudFormation tutorial",

	"Resources" : {
	  "InstanceSecurityGroup": {
	     "Type": "AWS::EC2::SecurityGroup",
	     "Properties": {
	         "GroupDescription" : "Enable HTTP Access on the configured port",
	         "securityGroupIngress" : [
	            {"IpProtocol": "tcp", "FromPort":"80", "ToPort":"80","CidrIp":"0.0.0.0/0"}
	         ]
	     }
	  }
	}
}