openstax_aws 1.5.0 → 1.6.0

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
  SHA256:
3
- metadata.gz: 7754f428f875d2a03d7e007352ab1c98107838904fd56ec7b0b7e188f62cf3fd
4
- data.tar.gz: 862cfac082c78ac44a42190634cac16e2d05b2eaf5f9445950928d9883bd53b8
3
+ metadata.gz: d7ed7cb99a4131a436325e8766d03f6a62accbd62a700a6238a0a6278ae1e6e5
4
+ data.tar.gz: 46f26ea0c266cf1c1ca1b0cf7c5307848bf8be3c5097c7fe16472a1fe3115f81
5
5
  SHA512:
6
- metadata.gz: dfb2f7012992c090625da1ba7906f475d43042456e8c241e54624123f12a28ac36effa58cab39de0beede13643f4513441da7e1154edfaa2f1783e97ea8927dc
7
- data.tar.gz: 309ed6f57c82ea3d42a9860f44a7ad80bec3d524ae5deac7546ed870e4cb572b904cba75a76df9e4d80c0834e6393b1b85d41a53d5bb9bc4619da8fc20ea0b1d
6
+ metadata.gz: 1871bbb908ecbfb58eb782fae57f960cf1db1a066adf8003c14115756273656a51aa2c32e061bb8fcc6607fe06633fd6936b7d71da38c907d313aa9d5509ad8b
7
+ data.tar.gz: 82108d04dde247454dfeafe8450a2bfed4ffe40d8d00c45dea2693501ae9693e7e77be618605cf3f49cb647bdb6cdf0b78e1cac71b37f3fe0fbe94543a1ffac8
@@ -7,6 +7,7 @@ module OpenStax
7
7
  def initialize(ami_name_base:, region:,
8
8
  verbose: false, debug: false,
9
9
  github_org:, repo:, branch: nil, sha: nil,
10
+ deployment_sha: nil,
10
11
  packer_absolute_file_path: , playbook_absolute_file_path:,
11
12
  dry_run: true)
12
13
  if sha.nil?
@@ -18,6 +19,8 @@ module OpenStax
18
19
  )
19
20
  end
20
21
 
22
+ deployment_sha ||= OpenStax::Aws::GitHelper.current_sha
23
+
21
24
  ami_name = "#{ami_name_base}@#{sha[0..6]} #{Time.now.utc.strftime("%y%m%d%H%MZ")}"
22
25
 
23
26
  @packer = OpenStax::Aws::PackerFactory.new_packer(
@@ -30,9 +33,11 @@ module OpenStax
30
33
  @packer.var("region", region)
31
34
  @packer.var("ami_name", ami_name)
32
35
  @packer.var("sha", sha)
36
+ @packer.var("deployment_sha", deployment_sha)
33
37
  @packer.var("playbook_file", playbook_absolute_file_path)
34
38
  @packer.var("ami_description", {
35
39
  sha: sha,
40
+ deployment_sha: deployment_sha,
36
41
  github_org: github_org,
37
42
  repo: repo
38
43
  }.to_json)
@@ -3,7 +3,6 @@ require 'open-uri'
3
3
 
4
4
  module OpenStax::Aws
5
5
  module GitHelper
6
-
7
6
  def self.sha_for_branch_name(org_slash_repo:, branch:)
8
7
  ::Git.ls_remote("https://github.com/#{org_slash_repo}")["branches"][branch][:sha]
9
8
  end
@@ -23,5 +22,9 @@ module OpenStax::Aws
23
22
  end
24
23
  end
25
24
  end
25
+
26
+ def self.current_sha
27
+ ::Git.revparse('HEAD')
28
+ end
26
29
  end
27
30
  end
@@ -25,9 +25,12 @@ module OpenStax::Aws
25
25
  get_tag(key: "sha")
26
26
  end
27
27
 
28
- def self.find_by_sha(sha:, region:)
28
+ def self.find_by_sha(sha:, region:, deployment_sha: nil)
29
+ filters = [{name: "tag:sha", values: [sha]}]
30
+ filters << {name: "tag:deployment_sha", values: [deployment_sha]} unless deployment_sha.nil?
31
+
29
32
  Aws::EC2::Client.new(region: region).describe_images({
30
- owners: ['self'], filters: [{name: "tag:sha", values: [sha]}]
33
+ owners: ['self'], filters: filters
31
34
  }).images.map{|aws_image| new(aws_image: aws_image)}
32
35
  end
33
36
  end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Aws
3
- VERSION = "1.5.0"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-14 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-autoscaling