Class: Jets::Commands::Url
- Inherits:
-
Object
- Object
- Jets::Commands::Url
show all
- Includes:
- AwsServices
- Defined in:
- lib/jets/commands/url.rb
Instance Method Summary
collapse
#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts
#lookup, #stack_exists?, #stack_in_progress?
included
Constructor Details
#initialize(options) ⇒ Url
Returns a new instance of Url.
5
6
7
|
# File 'lib/jets/commands/url.rb', line 5
def initialize(options)
@options = options
end
|
Instance Method Details
#display ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/jets/commands/url.rb', line 9
def display
stack_name = Jets::Names.parent_stack_name
unless stack_exists?(stack_name)
puts "Stack for #{Jets.config.project_name.color(:green)} project for environment #{Jets.env.color(:green)}. Couldn't find #{stack_name.color(:green)} stack."
exit
end
stack = cfn.describe_stacks(stack_name: stack_name).stacks.first
api_gateway_stack_arn = lookup(stack[:outputs], "ApiGateway")
if api_gateway_stack_arn && endpoint_available?
api_gateway_endpoint = get_gateway_endpoint(api_gateway_stack_arn)
STDOUT.puts "API Gateway Endpoint: #{api_gateway_endpoint}"
show_custom_domain
else
puts "API Gateway not found. This jets app does have an API Gateway associated with it. Please double check your config/routes.rb if you were expecting to see a url for the app. Also check that #{stack_name.color(:green)} is a jets app."
end
end
|
#endpoint_available? ⇒ Boolean
56
57
58
|
# File 'lib/jets/commands/url.rb', line 56
def endpoint_available?
!endpoint_unavailable?
end
|
#endpoint_unavailable? ⇒ Boolean
50
51
52
53
54
|
# File 'lib/jets/commands/url.rb', line 50
def endpoint_unavailable?
return false if Jets::Router.routes.empty?
resp, status = stack_status
return false if status.include?("ROLLBACK")
end
|
#get_gateway_endpoint(api_gateway_stack_arn) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/jets/commands/url.rb', line 28
def get_gateway_endpoint(api_gateway_stack_arn)
stack = cfn.describe_stacks(stack_name: api_gateway_stack_arn).stacks.first
rest_api = lookup(stack[:outputs], "RestApi")
region_id = lookup(stack[:outputs], "Region")
stage_name = Jets::Resource::ApiGateway::Deployment.stage_name
"https://#{rest_api}.execute-api.#{region_id}.amazonaws.com/#{stage_name}"
end
|
#show_custom_domain ⇒ Object
#stack_status ⇒ Object
62
63
64
65
66
|
# File 'lib/jets/commands/url.rb', line 62
def stack_status
resp = cfn.describe_stacks(stack_name: @parent_stack_name)
status = resp.stacks[0].stack_status
[resp, status]
end
|