aws_client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a68ecc8d49db232b896160d304946501e56072b
4
- data.tar.gz: 9be7f394a8ac196d416fb6fd6b67670470bdfc91
3
+ metadata.gz: 3fddc029999898a6956183916de48acb4fe9372b
4
+ data.tar.gz: 469c2dbb49038b7cde938b48c67f02f9d3175803
5
5
  SHA512:
6
- metadata.gz: c26ba01a0b5dd0d559c00604acb8734958fa9791cbe9c2a40597057a9e7fc6b40d262e5234c7a59eafc56a62e361aa7ec66c2235e7d421b261984d60f07bb9a4
7
- data.tar.gz: 58b1225923c91e4ebe0e4726d78c635373624fd2712badcf6d9b2f0669897eea42afc122274856d879c47067987ce4c94107836d6f9580c6300514b79d3058f7
6
+ metadata.gz: 48f0b4124565e85e811c8ecf470544b105fc697d1aea01e3c352fc8387ed69dc0f42c192ec80a0683a0c524b2a9a287387aba79604e381ab583e26c6cbe22007
7
+ data.tar.gz: 252b43b100bf2b1512057d46668c89a0c74f9f891c991b2c0b07cc61a207f951fc10d3087b2804fae47999077585d2a13b69257dc0d27294810732b6fd1b7f7a
data/README.md CHANGED
@@ -39,7 +39,7 @@ Then include it in your project
39
39
 
40
40
  ### Usage
41
41
 
42
- #### Connnecting
42
+ #### Connecting
43
43
 
44
44
  ```
45
45
  # ::AwsClient::Container.new(ORG_KEY, AWS_REGION, PROVISIONING_REGION) e.g.
@@ -71,3 +71,10 @@ Each client wrapper above is merely a wrapper for the underlying AWS client, fro
71
71
  ```
72
72
 
73
73
  Each client wrapper exposes some additional functionality useful to me, but may easily be monkey patched to add functionality (I find working with AWS APIs often exhausting, especially when working with Cloudformation where orchestration tasks may involve the use of multiple APIs in sequence).
74
+
75
+
76
+ #### Specific usage examples
77
+
78
+ * [S3](documentation/s3.md)
79
+ * [Cloudformation](documentation/cloudformation.md)
80
+
Binary file
@@ -0,0 +1,55 @@
1
+ ### Cloudformation
2
+
3
+ N.B. This gem solves very specific and limited use cases, and is in no way exhaustive (although it may be easily monkey patched to add in additional functions)
4
+
5
+ #### Create a cloudformation stack from a public template url
6
+
7
+ ```
8
+ aws_clients = ::AwsClient::Container.new(ORG_KEY, AWS_REGION, PROVISIONING_REGION)
9
+
10
+ cloudformation_client = aws_clients.cloudformation
11
+
12
+ cloudformation_client.create_stack(
13
+ stack_name: "The name for you stack",
14
+ template_url: "The URL at which your cloudformation template can be found (in S3)"
15
+ capabilities: ["List", "of", "capabilities"] # e.g ["CAPABILITY_IAM"],
16
+ on_failure: "failure action" # e.g. "DO_NOTHING" | "ROLLBACK" | "DELETE"
17
+ tags = [
18
+ { key: "value" },
19
+ { secondkey: "secondvalue" }
20
+ ]
21
+ )
22
+
23
+ ```
24
+
25
+ #### Get stack status
26
+
27
+ ```
28
+ cloudformation_client.stack_status("STACK NAME")
29
+ ```
30
+
31
+
32
+ #### Accessing the underlying client
33
+
34
+ ```
35
+ aws_clients = ::AwsClient::Container.new(ORG_KEY, AWS_REGION, PROVISIONING_REGION)
36
+ cloudformation_client = aws_clients.cloudformation
37
+ underlying_client = cloudformation_client.client
38
+ ```
39
+
40
+ #### Extending functionality with a patch:
41
+
42
+ Extend the following class:
43
+
44
+ ```
45
+ module AwsClient
46
+ class CfWrapper < AwsClient::Wrapper
47
+
48
+ ...
49
+
50
+ end
51
+ end
52
+ ```
53
+
54
+ See 'Accessing the underlying client', above, for how to access the underlying cloudformation client.
55
+
@@ -0,0 +1,57 @@
1
+ ### S3 Usage examples
2
+
3
+ N.B. This gem solves very specific and limited use cases, and is in no way exhaustive (although it may be easily monkey patched to add in additional functions)
4
+
5
+ #### Configuration
6
+
7
+ Create a file named .aws_buckets in your root home directory. This file is a simple lookup allowing you to reference S3 buckets by key, e.g.
8
+
9
+ ```
10
+ ---
11
+ :bucket_1_key: "name of bucket 1 in S3"
12
+ :bucket_2_key: "name of bucket 2 in S3"
13
+ ```
14
+
15
+ #### Writing to a bucket
16
+
17
+ ```
18
+ aws_clients = ::AwsClient::Container.new(ORG_KEY, AWS_REGION, PROVISIONING_REGION)
19
+ s3_client = aws_clients.s3
20
+ s3_client.write_file_to_bucket(bucket_key, path_to_local_file)
21
+ ```
22
+
23
+ #### Find or create a bucket by bucket key
24
+
25
+ ```
26
+ aws_clients = ::AwsClient::Container.new(ORG_KEY, AWS_REGION, PROVISIONING_REGION)
27
+ s3_client = aws_clients.s3
28
+ s3_client.find_or_create_bucket_for(bucket_key)
29
+ ```
30
+
31
+ Note that when creating an S3 bucket, it will be named in the following format: [bucket key].[aws credentials key].[aws region]
32
+
33
+ #### Accessing the underlying client
34
+
35
+ ```
36
+ aws_clients = ::AwsClient::Container.new(ORG_KEY, AWS_REGION, PROVISIONING_REGION)
37
+ s3_client = aws_clients.s3
38
+ underlying_client = s3_client.client
39
+ ```
40
+
41
+ #### Extending functionality with a patch:
42
+
43
+ Extend the following class:
44
+
45
+ ```
46
+ module AwsClient
47
+ class S3Wrapper < AwsClient::Wrapper
48
+
49
+ ...
50
+
51
+ end
52
+ end
53
+ ```
54
+
55
+
56
+ See 'Accessing the underlying client', above, for how to access the underlying S3 client.
57
+
@@ -1,3 +1,3 @@
1
1
  module AwsClient
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/cf_wrapper.rb CHANGED
@@ -2,6 +2,7 @@ module AwsClient
2
2
  class CfWrapper < Wrapper
3
3
 
4
4
  STACK_COMPLETE_STATUS = "CREATE_COMPLETE"
5
+ STACK_UPDATE_COMPLETE_STATUS = "UPDATE_COMPLETE"
5
6
  STACK_ROLLLBACK_STATUS = "ROLLBACK_IN_PROGRESS"
6
7
  STACK_WAIT_SLEEP_TIME = 3
7
8
 
@@ -11,6 +12,14 @@ module AwsClient
11
12
  wait_for_stack(stack_params[:stack_name])
12
13
  end
13
14
 
15
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#update_stack-instance_method
16
+ def update_stack(stack_params)
17
+ puts "Updating stack with the following parameters: #{stack_params.inspect}"
18
+ response = client.update_stack(stack_params)
19
+ is_update = true
20
+ wait_for_stack(stack_params[:stack_name], is_update)
21
+ end
22
+
14
23
  def stack_status_for(stack_name)
15
24
  stack_info = stack_info_for(stack_name)
16
25
  return stack_info_for(stack_name).stack_status
@@ -49,17 +58,19 @@ module AwsClient
49
58
  resource_data_for_resource_name(stack_name, resource_name).physical_resource_id
50
59
  end
51
60
 
52
- def wait_for_stack(stack_name)
53
- puts "Waiting for stack to spin up"
61
+ def wait_for_stack(stack_name, is_update = false)
62
+ puts "Waiting for stack"
54
63
  status = ""
55
- while status != STACK_COMPLETE_STATUS
64
+ end_status = is_update ? STACK_UPDATE_COMPLETE_STATUS : STACK_COMPLETE_STATUS
65
+
66
+ while status != end_status
56
67
  status = stack_status_for(stack_name)
57
68
  puts "'#{stack_name}' stack status: #{status}"
58
69
 
59
70
  raise "Rollback in progress - CF build failed" if status == STACK_ROLLLBACK_STATUS
60
71
  sleep(STACK_WAIT_SLEEP_TIME)
61
72
  end
62
- puts "Stack is up. Ready for bootstrapping"
73
+ puts "Stack is ready."
63
74
  end
64
75
 
65
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Webzakimbo
@@ -65,9 +65,12 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - aws_client-0.0.1.gem
68
+ - aws_client-0.0.2.gem
68
69
  - aws_client.gemspec
69
70
  - bin/console
70
71
  - bin/setup
72
+ - documentation/cloudformation.md
73
+ - documentation/s3.md
71
74
  - lib/aws_client.rb
72
75
  - lib/aws_client/version.rb
73
76
  - lib/cf_wrapper.rb