fog-aws 3.5.2 → 3.6.6
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/.gitignore +1 -0
- data/CHANGELOG.md +82 -7
- data/LICENSE.md +1 -1
- data/README.md +39 -6
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fog-aws.gemspec +3 -3
- data/lib/fog/aws.rb +6 -1
- data/lib/fog/aws/credential_fetcher.rb +27 -4
- data/lib/fog/aws/elasticache.rb +4 -2
- data/lib/fog/aws/elb.rb +1 -1
- data/lib/fog/aws/elbv2.rb +72 -0
- data/lib/fog/aws/kinesis.rb +23 -15
- data/lib/fog/aws/models/compute/flavors.rb +1556 -134
- data/lib/fog/aws/models/compute/server.rb +4 -2
- data/lib/fog/aws/models/compute/servers.rb +2 -0
- data/lib/fog/aws/models/compute/snapshot.rb +7 -6
- data/lib/fog/aws/models/compute/vpc.rb +8 -2
- data/lib/fog/aws/models/storage/directory.rb +0 -1
- data/lib/fog/aws/models/storage/file.rb +3 -0
- data/lib/fog/aws/parsers/compute/create_snapshot.rb +1 -1
- data/lib/fog/aws/parsers/compute/create_subnet.rb +33 -6
- data/lib/fog/aws/parsers/compute/describe_subnets.rb +33 -6
- data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +1 -1
- data/lib/fog/aws/parsers/dns/get_hosted_zone.rb +3 -3
- data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +3 -1
- data/lib/fog/aws/parsers/elbv2/create_load_balancer.rb +88 -0
- data/lib/fog/aws/parsers/elbv2/describe_listeners.rb +110 -0
- data/lib/fog/aws/parsers/elbv2/describe_load_balancers.rb +88 -0
- data/lib/fog/aws/parsers/elbv2/describe_tags.rb +53 -0
- data/lib/fog/aws/parsers/elbv2/empty.rb +10 -0
- data/lib/fog/aws/parsers/storage/get_object_tagging.rb +33 -0
- data/lib/fog/aws/parsers/sts/assume_role_with_web_identity.rb +1 -1
- data/lib/fog/aws/requests/compute/create_vpc.rb +2 -2
- data/lib/fog/aws/requests/compute/run_instances.rb +20 -0
- data/lib/fog/aws/requests/compute/stop_instances.rb +11 -3
- data/lib/fog/aws/requests/elbv2/add_tags.rb +45 -0
- data/lib/fog/aws/requests/elbv2/create_load_balancer.rb +160 -0
- data/lib/fog/aws/requests/elbv2/describe_listeners.rb +38 -0
- data/lib/fog/aws/requests/elbv2/describe_load_balancers.rb +100 -0
- data/lib/fog/aws/requests/elbv2/describe_tags.rb +50 -0
- data/lib/fog/aws/requests/elbv2/remove_tags.rb +45 -0
- data/lib/fog/aws/requests/storage/get_object_tagging.rb +41 -0
- data/lib/fog/aws/requests/storage/put_object_tagging.rb +42 -0
- data/lib/fog/aws/requests/sts/assume_role_with_web_identity.rb +7 -6
- data/lib/fog/aws/storage.rb +2 -0
- data/lib/fog/aws/version.rb +1 -1
- data/tests/credentials_tests.rb +20 -0
- data/tests/parsers/elbv2/create_load_balancer_tests.rb +48 -0
- data/tests/parsers/elbv2/describe_listeners_tests.rb +76 -0
- data/tests/parsers/elbv2/describe_load_balancers_tests.rb +54 -0
- data/tests/parsers/elbv2/describe_tags_tests.rb +35 -0
- data/tests/requests/compute/vpc_tests.rb +6 -0
- data/tests/requests/elbv2/helper.rb +66 -0
- data/tests/requests/elbv2/load_balancer_tests.rb +50 -0
- metadata +32 -9
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/describe_listeners'
|
6
|
+
|
7
|
+
# Describe all or specified load balancers
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * 'LoadBalancerArn'<~String> - The Amazon Resource Name (ARN) of the load balancer
|
11
|
+
# * options<~Hash>
|
12
|
+
# * 'Marker'<String> - Indicates where to begin in your list of load balancers
|
13
|
+
#
|
14
|
+
# ==== Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'ResponseMetadata'<~Hash>:
|
18
|
+
# * 'RequestId'<~String> - Id of request
|
19
|
+
# * 'DescribeListenersResult'<~Hash>:
|
20
|
+
# * 'Listeners'<~Array>
|
21
|
+
# * 'LoadBalancerArn'<~String> - The Amazon Resource Name (ARN) of the load balancer
|
22
|
+
# * 'Protocol'<~String> - The protocol for connections from clients to the load balancer
|
23
|
+
# * 'Port'<~String> - The port on which the load balancer is listening
|
24
|
+
# * 'DefaultActions'<~Array> - The default actions for the listener
|
25
|
+
# * 'Type'<~String> - The type of action
|
26
|
+
# * 'TargetGroupArn'<~String> - The Amazon Resource Name (ARN) of the target group. Specify only when Type is forward
|
27
|
+
# * 'NextMarker'<~String> - Marker to specify for next page
|
28
|
+
def describe_listeners(load_balancer_arn, options = {})
|
29
|
+
request({
|
30
|
+
'Action' => 'DescribeListeners',
|
31
|
+
'LoadBalancerArn' => load_balancer_arn,
|
32
|
+
:parser => Fog::Parsers::AWS::ELBV2::DescribeListeners.new
|
33
|
+
}.merge!(options))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/describe_load_balancers'
|
6
|
+
|
7
|
+
# Describe all or specified load balancers
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * options<~Hash>
|
11
|
+
# * 'LoadBalancerNames'<~Array> - List of load balancer names to describe, defaults to all
|
12
|
+
# * 'Marker'<String> - Indicates where to begin in your list of load balancers
|
13
|
+
#
|
14
|
+
# ==== Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'ResponseMetadata'<~Hash>:
|
18
|
+
# * 'RequestId'<~String> - Id of request
|
19
|
+
# * 'DescribeLoadBalancersResult'<~Hash>:
|
20
|
+
# * 'LoadBalancers'<~Array>
|
21
|
+
# * 'AvailabilityZones'<~Array>:
|
22
|
+
# * 'SubnetId'<~String> - ID of the subnet
|
23
|
+
# * 'ZoneName'<~String> - Name of the Availability Zone
|
24
|
+
# * 'LoadBalancerAddresses'<~Array>:
|
25
|
+
# * 'IpAddress'<~String> - IP address
|
26
|
+
# * 'AllocationId'<~String> - ID of the AWS allocation
|
27
|
+
# * 'CanonicalHostedZoneName'<~String> - name of the Route 53 hosted zone associated with the load balancer
|
28
|
+
# * 'CanonicalHostedZoneNameID'<~String> - ID of the Route 53 hosted zone associated with the load balancer
|
29
|
+
# * 'CreatedTime'<~Time> - time load balancer was created
|
30
|
+
# * 'DNSName'<~String> - external DNS name of load balancer
|
31
|
+
# * 'LoadBalancerName'<~String> - name of load balancer
|
32
|
+
# * 'SecurityGroups'<~Array> - array of security group id
|
33
|
+
# * 'NextMarker'<~String> - Marker to specify for next page
|
34
|
+
def describe_load_balancers(options = {})
|
35
|
+
unless options.is_a?(Hash)
|
36
|
+
Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
|
37
|
+
options = { 'LoadBalancerNames' => [options].flatten }
|
38
|
+
end
|
39
|
+
|
40
|
+
if names = options.delete('LoadBalancerNames')
|
41
|
+
options.update(Fog::AWS.indexed_param('LoadBalancerNames.member', [*names]))
|
42
|
+
end
|
43
|
+
|
44
|
+
request({
|
45
|
+
'Action' => 'DescribeLoadBalancers',
|
46
|
+
:parser => Fog::Parsers::AWS::ELBV2::DescribeLoadBalancers.new
|
47
|
+
}.merge!(options))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Mock
|
52
|
+
def describe_load_balancers(options = {})
|
53
|
+
unless options.is_a?(Hash)
|
54
|
+
Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
|
55
|
+
options = { 'LoadBalancerNames' => [options].flatten }
|
56
|
+
end
|
57
|
+
|
58
|
+
lb_names = options['LoadBalancerNames'] || []
|
59
|
+
|
60
|
+
lb_names = [*lb_names]
|
61
|
+
load_balancers = if lb_names.any?
|
62
|
+
lb_names.map do |lb_name|
|
63
|
+
lb = self.data[:load_balancers_v2].find { |name, data| name == lb_name }
|
64
|
+
raise Fog::AWS::ELBV2::NotFound unless lb
|
65
|
+
lb[1].dup
|
66
|
+
end.compact
|
67
|
+
else
|
68
|
+
self.data[:load_balancers_v2].map { |lb, values| values.dup }
|
69
|
+
end
|
70
|
+
|
71
|
+
marker = options.fetch('Marker', 0).to_i
|
72
|
+
if load_balancers.count - marker > 400
|
73
|
+
next_marker = marker + 400
|
74
|
+
load_balancers = load_balancers[marker...next_marker]
|
75
|
+
else
|
76
|
+
next_marker = nil
|
77
|
+
end
|
78
|
+
|
79
|
+
response = Excon::Response.new
|
80
|
+
response.status = 200
|
81
|
+
|
82
|
+
response.body = {
|
83
|
+
'ResponseMetadata' => {
|
84
|
+
'RequestId' => Fog::AWS::Mock.request_id
|
85
|
+
},
|
86
|
+
'DescribeLoadBalancersResult' => {
|
87
|
+
'LoadBalancers' => load_balancers
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
if next_marker
|
92
|
+
response.body['DescribeLoadBalancersResult']['NextMarker'] = next_marker.to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
response
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/describe_tags'
|
6
|
+
|
7
|
+
# returns a Hash of tags for a load balancer
|
8
|
+
# http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_DescribeTags.html
|
9
|
+
# ==== Parameters
|
10
|
+
# * resource_arns <~Array> - ARN(s) of the ELB instance whose tags are to be retrieved
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
def describe_tags(resource_arns)
|
15
|
+
request({
|
16
|
+
'Action' => 'DescribeTags',
|
17
|
+
:parser => Fog::Parsers::AWS::ELBV2::DescribeTags.new
|
18
|
+
}.merge!(Fog::AWS.indexed_param('ResourceArns.member.%d', [*resource_arns]))
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Mock
|
24
|
+
def describe_tags(resource_arns)
|
25
|
+
response = Excon::Response.new
|
26
|
+
resource_arns = [*resource_arns]
|
27
|
+
|
28
|
+
tag_describtions = resource_arns.map do |resource_arn|
|
29
|
+
if self.data[:load_balancers_v2][resource_arn]
|
30
|
+
{
|
31
|
+
"Tags"=>self.data[:tags][resource_arn],
|
32
|
+
"ResourceArn"=>resource_arn
|
33
|
+
}
|
34
|
+
else
|
35
|
+
raise Fog::AWS::ELBV2::NotFound.new("Elastic load balancer #{resource_arns} not found")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
response.status = 200
|
40
|
+
response.body = {
|
41
|
+
"ResponseMetadata"=>{"RequestId"=> Fog::AWS::Mock.request_id },
|
42
|
+
"DescribeTagsResult"=>{"TagDescriptions"=> tag_describtions}
|
43
|
+
}
|
44
|
+
|
45
|
+
response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/empty'
|
6
|
+
|
7
|
+
# removes tags from an elastic load balancer instance
|
8
|
+
# http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_RemoveTags.html
|
9
|
+
# ==== Parameters
|
10
|
+
# * resource_arn <~String> - ARN of the ELB instance whose tags are to be retrieved
|
11
|
+
# * keys <~Array> A list of String keys for the tags to remove
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
def remove_tags(resource_arn, keys)
|
16
|
+
request(
|
17
|
+
{ 'Action' => 'RemoveTags',
|
18
|
+
'ResourceArns.member.1' => resource_arn,
|
19
|
+
:parser => Fog::Parsers::AWS::ELBV2::Empty.new,
|
20
|
+
}.merge(Fog::AWS.indexed_param('TagKeys.member.%d', keys))
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
|
28
|
+
def remove_tags(resource_arn, keys)
|
29
|
+
response = Excon::Response.new
|
30
|
+
if self.data[:load_balancers_v2][resource_arn]
|
31
|
+
keys.each {|key| self.data[:tags][resource_arn].delete key}
|
32
|
+
response.status = 200
|
33
|
+
response.body = {
|
34
|
+
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
|
35
|
+
}
|
36
|
+
response
|
37
|
+
else
|
38
|
+
raise Fog::AWS::ELBV2::NotFound.new("Elastic load balancer #{resource_arn} not found")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class Storage
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/storage/get_object_tagging'
|
6
|
+
|
7
|
+
# Get tags for an S3 object
|
8
|
+
#
|
9
|
+
# @param bucket_name [String] Name of bucket to read from
|
10
|
+
# @param object_name [String] Name of object to get tags for
|
11
|
+
#
|
12
|
+
# @return [Excon::Response] response:
|
13
|
+
# * body [Hash]:
|
14
|
+
# * ObjectTagging [Hash]:
|
15
|
+
# * Key [String] - tag key
|
16
|
+
# * Value [String] - tag value
|
17
|
+
# @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html
|
18
|
+
|
19
|
+
def get_object_tagging(bucket_name, object_name)
|
20
|
+
unless bucket_name
|
21
|
+
raise ArgumentError.new('bucket_name is required')
|
22
|
+
end
|
23
|
+
unless object_name
|
24
|
+
raise ArgumentError.new('object_name is required')
|
25
|
+
end
|
26
|
+
|
27
|
+
request({
|
28
|
+
:expects => 200,
|
29
|
+
:headers => {},
|
30
|
+
:bucket_name => bucket_name,
|
31
|
+
:object_name => object_name,
|
32
|
+
:idempotent => true,
|
33
|
+
:method => 'GET',
|
34
|
+
:parser => Fog::Parsers::AWS::Storage::GetObjectTagging.new,
|
35
|
+
:query => {'tagging' => nil}
|
36
|
+
})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class Storage
|
4
|
+
class Real
|
5
|
+
# Change tag set for an S3 object
|
6
|
+
#
|
7
|
+
# @param bucket_name [String] Name of bucket to modify object in
|
8
|
+
# @param object_name [String] Name of object to modify
|
9
|
+
#
|
10
|
+
# @param tags [Hash]:
|
11
|
+
# * Key [String]: tag key
|
12
|
+
# * Value [String]: tag value
|
13
|
+
#
|
14
|
+
# @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html
|
15
|
+
|
16
|
+
def put_object_tagging(bucket_name, object_name, tags)
|
17
|
+
tagging = tags.map do |k,v|
|
18
|
+
"<Tag><Key>#{k}</Key><Value>#{v}</Value></Tag>"
|
19
|
+
end.join("\n")
|
20
|
+
data =
|
21
|
+
<<-DATA
|
22
|
+
<Tagging xmlns="http://doc.s3.amazonaws.com/2006-03-01" >
|
23
|
+
<TagSet>
|
24
|
+
#{tagging}
|
25
|
+
</TagSet>
|
26
|
+
</Tagging>
|
27
|
+
DATA
|
28
|
+
|
29
|
+
request({
|
30
|
+
:body => data,
|
31
|
+
:expects => 200,
|
32
|
+
:headers => {'Content-MD5' => Base64.encode64(OpenSSL::Digest::MD5.digest(data)).chomp!, 'Content-Type' => 'application/xml'},
|
33
|
+
:bucket_name => bucket_name,
|
34
|
+
:object_name => object_name,
|
35
|
+
:method => 'PUT',
|
36
|
+
:query => {'tagging' => nil}
|
37
|
+
})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -6,12 +6,13 @@ module Fog
|
|
6
6
|
|
7
7
|
def assume_role_with_web_identity(role_arn, web_identity_token, role_session_name, options={})
|
8
8
|
request_unsigned(
|
9
|
-
'Action'
|
10
|
-
'RoleArn'
|
11
|
-
'RoleSessionName'
|
12
|
-
'
|
13
|
-
|
14
|
-
:
|
9
|
+
'Action' => 'AssumeRoleWithWebIdentity',
|
10
|
+
'RoleArn' => role_arn,
|
11
|
+
'RoleSessionName' => role_session_name,
|
12
|
+
'WebIdentityToken' => web_identity_token,
|
13
|
+
'DurationSeconds' => options[:duration] || 3600,
|
14
|
+
:idempotent => true,
|
15
|
+
:parser => Fog::Parsers::AWS::STS::AssumeRoleWithWebIdentity.new
|
15
16
|
)
|
16
17
|
end
|
17
18
|
end
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -84,6 +84,7 @@ module Fog
|
|
84
84
|
request :get_object_http_url
|
85
85
|
request :get_object_https_url
|
86
86
|
request :get_object_url
|
87
|
+
request :get_object_tagging
|
87
88
|
request :get_request_payment
|
88
89
|
request :get_service
|
89
90
|
request :head_bucket
|
@@ -107,6 +108,7 @@ module Fog
|
|
107
108
|
request :put_object
|
108
109
|
request :put_object_acl
|
109
110
|
request :put_object_url
|
111
|
+
request :put_object_tagging
|
110
112
|
request :put_request_payment
|
111
113
|
request :sync_clock
|
112
114
|
request :upload_part
|
data/lib/fog/aws/version.rb
CHANGED
data/tests/credentials_tests.rb
CHANGED
@@ -7,6 +7,8 @@ Shindo.tests('AWS | credentials', ['aws']) do
|
|
7
7
|
Fog.unmock!
|
8
8
|
begin
|
9
9
|
Excon.defaults[:mock] = true
|
10
|
+
Excon.stub({ method: :put, path: '/latest/api/token' }, { status: 200, body: 'token1234' })
|
11
|
+
|
10
12
|
Excon.stub({ method: :get, path: '/latest/meta-data/iam/security-credentials/' }, { status: 200, body: 'arole' })
|
11
13
|
Excon.stub({ method: :get, path: '/latest/meta-data/placement/availability-zone/' }, { status: 200, body: 'us-west-1a' })
|
12
14
|
|
@@ -28,6 +30,23 @@ Shindo.tests('AWS | credentials', ['aws']) do
|
|
28
30
|
aws_credentials_expire_at: expires_at) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
|
29
31
|
end
|
30
32
|
|
33
|
+
tests('#fetch_credentials when the v2 token 404s') do
|
34
|
+
Excon.stub({ method: :put, path: '/latest/api/token' }, { status: 404, body: 'not found' })
|
35
|
+
returns(aws_access_key_id: 'dummykey',
|
36
|
+
aws_secret_access_key: 'dummysecret',
|
37
|
+
aws_session_token: 'dummytoken',
|
38
|
+
region: 'us-west-1',
|
39
|
+
aws_credentials_expire_at: expires_at) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
|
40
|
+
end
|
41
|
+
|
42
|
+
tests('#fetch_credentials when the v2 disabled') do
|
43
|
+
returns(aws_access_key_id: 'dummykey',
|
44
|
+
aws_secret_access_key: 'dummysecret',
|
45
|
+
aws_session_token: 'dummytoken',
|
46
|
+
region: 'us-west-1',
|
47
|
+
aws_credentials_expire_at: expires_at) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true, disable_imds_v2: true) }
|
48
|
+
end
|
49
|
+
|
31
50
|
ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = '/v1/credentials?id=task_id'
|
32
51
|
Excon.stub({ method: :get, path: '/v1/credentials?id=task_id' }, { status: 200, body: Fog::JSON.encode(credentials) })
|
33
52
|
|
@@ -62,6 +81,7 @@ Shindo.tests('AWS | credentials', ['aws']) do
|
|
62
81
|
|
63
82
|
default_credentials = Fog::AWS::Compute.fetch_credentials({})
|
64
83
|
tests('#fetch_credentials when the url 404s') do
|
84
|
+
Excon.stub({ method: :put, path: '/latest/api/token' }, { status: 404, body: 'not found' })
|
65
85
|
Excon.stub({ method: :get, path: '/latest/meta-data/iam/security-credentials/' }, { status: 404, body: 'not bound' })
|
66
86
|
Excon.stub({ method: :get, path: '/latest/meta-data/placement/availability-zone/' }, { status: 400, body: 'not found' })
|
67
87
|
returns(default_credentials) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'fog/xml'
|
2
|
+
require 'fog/aws/parsers/elbv2/create_load_balancer'
|
3
|
+
|
4
|
+
CREATE_LOAD_BALANCER_RESULT = <<-EOF
|
5
|
+
<CreateLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2015-12-01/">
|
6
|
+
<CreateLoadBalancerResult>
|
7
|
+
<LoadBalancers>
|
8
|
+
<member>
|
9
|
+
<LoadBalancerArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/50dc6c495c0c9188</LoadBalancerArn>
|
10
|
+
<Scheme>internet-facing</Scheme>
|
11
|
+
<LoadBalancerName>my-load-balancer</LoadBalancerName>
|
12
|
+
<VpcId>vpc-3ac0fb5f</VpcId>
|
13
|
+
<CanonicalHostedZoneId>Z2P70J7EXAMPLE</CanonicalHostedZoneId>
|
14
|
+
<CreatedTime>2016-03-25T21:29:48.850Z</CreatedTime>
|
15
|
+
<AvailabilityZones>
|
16
|
+
<member>
|
17
|
+
<SubnetId>subnet-8360a9e7</SubnetId>
|
18
|
+
<ZoneName>us-west-2a</ZoneName>
|
19
|
+
</member>
|
20
|
+
<member>
|
21
|
+
<SubnetId>subnet-b7d581c0</SubnetId>
|
22
|
+
<ZoneName>us-west-2b</ZoneName>
|
23
|
+
</member>
|
24
|
+
</AvailabilityZones>
|
25
|
+
<SecurityGroups>
|
26
|
+
<member>sg-5943793c</member>
|
27
|
+
</SecurityGroups>
|
28
|
+
<DNSName>my-load-balancer-424835706.us-west-2.elb.amazonaws.com</DNSName>
|
29
|
+
<State>
|
30
|
+
<Code>provisioning</Code>
|
31
|
+
</State>
|
32
|
+
<Type>application</Type>
|
33
|
+
</member>
|
34
|
+
</LoadBalancers>
|
35
|
+
</CreateLoadBalancerResult>
|
36
|
+
<ResponseMetadata>
|
37
|
+
<RequestId>32d531b2-f2d0-11e5-9192-3fff33344cfa</RequestId>
|
38
|
+
</ResponseMetadata>
|
39
|
+
</CreateLoadBalancerResponse>
|
40
|
+
EOF
|
41
|
+
|
42
|
+
Shindo.tests('AWS::ELBV2 | parsers | create_load_balancer', %w[aws elb parser]) do
|
43
|
+
tests('parses the xml').formats(AWS::ELBV2::Formats::CREATE_LOAD_BALANCER) do
|
44
|
+
parser = Nokogiri::XML::SAX::Parser.new(Fog::Parsers::AWS::ELBV2::CreateLoadBalancer.new)
|
45
|
+
parser.parse(CREATE_LOAD_BALANCER_RESULT)
|
46
|
+
parser.document.response
|
47
|
+
end
|
48
|
+
end
|