fog-aws 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -1
  3. data/lib/fog/aws.rb +2 -0
  4. data/lib/fog/aws/cloud_formation.rb +14 -0
  5. data/lib/fog/aws/compute.rb +2 -0
  6. data/lib/fog/aws/models/compute/security_group.rb +49 -26
  7. data/lib/fog/aws/models/compute/vpc.rb +6 -0
  8. data/lib/fog/aws/models/support/flagged_resource.rb +14 -0
  9. data/lib/fog/aws/models/support/flagged_resources.rb +11 -0
  10. data/lib/fog/aws/models/support/trusted_advisor_check.rb +65 -0
  11. data/lib/fog/aws/models/support/trusted_advisor_checks.rb +21 -0
  12. data/lib/fog/aws/parsers/cloud_formation/basic.rb +8 -0
  13. data/lib/fog/aws/parsers/cloud_formation/create_change_set.rb +16 -0
  14. data/lib/fog/aws/parsers/cloud_formation/describe_account_limits.rb +26 -0
  15. data/lib/fog/aws/parsers/cloud_formation/describe_change_set.rb +135 -0
  16. data/lib/fog/aws/parsers/cloud_formation/describe_stack_resource.rb +28 -0
  17. data/lib/fog/aws/parsers/cloud_formation/estimate_template_cost.rb +16 -0
  18. data/lib/fog/aws/parsers/cloud_formation/get_stack_policy.rb +16 -0
  19. data/lib/fog/aws/parsers/cloud_formation/get_template_summary.rb +62 -0
  20. data/lib/fog/aws/parsers/cloud_formation/list_change_sets.rb +30 -0
  21. data/lib/fog/aws/parsers/compute/describe_vpcs.rb +3 -1
  22. data/lib/fog/aws/requests/cloud_formation/cancel_update_stack.rb +25 -0
  23. data/lib/fog/aws/requests/cloud_formation/continue_update_rollback.rb +26 -0
  24. data/lib/fog/aws/requests/cloud_formation/create_change_set.rb +70 -0
  25. data/lib/fog/aws/requests/cloud_formation/create_stack.rb +14 -0
  26. data/lib/fog/aws/requests/cloud_formation/delete_change_set.rb +26 -0
  27. data/lib/fog/aws/requests/cloud_formation/delete_stack.rb +1 -1
  28. data/lib/fog/aws/requests/cloud_formation/describe_account_limits.rb +27 -0
  29. data/lib/fog/aws/requests/cloud_formation/describe_change_set.rb +43 -0
  30. data/lib/fog/aws/requests/cloud_formation/describe_stack_resource.rb +40 -0
  31. data/lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb +48 -0
  32. data/lib/fog/aws/requests/cloud_formation/execute_change_set.rb +26 -0
  33. data/lib/fog/aws/requests/cloud_formation/get_stack_policy.rb +27 -0
  34. data/lib/fog/aws/requests/cloud_formation/get_template_summary.rb +46 -0
  35. data/lib/fog/aws/requests/cloud_formation/list_change_sets.rb +40 -0
  36. data/lib/fog/aws/requests/cloud_formation/set_stack_policy.rb +38 -0
  37. data/lib/fog/aws/requests/cloud_formation/signal_resource.rb +32 -0
  38. data/lib/fog/aws/requests/cloud_formation/update_stack.rb +49 -0
  39. data/lib/fog/aws/requests/compute/authorize_security_group_egress.rb +112 -0
  40. data/lib/fog/aws/requests/compute/revoke_security_group_egress.rb +98 -0
  41. data/lib/fog/aws/requests/support/describe_trusted_advisor_check_result.rb +31 -0
  42. data/lib/fog/aws/requests/support/describe_trusted_advisor_checks.rb +29 -0
  43. data/lib/fog/aws/support.rb +170 -0
  44. data/lib/fog/aws/version.rb +1 -1
  45. data/tests/models/compute/security_group_tests.rb +24 -0
  46. data/tests/models/support/trusted_advisor_tests.rb +25 -0
  47. data/tests/requests/support/helper.rb +43 -0
  48. data/tests/requests/support/trusted_advisor_check_tests.rb +16 -0
  49. metadata +36 -3
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudFormation
5
+ class DescribeStackResource < Fog::Parsers::Base
6
+ def reset
7
+ @resource = {}
8
+ @response = { 'StackResourceDetail' => {} }
9
+ end
10
+
11
+ def end_element(name)
12
+ case name
13
+ when 'Description','LogicalResourceId', 'Metadata', 'PhysicalResourceId', 'ResourceStatus', 'ResourceStatusReason', 'ResourceType', 'StackId', 'StackName'
14
+ @resource[name] = value
15
+ when 'StackResourceDetail'
16
+ @response['StackResourceDetail'] = @resource
17
+ @resource = {}
18
+ when 'RequestId'
19
+ @response[name] = value
20
+ when 'LastUpdatedTimestamp'
21
+ @resource[name] = Time.parse(value)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudFormation
5
+ class EstimateTemplateCost < Fog::Parsers::Base
6
+ def end_element(name)
7
+ case name
8
+ when 'RequestId', 'Url'
9
+ @response[name] = value
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudFormation
5
+ class GetStackPolicy < Fog::Parsers::Base
6
+ def end_element(name)
7
+ case name
8
+ when 'RequestId', 'StackPolicyBody'
9
+ @response[name] = value
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudFormation
5
+ class GetTemplateSummary < Fog::Parsers::Base
6
+ def reset
7
+ reset_parameter
8
+ @response = {'Capabilities' => [],'ResourceTypes' => '','Parameters' => [] }
9
+ end
10
+
11
+ def reset_parameter
12
+ @parameter = {'AllowedValues' => []}
13
+ end
14
+
15
+ def start_element(name, attrs=[])
16
+ super
17
+ case name
18
+ when 'Capabilities'
19
+ @in_capabilities = true
20
+ when 'Parameters'
21
+ @in_parameters = true
22
+ when 'ResourceTypes'
23
+ @in_resource_types = true
24
+ end
25
+ end
26
+
27
+ def end_element(name)
28
+ case name
29
+ when 'member'
30
+ if @in_capabilities
31
+ @response['Capabilities'] << value
32
+ elsif @in_resource_types
33
+ @response['ResourceTypes'] << value
34
+ elsif @in_parameters
35
+ @response['Parameters'] << @parameter
36
+ reset_parameter
37
+ end
38
+ when 'DefaultValue', 'NoEcho', 'ParameterKey', 'ParameterType', 'ParameterType'
39
+ @parameter[name] = value if @in_parameters
40
+ when 'Description'
41
+ if @in_parameters
42
+ @parameter[name] = value
43
+ else
44
+ @response[name] = value
45
+ end
46
+ when 'ParameterConstraints'
47
+ @parameter['AllowedValues'] << value if @in_parameters
48
+ when 'RequestId'
49
+ @response[name] = value
50
+ when 'Parameters'
51
+ @in_parameters = false
52
+ when 'ResourceTypes'
53
+ @in_resource_types = false
54
+ when 'Capabilities'
55
+ @in_capabilities = false
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudFormation
5
+ class ListChangeSets < Fog::Parsers::Base
6
+ def reset
7
+ @change_set = {}
8
+ @response = { 'Summaries' => [] }
9
+ end
10
+
11
+ def end_element(name)
12
+ case name
13
+ when 'ChangeSetId', 'ChangeSetName', 'Description', 'ExecutionStatus', 'StackId', 'StackName', 'Status', 'StackReason'
14
+ @change_set[name] = value
15
+ when 'member'
16
+ @response['Summaries'] << @change_set
17
+ @change_set = {}
18
+ when 'RequestId'
19
+ @response[name] = value
20
+ when 'CreationTime'
21
+ @change_set[name] = Time.parse(value)
22
+ when 'NextToken'
23
+ @response[name] = value
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -30,8 +30,10 @@ module Fog
30
30
  end
31
31
  else
32
32
  case name
33
- when 'vpcId', 'state', 'cidrBlock', 'dhcpOptionsId', 'instanceTenancy', 'isDefault'
33
+ when 'vpcId', 'state', 'cidrBlock', 'dhcpOptionsId', 'instanceTenancy'
34
34
  @vpc[name] = value
35
+ when 'isDefault'
36
+ @vpc['isDefault'] = value == 'true'
35
37
  when 'item'
36
38
  @response['vpcSet'] << @vpc
37
39
  @vpc = { 'tagSet' => {} }
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/basic'
6
+
7
+ # Cancels an update on the specified stack.
8
+ #
9
+ # @param stack_name String] Name of the stack to cancel update.
10
+ #
11
+ # @return [Excon::Response]
12
+ #
13
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_CancelUpdateStack.html
14
+
15
+ def cancel_update_stack(stack_name)
16
+ request(
17
+ 'Action' => 'CancelUpdateStack',
18
+ 'StackName' => stack_name,
19
+ :parser => Fog::Parsers::AWS::CloudFormation::Basic.new
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/basic'
6
+
7
+ # For a specified stack that is in the UPDATE_ROLLBACK_FAILED state,
8
+ # continues rolling it back to the UPDATE_ROLLBACK_COMPLETE state.
9
+ #
10
+ # @param stack_name [String] The name or the unique ID of the stack that you want to continue rolling back.
11
+ #
12
+ # @return [Excon::Response]
13
+ #
14
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_ContinueUpdateRollback.html
15
+
16
+ def continue_update_rollback(stack_name)
17
+ request(
18
+ 'Action' => 'ContinueUpdateRollback',
19
+ 'StackName' => stack_name,
20
+ :parser => Fog::Parsers::AWS::CloudFormation::Basic.new
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,70 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/create_change_set'
6
+
7
+ # Create a Change Set.
8
+ #
9
+ # * stack_name [String] Name of the stack to create.
10
+ # * options [Hash]:
11
+ # * ChangeSetName [String] The name of the change set.
12
+ # * Description [String] A description to help you identify this change set.
13
+ # * TemplateBody [String] Structure containing the template body.
14
+ # or (one of the two Template parameters is required)
15
+ # * TemplateURL [String] URL of file containing the template body.
16
+ # * UsePreviousTemplate [Boolean] Reuse the template that is associated with the stack to create the change set.
17
+ # * NotificationARNs [Array] List of SNS topics to publish events to.
18
+ # * Parameters [Hash] Hash of providers to supply to template.
19
+ #
20
+ # @return [Excon::Response]:
21
+ # * body [Hash:
22
+ # * Id [String] - The Amazon Resource Name (ARN) of the change set
23
+ #
24
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html
25
+
26
+ def create_change_set(stack_name, options = {})
27
+ params = {
28
+ 'StackName' => stack_name,
29
+ }
30
+
31
+ if options['ChangeSetName']
32
+ params['ChangeSetName'] = options['ChangeSetName']
33
+ end
34
+
35
+ if options['Description']
36
+ params['Description'] = options['Description']
37
+ end
38
+ if options['UsePreviousTemplate']
39
+ params['UsePreviousTemplate'] = options['UsePreviousTemplate']
40
+ end
41
+
42
+ if options['NotificationARNs']
43
+ params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*options['NotificationARNs']]))
44
+ end
45
+
46
+ if options['Parameters']
47
+ options['Parameters'].keys.each_with_index do |key, index|
48
+ index += 1 # params are 1-indexed
49
+ params.merge!({
50
+ "Parameters.member.#{index}.ParameterKey" => key,
51
+ "Parameters.member.#{index}.ParameterValue" => options['Parameters'][key]
52
+ })
53
+ end
54
+ end
55
+
56
+ if options['TemplateBody']
57
+ params['TemplateBody'] = options['TemplateBody']
58
+ elsif options['TemplateURL']
59
+ params['TemplateURL'] = options['TemplateURL']
60
+ end
61
+
62
+ request({
63
+ 'Action' => 'CreateChangeSet',
64
+ :parser => Fog::Parsers::AWS::CloudFormation::CreateChangeSet.new
65
+ }.merge!(params))
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -12,10 +12,14 @@ module Fog
12
12
  # or (one of the two Template parameters is required)
13
13
  # * TemplateURL [String] URL of file containing the template body.
14
14
  # * DisableRollback [Boolean] Controls rollback on stack creation failure, defaults to false.
15
+ # * OnFailure [String] Determines what action will be taken if stack creation fails. This must be one of: DO_NOTHING, ROLLBACK, or DELETE.
15
16
  # * NotificationARNs [Array] List of SNS topics to publish events to.
16
17
  # * Parameters [Hash] Hash of providers to supply to template
17
18
  # * TimeoutInMinutes [Integer] Minutes to wait before status is set to CREATE_FAILED
18
19
  # * Capabilities [Array] List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources
20
+ # * StackPolicyBody [String] Structure containing the stack policy body.
21
+ # * StackPolicyURL [String] URL of file containing the stack policy.
22
+ # * Tags [Array] Key-value pairs to associate with this stack.
19
23
  #
20
24
  # @return [Excon::Response]:
21
25
  # * body [Hash:
@@ -32,6 +36,10 @@ module Fog
32
36
  params['DisableRollback'] = options['DisableRollback']
33
37
  end
34
38
 
39
+ if options['OnFailure']
40
+ params['OnFailure'] = options['OnFailure']
41
+ end
42
+
35
43
  if options['NotificationARNs']
36
44
  params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*options['NotificationARNs']]))
37
45
  end
@@ -69,6 +77,12 @@ module Fog
69
77
  params['TemplateURL'] = options['TemplateURL']
70
78
  end
71
79
 
80
+ if options['StackPolicyBody']
81
+ params['StackPolicyBody'] = options['StackPolicyBody']
82
+ elsif options['StackPolicyURL']
83
+ params['StackPolicyURL'] = options['StackPolicyURL']
84
+ end
85
+
72
86
  if options['TimeoutInMinutes']
73
87
  params['TimeoutInMinutes'] = options['TimeoutInMinutes']
74
88
  end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/basic'
6
+
7
+ # Delete a change set.
8
+ #
9
+ # @param ChangeSetName [String] The name of the change set to delete.
10
+ # @option options StackName [String] The Stack name or ID (ARN) that is associated with change set.
11
+ #
12
+ # @return [Excon::Response]
13
+ #
14
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DeleteChangeSet.html
15
+
16
+ def delete_change_set(change_set_name, options = {})
17
+ options['ChangeSetName'] = change_set_name
18
+ request({
19
+ 'Action' => 'DeleteChangeSet',
20
+ :parser => Fog::Parsers::AWS::CloudFormation::Basic.new
21
+ }.merge!(options))
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -6,7 +6,7 @@ module Fog
6
6
 
7
7
  # Delete a stack.
8
8
  #
9
- # @param stack_name String] Name of the stack to create.
9
+ # @param stack_name [String] Name of the stack to create.
10
10
  #
11
11
  # @return [Excon::Response]
12
12
  #
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/describe_account_limits'
6
+
7
+ # Describe account_limits.
8
+ #
9
+ #
10
+ # @return [Excon::Response]
11
+ # * body [Hash]:
12
+ # * AccountLimits [Array]
13
+ # * member [Hash]:
14
+ # * StackLimit [Integer]
15
+ #
16
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeAccountLimits.html
17
+
18
+ def describe_account_limits()
19
+ request(
20
+ 'Action' => 'DescribeAccountLimits',
21
+ :parser => Fog::Parsers::AWS::CloudFormation::DescribeAccountLimits.new
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/describe_change_set'
6
+
7
+ # Describe change_set.
8
+ #
9
+ # * ChangeSetName [String] The name of the change set to describe.
10
+ # @param options [Hash]
11
+ # @option options StackName [String] Name of the stack for the change set.
12
+ #
13
+ # @return [Excon::Response]
14
+ # * body [Hash]:
15
+ # * ChangeSetId [String] -
16
+ # * ChangeSetName [String] -
17
+ # * Description [String] -
18
+ # * CreationTime [Time] -
19
+ # * ExecutionStatus [String] -
20
+ # * StackId [String] -
21
+ # * StackName [String] -
22
+ # * Status [String] -
23
+ # * StackReason [String] -
24
+ # * NotificationARNs [Array] -
25
+ # * NotificationARN [String] -
26
+ # * Parameters [Array] -
27
+ # * parameter [Hash]:
28
+ # * ParameterKey [String] -
29
+ # * ParameterValue [String] -
30
+ #
31
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeChangeSet.html
32
+
33
+ def describe_change_set(change_set_name, options = {})
34
+ options['ChangeSetName'] = change_set_name
35
+ request({
36
+ 'Action' => 'DescribeChangeSet',
37
+ :parser => Fog::Parsers::AWS::CloudFormation::DescribeChangeSet.new
38
+ }.merge!(options))
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module AWS
3
+ class CloudFormation
4
+ class Real
5
+ require 'fog/aws/parsers/cloud_formation/describe_stack_resource'
6
+
7
+ # Describe stack resource.
8
+ #
9
+ # @param options Hash]:
10
+ # * LogicalResourceId [String] Logical name of the resource as specified in the template
11
+ # * StackName [String] The name or the unique stack ID
12
+ #
13
+ # @return [Excon::Response]
14
+ # * body [Hash]:
15
+ # * StackResourceDetail [Hash] - Matching resources
16
+ # *Description [String] -
17
+ # * LastUpdatedTimestamp [Timestamp] -
18
+ # * LogicalResourceId [String] -
19
+ # * Metadata [String] -
20
+ # * PhysicalResourceId [String] -
21
+ # * ResourceStatus [String] -
22
+ # * ResourceStatusReason [String] -
23
+ # * ResourceType [String] -
24
+ # * StackId [String] -
25
+ # * StackName [String] -
26
+ #
27
+ # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackResource.html
28
+
29
+ def describe_stack_resource(logical_resource_id, stack_name )
30
+ request(
31
+ 'Action' => 'DescribeStackResource',
32
+ 'LogicalResourceId' => logical_resource_id,
33
+ 'StackName' => stack_name,
34
+ :parser => Fog::Parsers::AWS::CloudFormation::DescribeStackResource.new
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end