lib/jets/resource/api_gateway/resource.rb in jets-1.1.5 vs lib/jets/resource/api_gateway/resource.rb in jets-1.2.0
- old
+ new
@@ -1,19 +1,20 @@
module Jets::Resource::ApiGateway
class Resource < Jets::Resource::Base
- def initialize(path)
+ def initialize(path, internal: false)
@path = path # Examples: "posts/:id/edit" or "posts"
+ @internal = internal
end
def definition
{
resource_logical_id => {
type: "AWS::ApiGateway::Resource",
properties: {
parent_id: parent_id,
path_part: path_part,
- rest_api_id: "!Ref RestApi",
+ rest_api_id: "!Ref #{RestApi.logical_id(@internal)}",
}
}
}
end
@@ -40,10 +41,10 @@
if @path.include?('/') # posts/:id or posts/:id/edit
parent_path = @path.split('/')[0..-2].join('/')
parent_logical_id = path_logical_id(parent_path)
"!Ref #{parent_logical_id}ApiResource"
else
- "!GetAtt RestApi.RootResourceId"
+ "!GetAtt #{RestApi.logical_id(@internal)}.RootResourceId"
end
end
def path_part
last_part = path.split('/').last