AWS-Lambda-Quick
view release on metacpan or search on metacpan
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
}
$self->_stage;
return ();
}
sub api_url {
my $self = shift;
return
'https://'
. $self->rest_api_id
. '.execute-api.'
. $self->region
. '.amazonaws.com/'
. $self->stage_name . '/'
. $self->name;
}
sub _stage {
my $self = shift;
$self->aws_do(
'apigateway',
'create-deployment',
{
'rest-api-id' => $self->rest_api_id,
'stage-name' => $self->stage_name,
}
);
}
sub _create_method {
my $self = shift;
my $resource_id = shift;
my @identifiers = (
'rest-api-id' => $self->rest_api_id,
'resource-id' => $resource_id,
'http-method' => 'ANY',
);
$self->debug('checking for existing method');
# get the current method
my $result = $self->aws->apigateway(
'get-method', {@identifiers},
);
if ($result) {
$self->debug('found existing method');
return ();
}
$self->debug('putting new method');
$self->aws_do(
'apigateway',
'put-method',
{
@identifiers,
'authorization-type' => 'NONE',
},
);
$self->debug('new method put');
return ();
}
sub _create_method_response {
my $self = shift;
my $resource_id = shift;
my $identifiers = {
'rest-api-id' => $self->rest_api_id,
'resource-id' => $resource_id,
'http-method' => 'ANY',
'status-code' => 200,
};
$self->debug('checking for existing method response');
# get the current method response
my $result = $self->aws->apigateway(
'get-method-response', $identifiers,
);
if ($result) {
$self->debug('found existing method response');
return ();
}
$self->debug('putting new method response');
$self->aws_do(
'apigateway',
'put-method-response',
$identifiers,
);
$self->debug('new method response put');
return ();
}
sub _create_integration {
my $self = shift;
my $function_arn = shift;
my $resource_id = shift;
my $identifiers = {
'rest-api-id' => $self->rest_api_id,
'resource-id' => $resource_id,
'http-method' => 'ANY',
};
# according the the documentation at https://docs.aws.amazon.com/cli/latest/reference/apigateway/put-integration.html
# the uri has the form arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}
# "lambda:path/2015-03-31/functions" is the {subdomain.service|service}:path|action for lambda functions
my $uri
= "arn:aws:apigateway:@{[ $self->region ]}:lambda:path/2015-03-31/functions/$function_arn/invocations";
$self->debug('checking for existing integration');
# get the current method response
( run in 1.037 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )