Berkshelf

Berkshelf is a tool to manage Chef cookbooks and their dependencies.

If you define a cookbook to be used for the definition file, you can eliminate depedencies automatically from the repository.

[vagrant@localhost test]$ gem install mixlib-archive -v 0.4.20
[vagrant@localhost test]$ gem install mixlib-config -v 2.2.18

[vagrant@localhost test]$ gem install berkshelf
Fetching: fuzzyurl-0.9.0.gem (100%)
Successfully installed fuzzyurl-0.9.0
Fetching: chef-config-15.1.36.gem (100%)
Successfully installed chef-config-15.1.36
Fetching: builder-3.2.3.gem (100%)
Successfully installed builder-3.2.3
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: gssapi-1.3.0.gem (100%)
Successfully installed gssapi-1.3.0
Fetching: gyoku-1.3.1.gem (100%)
Successfully installed gyoku-1.3.1
Fetching: httpclient-2.8.3.gem (100%)
Successfully installed httpclient-2.8.3
Fetching: little-plugger-1.1.4.gem (100%)
Successfully installed little-plugger-1.1.4
Fetching: logging-2.2.2.gem (100%)
Successfully installed logging-2.2.2
Fetching: nori-2.6.0.gem (100%)
Successfully installed nori-2.6.0
Fetching: rubyntlm-0.6.2.gem (100%)
Successfully installed rubyntlm-0.6.2
Fetching: winrm-2.3.2.gem (100%)
Successfully installed winrm-2.3.2
Fetching: rubyzip-1.2.3.gem (100%)
Successfully installed rubyzip-1.2.3
Fetching: winrm-fs-1.3.2.gem (100%)
Successfully installed winrm-fs-1.3.2
Fetching: train-core-2.1.13.gem (100%)
ERROR: Error installing berkshelf:
There are no versions of train-core (>= 2.0.12, ~> 2.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you’re looking for?
train-core requires Ruby version >= 2.4. The current ruby version is 2.3.0.

なにいいいいいいいいいいいいいいいいいいいい

create zip directory with zip command

$ zip -r filename directoryname

[vagrant@localhost test]$ ls
test
[vagrant@localhost test]$ zip -r sample test
-bash: zip: コマンドが見つかりません

あれ、zipが入っていない?!

[vagrant@localhost test]$ sudo yum install zip
インストール:
zip.x86_64 0:3.0-1.el6_7.1

完了しました!

zipファイルを作ります。
[vagrant@localhost test]$ zip -r sample.zip test
adding: test/ (stored 0%)
[vagrant@localhost test]$ ls
sample.zip test

お!?

$ zip -e -v
->オプション
-e: –encrypt: 暗号化する
-v: –verbose: 動作中のメッセージを詳しくする

ああああああああああああああああああ、
まだまだまだまだあるううううううううううううううううううう

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"}
			}
		}
	}
}

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