aws-ec2 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/aws_ec2/create.rb +37 -20
- data/lib/aws_ec2/scripts/cloudwatch/configure.sh +1 -1
- data/lib/aws_ec2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 133b3adbf26d2f3f9e02e7aa2f97dfc3e899cff09e3c7195dd2fb3670c35f1d2
|
4
|
+
data.tar.gz: d16e6f935714439ae350822441e84f7192ba14837d2c88df42517d77e49e2e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cce36e27bb90ac8e05c1f29ac209e6d6804510d0074da10cde099972f90f67af2cf6660a276b9f405f71284f1e16d1f5d1e4880ff0ce7cb5e9cbe53b99986b9
|
7
|
+
data.tar.gz: c1331df63412bfc9ecf623912257c3a25615e3e631edccc30f2a22daf5c925f18175b5dc4a0246a0e93a924d296e5fd5ef3d99242f1a950f8b224245f4dd8d92
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [1.4.3]
|
7
|
+
- fix get_region when aws-ec2 called from an ec2 instance
|
8
|
+
|
6
9
|
## [1.4.2]
|
7
10
|
- fix cloudwatch for ubuntu
|
8
11
|
|
data/Gemfile.lock
CHANGED
data/lib/aws_ec2/create.rb
CHANGED
@@ -29,26 +29,6 @@ module AwsEc2
|
|
29
29
|
display_cloudwatch_info(instance_id)
|
30
30
|
end
|
31
31
|
|
32
|
-
def display_cloudwatch_info(instance_id)
|
33
|
-
return unless @options[:cloudwatch]
|
34
|
-
|
35
|
-
region = `aws configure get region`.strip
|
36
|
-
region = 'us-east-1' if region == ''
|
37
|
-
url = "https://#{region}.console.aws.amazon.com/cloudwatch/home?region=#{region}#logEventViewer:group=ec2;stream=#{instance_id}/var/log/cloud-init-output.log"
|
38
|
-
puts "To view instance's cloudwatch logs visit:"
|
39
|
-
puts " #{url}"
|
40
|
-
puts "Note: It takes a little time for the instance to launch and report logs."
|
41
|
-
add_to_clipboard(url)
|
42
|
-
end
|
43
|
-
|
44
|
-
def add_to_clipboard(text)
|
45
|
-
return unless RUBY_PLATFORM =~ /darwin/
|
46
|
-
return unless system("type pbcopy > /dev/null")
|
47
|
-
|
48
|
-
system(%[echo "#{text}" | pbcopy])
|
49
|
-
puts "Pro tip: The CloudWatch Console Link has been added to your copy-and-paste clipboard."
|
50
|
-
end
|
51
|
-
|
52
32
|
def run_instances(params)
|
53
33
|
ec2.run_instances(params)
|
54
34
|
rescue Aws::EC2::Errors::ServiceError => e
|
@@ -107,6 +87,43 @@ module AwsEc2
|
|
107
87
|
exit
|
108
88
|
end
|
109
89
|
|
90
|
+
def display_cloudwatch_info(instance_id)
|
91
|
+
return unless @options[:cloudwatch]
|
92
|
+
|
93
|
+
region = get_region
|
94
|
+
url = "https://#{region}.console.aws.amazon.com/cloudwatch/home?region=#{region}#logEventViewer:group=ec2;stream=#{instance_id}/var/log/cloud-init-output.log"
|
95
|
+
puts "To view instance's cloudwatch logs visit:"
|
96
|
+
puts " #{url}"
|
97
|
+
puts "Note: It takes a little time for the instance to launch and report logs."
|
98
|
+
add_to_clipboard(url)
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_to_clipboard(text)
|
102
|
+
return unless RUBY_PLATFORM =~ /darwin/
|
103
|
+
return unless system("type pbcopy > /dev/null")
|
104
|
+
|
105
|
+
system(%[echo "#{text}" | pbcopy])
|
106
|
+
puts "Pro tip: The CloudWatch Console Link has been added to your copy-and-paste clipboard."
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_region
|
110
|
+
# Highest precedence is the setting in ~/.aws/config and AWS_PROFILE used
|
111
|
+
aws_found = system("type aws > /dev/null")
|
112
|
+
if aws_found
|
113
|
+
region = `aws configure get region`.strip
|
114
|
+
return region
|
115
|
+
end
|
116
|
+
|
117
|
+
# Assumes instace being launched in the same region as the calling ec2 instance
|
118
|
+
curl_found = system("type curl > /dev/null")
|
119
|
+
if curl_found
|
120
|
+
region = `curl --connect-timeout 3 -s 169.254.169.254/latest/meta-data/placement/availability-zone | sed s'/.$//'`
|
121
|
+
return region unless region == ''
|
122
|
+
end
|
123
|
+
|
124
|
+
return 'us-east-1' # fallback default
|
125
|
+
end
|
126
|
+
|
110
127
|
def pretty_display(data)
|
111
128
|
data = data.deep_stringify_keys
|
112
129
|
|
@@ -79,6 +79,6 @@ datetime_format =
|
|
79
79
|
EOF
|
80
80
|
|
81
81
|
if [ -f /etc/awslogs/awscli.conf ]; then
|
82
|
-
region=$(curl 169.254.169.254/latest/meta-data/placement/availability-zone | sed s'/.$//')
|
82
|
+
region=$(curl -s 169.254.169.254/latest/meta-data/placement/availability-zone | sed s'/.$//')
|
83
83
|
sed -i -e "s/region = us-east-1/region = $region/g" /etc/awslogs/awscli.conf
|
84
84
|
fi
|
data/lib/aws_ec2/version.rb
CHANGED