Class: Jets::Resource::ApiGateway::Deployment
- Defined in:
- lib/jets/resource/api_gateway/deployment.rb
Constant Summary collapse
- @@timestamp =
nil
Class Method Summary collapse
Instance Method Summary collapse
- #definition ⇒ Object
- #depends_on ⇒ Object
- #deployment_logical_id ⇒ Object
- #outputs(internal = false) ⇒ Object
- #parameters ⇒ Object
-
#stage_name ⇒ Object
stage_name: dev, dev-1, dev-2, etc.
- #timestamp ⇒ Object
Methods inherited from Base
Class Method Details
.logical_id ⇒ Object
76 77 78 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 76 def self.logical_id "ApiDeployment#{}" end |
.stage_name ⇒ Object
58 59 60 61 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 58 def self.stage_name # Stage name only allows a-zA-Z0-9_ [Jets.config.short_env, Jets.config.extra].compact.join('_').gsub('-','_') end |
.timestamp ⇒ Object
68 69 70 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 68 def self. @@timestamp ||= Time.now.strftime("%Y%m%d%H%M%S") end |
Instance Method Details
#definition ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 3 def definition { deployment_logical_id => { type: "AWS::ApiGateway::Deployment", properties: { description: "Version #{} deployed by jets", rest_api_id: "!Ref #{RestApi.logical_id}", stage_name: stage_name, } } } end |
#depends_on ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 35 def depends_on expression = "#{Jets::Names.template_path_prefix}-*_controller*" controller_logical_ids = [] Dir.glob(expression).each do |path| next unless File.file?(path) regexp = Regexp.new(".*#{Jets.config.project_namespace}-") controller_name = path.sub(regexp, '').sub('.yml', '') # map the path to a camelized logical_id. Example: # /tmp/jets/demo/templates/demo-dev-2-posts_controller.yml to # PostsController controller_logical_id = controller_name.underscore.camelize controller_logical_ids << controller_logical_id end controller_logical_ids end |
#deployment_logical_id ⇒ Object
72 73 74 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 72 def deployment_logical_id self.class.logical_id.underscore end |
#outputs(internal = false) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 28 def outputs(internal=false) rest_api = internal ? RestApi.internal_logical_id : "RestApi" { "RestApiUrl" => "!Sub 'https://${#{rest_api}}.execute-api.${AWS::Region}.amazonaws.com/#{stage_name}/'", } end |
#parameters ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 16 def parameters p = { "GemLayer" => "GemLayer", "IamRole" => "IamRole", "RestApi" => "RestApi", "S3Bucket" => "S3Bucket", } p[:DomainName] = "DomainName" if Jets.custom_domain? p[:BasePath] = "BasePath" unless Jets.config.domain.base_path.nil? p end |
#stage_name ⇒ Object
stage_name: dev, dev-1, dev-2, etc
54 55 56 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 54 def stage_name self.class.stage_name end |
#timestamp ⇒ Object
63 64 65 |
# File 'lib/jets/resource/api_gateway/deployment.rb', line 63 def self.class. end |