>.
diff --git a/NAMESPACE b/NAMESPACE
index ffb0b89..68cbf78 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -17,12 +17,22 @@ export(list_function_aliases)
export(list_function_versions)
export(list_functions)
export(make_function_version)
+export(publish_function_version)
export(update_function)
export(update_function_alias)
-import(httr)
+export(update_function_code)
+export(update_function_config)
+importFrom(aws.signature,locate_credentials)
importFrom(aws.signature,signature_v4_auth)
importFrom(base64enc,base64encode)
-importFrom(jsonlite,fromJSON)
+importFrom(httr,DELETE)
+importFrom(httr,GET)
+importFrom(httr,POST)
+importFrom(httr,PUT)
+importFrom(httr,add_headers)
+importFrom(httr,content)
+importFrom(httr,headers)
+importFrom(httr,http_error)
+importFrom(httr,stop_for_status)
importFrom(jsonlite,toJSON)
-importFrom(utils,str)
importFrom(utils,zip)
diff --git a/NEWS.md b/NEWS.md
index 88bafd5..14461c1 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,19 +1,26 @@
-# CHANGES TO aws.lambda 0.1.6
+# aws.lambda 0.1.6.9000
+
+* New maintainer (@jonthegeek).
+* Updated license to GPL-3.
+* Deprecated `update_function()` in favor of `update_function_code()` and `update_function_config()`.
+* Deprecated `make_function_version()` in favor of `publish_function_version()`.
+
+# aws.lambda 0.1.6
* Change `get_account()` to `get_lambda_account()` to avoid namespace conflict with **aws.iam.**
-# CHANGES TO aws.lambda 0.1.4
+# aws.lambda 0.1.4
* Bump **aws.signature** dependency to 0.3.4.
-# CHANGES TO aws.lambda 0.1.3
+# aws.lambda 0.1.3
* Rename alias-related functions to avoid namespace clash with aws.iam.
-# CHANGES TO aws.lambda 0.1.2
+# aws.lambda 0.1.2
* Update code and documentation.
-# CHANGES TO aws.lambda 0.1.1
+# aws.lambda 0.1.1
* Initial release.
diff --git a/R/account.R b/R/account.R
index 8cfba04..9623adc 100644
--- a/R/account.R
+++ b/R/account.R
@@ -4,10 +4,10 @@
#' @return A list.
#' @examples
#' \dontrun{
-#' get_lambda_account()
+#' get_lambda_account()
#' }
#' @export
get_lambda_account <- function(...) {
- act <- paste0("/2016-08-19/account-settings")
- lambdaHTTP(verb = "GET", action = act, ...)
+ act <- paste0("/2016-08-19/account-settings")
+ lambdaHTTP(verb = "GET", action = act, ...)
}
diff --git a/R/aliases.R b/R/aliases.R
index 04b917a..c53cba5 100644
--- a/R/aliases.R
+++ b/R/aliases.R
@@ -3,63 +3,100 @@
#' @description List, create, update, and delete function aliases
#' @template name
#' @param alias A character string specifying a function alias
-#' @param description Optionally, a max 256-character description of the function for your own use.
-#' @param version A character string specifying a function version
+#' @param version A character string specifying a function version to associate
+#' with this alias.
+#' @param description Optionally, a max 256-character description of the
+#' function for your own use.
#' @param marker A pagination marker from a previous request.
#' @param n An integer specifying the number of results to return.
#' @template dots
#' @return An object of class \dQuote{aws_lambda_function}.
-#' @details \code{list_functions} lists all functions. \code{get_function} retrieves a specific function and \code{get_function_versions} retrieves all versions of that function. \code{get_function_configuration} returns the configuration details used when creating or updating the function. \code{delete_function} deletes a function, if you have permission to do so.
+#' @details \code{create_function_alias} creates a new function alias for a
+#' given version of a function. \code{update_function_alias} updates the
+#' association between a function alias and the function version.
+#' \code{list_function_aliases} lists all function aliases.
+#' \code{get_function_alias} retrieves a specific function alias.
+#' \code{delete_function_alias} deletes a function alias, but not the
+#' associated function version.
#' @references
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetAlias.html}{API Reference: GetAlias}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html}{API Reference: CreateAlias}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html}{API Reference: UpdateAlias}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_DeleteAlias.html}{API Reference: DeleteAlias}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListAliases.html}{API Reference: ListAliases}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetAlias.html}{API
+#' Reference: GetAlias}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html}{API
+#' Reference: CreateAlias}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html}{API
+#' Reference: UpdateAlias}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_DeleteAlias.html}{API
+#' Reference: DeleteAlias}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListAliases.html}{API
+#' Reference: ListAliases}
#' @seealso \code{\link{create_function}}, \code{\link{list_functions}}
#' @export
-create_function_alias <- function(name, alias, description, version, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/aliases")
- b <- list(Description = description, FunctionVersion = version, Name = alias)
- r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
- return(r)
+create_function_alias <- function(name, alias, version, description, ...) {
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/aliases")
+ b <- list(FunctionVersion = version, Name = alias)
+ # Description is optional.
+ if (!missing(description)) {
+ b[["Description"]] <- description
+ }
+ r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
+ return(r)
}
#' @rdname alias
#' @export
-update_function_alias <- function(name, alias, description, version, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
- b <- list(Description = description, FunctionVersion = version)
- r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
- return(r)
+update_function_alias <- function(name, alias, version, description, ...) {
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
+ b <- list()
+ if (!missing(version)) {
+ b[["FunctionVersion"]] <- version
+ }
+ if (!missing(description)) {
+ b[["Description"]] <- description
+ }
+ r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
+ return(r)
}
#' @rdname alias
#' @export
delete_function_alias <- function(name, alias, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
- r <- lambdaHTTP(verb = "DELETE", action = act, ...)
- return(r)
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
+ r <- lambdaHTTP(verb = "DELETE", action = act, ...)
+ return(r)
}
#' @rdname alias
#' @export
get_function_alias <- function(name, alias, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
- r <- lambdaHTTP(verb = "GET", action = act, ...)
- return(r)
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
+ r <- lambdaHTTP(verb = "GET", action = act, ...)
+ return(r)
}
#' @rdname alias
#' @export
list_function_aliases <- function(name, version, marker, n, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/aliases")
- query <- list(FunctionVersion = version, Marker = marker, MaxItems = n)
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- return(r)
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/aliases")
+ query <- list()
+ if (!missing(version)) {
+ warning(
+ "The AWS API erroneously returns an empty list when version is specified",
+ " if you only have one alias.",
+ "\n You may want to try again without specifying a version."
+ )
+ query[["FunctionVersion"]] <- version
+ }
+ if (!missing(marker)) {
+ query[["Marker"]] <- marker
+ }
+ if (!missing(n)) {
+ query[["MaxItems"]] <- n
+ }
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ return(r)
}
diff --git a/R/create_function.R b/R/create_function.R
index 40d68c0..8aef69b 100644
--- a/R/create_function.R
+++ b/R/create_function.R
@@ -1,160 +1,296 @@
#' @rdname create_function
#' @title Manage AWS Lambda Functions
#' @description Create, update, and version AWS Lambda functions
-#' @param func Either (1) a character string containing a url-style AWS S3 bucket and object key (e.g., \code{"s3://bucketname/objectkey"}) where the object is the .zip file containing the AWS Lambda deployment package; (2) a file string pointing to a .zip containing the deployment package; or (3) a single file (e.g., a javascript file) that will be zipped and used as the deployment. The third option is merely a convenience for very simple deployment packages.
+#' @param func Either (1) a character string containing a url-style AWS S3
+#' bucket and object key (e.g., \code{"s3://bucketname/objectkey"}) where the
+#' object is the .zip file containing the AWS Lambda deployment package; (2) a
+#' file string pointing to a .zip containing the deployment package; or (3) a
+#' single file (e.g., a javascript file) that will be zipped and used as the
+#' deployment. The third option is merely a convenience for very simple
+#' deployment packages.
#' @template name
-#' @param description Optionally, a max 256-character description of the function for your own use.
-#' @param handler A character string specifying the function within your code that Lambda calls to begin execution.
-#' @param role A character string containing an IAM role or an object of class \dQuote{iam_role}. This is the role that is used when the function is invoked, so it must have permissions over any AWS resources needed by the function.
-#' @param runtime A character string specifying the runtime environment for the function.
-#' @param timeout An integer specifying the timeout for the function, in seconds.
+#' @param description Optionally, a max 256-character description of the
+#' function for your own use.
+#' @param handler A character string specifying the function within your code
+#' that Lambda calls to begin execution.
+#' @param role A character string containing an IAM role or an object of class
+#' \dQuote{iam_role}. This is the role that is used when the function is
+#' invoked, so it must have permissions over any AWS resources needed by the
+#' function.
+#' @param runtime A character string specifying the runtime environment for the
+#' function.
+#' @param timeout An integer specifying the timeout for the function, in
+#' seconds.
#' @template dots
#' @return A list of class \dQuote{aws_lambda_function}.
-#' @details \code{create_function} creates a new function from a deployment package. \code{update_function} can, separately, update the code within a function or the configuration settings thereof. \code{make_function_version} records a function version (see \code{\link{list_function_versions}}; changes made between versioning are not recorded.
+#' @details \code{create_function} creates a new function from a deployment
+#' package. \code{update_function_code} updates the code within a function.
+#' \code{update_function_config} updates the configuration settings of a
+#' function. \code{publish_function_version} records a function version (see
+#' \code{\link{list_function_versions}}; changes made between versioning are
+#' not recorded.
#' @references
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html}{API Reference: CreateFunction}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunction.html}{API Reference: UpdateFunction}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_PublishFunction.html}{API Reference: PublishFunction}
-#'
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html}{API
+#' Reference: CreateFunction}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionCode.html}{API
+#' Reference: UpdateFunctionCode}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_PublishVersion.html}{API
+#' Reference: PublishVersion}
+#'
#' @examples
#' \dontrun{
-#' # 'hello world!' example code
-#' hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
+#' # 'hello world!' example code
+#' hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
+#'
+#' # get IAM role for Lambda execution
+#' library("aws.iam")
+#' id <- get_caller_identity()[["Account"]]
+#' # Note: This role may not work. We recommend copying the ARN of a
+#' # Lambda-capable role from the console once until we're able to more
+#' # smoothly integrate with aws.iam.
+#' role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
+#'
+#' lambda_func <- create_function("helloworld",
+#' func = hello,
+#' handler = "helloworld.handler",
+#' role = role
+#' )
+#'
+#' # invoke function
+#' invoke_function(lambda_func)
#'
-#' # get IAM role for Lambda execution
-#' library("aws.iam")
-#' id <- get_caller_identity()[["Account"]]
-#' role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
-#'
-#' func <- create_function("helloworld", func = hello,
-#' handler = "helloworld.handler",
-#' role = role)
-#'
-#' # invoke function
-#' invoke_function(func)
-#'
-#' # delete function
-#' delete_function(func)
+#' # delete function
+#' delete_function(lambda_func)
#' }
-#' @seealso \code{\link{invoke_function}}, \code{\link{create_function_alias}}, \code{\link{list_functions}}, \code{\link{delete_function}}
+#' @seealso \code{\link{invoke_function}}, \code{\link{create_function_alias}},
+#' \code{\link{list_functions}}, \code{\link{delete_function}}
#' @importFrom base64enc base64encode
#' @importFrom utils zip
#' @export
-create_function <-
-function(name,
- description = name,
- func,
- handler,
- role,
- runtime = c("nodejs6.10", "nodejs4.3", "java8", "python2.7", "dotnetcore1.0", "nodejs4.3-edge"),
- timeout = 3L,
- ...) {
- act <- paste0("/2015-03-31/functions")
- b <- list(Code = list())
- if (grepl("^s3://", func)) {
- x <- substring(func, 6, nchar(func))
- b[["Code"]][["S3Bucket"]] <- substring(x, 1, regexpr("/", x)-1L)
- b[["Code"]][["S3Key"]] <- substring(x, regexpr("/", x)+1L, nchar(x))
+create_function <- function(name,
+ func,
+ handler,
+ role,
+ runtime = c(
+ "nodejs12.x",
+ "nodejs10.x",
+ "java11",
+ "java8",
+ "python3.8",
+ "python3.7",
+ "python3.6",
+ "python2.7",
+ "dotnetcore3.1",
+ "dotnetcore2.1",
+ "go1.x",
+ "ruby2.7",
+ "ruby2.5",
+ "provided"
+ ),
+ timeout = 3L,
+ description,
+ ...) {
+ act <- paste0("/2015-03-31/functions")
+ b <- list(Code = list())
+ if (grepl("^s3://", func)) {
+ x <- substring(func, 6, nchar(func))
+ b[["Code"]][["S3Bucket"]] <- substring(x, 1, regexpr("/", x) - 1L)
+ b[["Code"]][["S3Key"]] <- substring(x, regexpr("/", x) + 1L, nchar(x))
+ } else {
+ if (!file.exists(func)) {
+ stop(sprintf("File '%s' not found!", func))
+ }
+ if (endsWith(func, "zip")) {
+ b[["Code"]] <- list(ZipFile = base64enc::base64encode(func))
} else {
- if (!file.exists(func)) {
- stop(sprintf("File '%s' not found!", func))
- }
- if (endsWith(func, "zip")) {
- b[["Code"]] <- list(ZipFile = base64enc::base64encode(func))
- } else {
- wd <- getwd()
- on.exit(setwd(wd))
- file.copy(from = func, to = tempdir(), overwrite = TRUE)
- tmp <- tempfile(fileext = ".zip")
- on.exit(unlink(tmp), add = TRUE)
- setwd(tempdir())
- utils::zip(zipfile = tmp, files = basename(func))
- setwd(wd)
- b[["Code"]] <- list(ZipFile = base64enc::base64encode(tmp))
- }
+ wd <- getwd()
+ on.exit(setwd(wd))
+ file.copy(from = func, to = tempdir(), overwrite = TRUE)
+ tmp <- tempfile(fileext = ".zip")
+ on.exit(unlink(tmp), add = TRUE)
+ setwd(tempdir())
+ utils::zip(zipfile = tmp, files = basename(func))
+ setwd(wd)
+ b[["Code"]] <- list(ZipFile = base64enc::base64encode(tmp))
}
- b[["FunctionName"]] <- name
+ }
+ b[["FunctionName"]] <- name
+ b[["Handler"]] <- handler
+ b[["Role"]] <- role
+ b[["Runtime"]] <- match.arg(runtime)
+ if (!missing(description)) {
b[["Description"]] <- description
+ }
+ if (timeout != 3) {
+ b[["Timeout"]] <- timeout
+ }
+ r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
+ structure(r, class = "aws_lambda_function")
+}
+
+# update_function_code and update_function_config were smushed into one
+# update_function, but I think that was a bad idea, so I've split them.
+
+#' @rdname create_function
+#' @export
+update_function_code <- function(name, func, ...) {
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/code")
+ b <- list()
+ if (grepl("^s3://", func)) {
+ x <- substring(func, 6, nchar(func))
+ b[["S3Bucket"]] <- substring(x, 1, regexpr("/", x) - 1L)
+ b[["S3Key"]] <- substring(x, regexpr("/", x) + 1L, nchar(x))
+ } else {
+ if (!file.exists(func)) {
+ stop(sprintf("File '%s' not found!", func))
+ }
+ if (endsWith(func, "zip")) {
+ b[["ZipFile"]] <- base64enc::base64encode(func)
+ } else {
+ wd <- getwd()
+ on.exit(setwd(wd))
+ file.copy(from = func, to = tempdir(), overwrite = TRUE)
+ tmp <- tempfile(fileext = ".zip")
+ on.exit(unlink(tmp), add = TRUE)
+ setwd(tempdir())
+ utils::zip(zipfile = tmp, files = basename(func))
+ setwd(wd)
+ b[["ZipFile"]] <- base64enc::base64encode(tmp)
+ }
+ }
+ r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
+ structure(r, class = "aws_lambda_function")
+}
+
+#' @rdname create_function
+#' @export
+update_function_config <- function(name,
+ description,
+ handler,
+ role,
+ runtime = c(
+ "nodejs12.x",
+ "nodejs10.x",
+ "java11",
+ "java8",
+ "python3.8",
+ "python3.7",
+ "python3.6",
+ "python2.7",
+ "dotnetcore3.1",
+ "dotnetcore2.1",
+ "go1.x",
+ "ruby2.7",
+ "ruby2.5",
+ "provided"
+ ),
+ timeout = 3L,
+ ...) {
+ act <- paste0("/2015-03-31/functions/", name, "/configuration")
+ b <- list()
+ if (!missing(description)) {
+ b[["Description"]] <- description
+ }
+ if (!missing(handler)) {
b[["Handler"]] <- handler
+ }
+ if (!missing(role)) {
b[["Role"]] <- role
+ }
+ if (!missing(runtime)) {
b[["Runtime"]] <- match.arg(runtime)
- if (timeout != 3) {
- b[["Timeout"]] <- timeout
- }
- r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
- structure(r, class = "aws_lambda_function")
+ }
+ if (!missing(runtime) && timeout != 3) {
+ b[["Timeout"]] <- timeout
+ }
+ r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
+ structure(r, class = "aws_lambda_function")
}
#' @rdname create_function
#' @export
-update_function <-
-function(name,
- func,
- description,
- handler,
- role,
- runtime = c("nodejs6.10", "nodejs4.3", "java8", "python2.7", "dotnetcore1.0", "nodejs4.3-edge"),
- timeout = 3L,
- ...) {
- name <- get_function_name(name)
- if (!missing(func)) {
- # update code
- act <- paste0("/2015-03-31/functions/", name, "/code")
- b <- list()
- if (grepl("^s3://", func)) {
- x <- substring(func, 6, nchar(func))
- b[["S3Bucket"]] <- substring(x, 1, regexpr("/", x)-1L)
- b[["S3Key"]] <- substring(x, regexpr("/", x)+1L, nchar(x))
- } else {
- if (!file.exists(func)) {
- stop(sprintf("File '%s' not found!", func))
- }
- if (endsWith(func, "zip")) {
- b[["ZipFile"]] <- base64enc::base64encode(func)
- } else {
- wd <- getwd()
- on.exit(setwd(wd))
- file.copy(from = func, to = tempdir(), overwrite = TRUE)
- tmp <- tempfile(fileext = ".zip")
- on.exit(unlink(tmp), add = TRUE)
- setwd(tempdir())
- utils::zip(zipfile = tmp, files = basename(func))
- setwd(wd)
- b[["ZipFile"]] <- base64enc::base64encode(tmp)
- }
- }
- } else {
- act <- paste0("/2015-03-31/functions/", name, "/configuration")
- b <- list()
- if (!missing(description)) {
- b[["Description"]] <- description
- }
- if (!missing(handler)) {
- b[["Handler"]] <- handler
- }
- if (!missing(role)) {
- b[["Role"]] <- role
- }
- if (!missing(runtime)) {
- b[["Runtime"]] <- match.arg(runtime)
- }
- if (!missing(runtime) && timeout != 3) {
- b[["Timeout"]] <- timeout
- }
- }
- r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
- structure(r, class = "aws_lambda_function")
+update_function <- function(name,
+ func,
+ description,
+ handler,
+ role,
+ runtime = c(
+ "nodejs12.x",
+ "nodejs10.x",
+ "java11",
+ "java8",
+ "python3.8",
+ "python3.7",
+ "python3.6",
+ "python2.7",
+ "dotnetcore3.1",
+ "dotnetcore2.1",
+ "go1.x",
+ "ruby2.7",
+ "ruby2.5",
+ "provided"
+ ),
+ timeout = 3L,
+ ...) {
+ if (!missing(func)) {
+ .Deprecated(
+ new = "update_function_code",
+ package = "aws.lambda",
+ msg = paste(
+ "update_function has been replaced by update_function_code and",
+ "update_function_config.",
+ "\nSince you included the func parameter, your code will be executed",
+ "by update_function_code.",
+ "\nupdate_function will be removed in a future version of this",
+ "package."
+ )
+ )
+ update_function_code(name, func, ...)
+ } else {
+ .Deprecated(
+ new = "update_function_code",
+ package = "aws.lambda",
+ msg = paste(
+ "update_function has been replaced by update_function_code and",
+ "update_function_config.",
+ "\nSince you did not include the func parameter,",
+ "your code will be executed by update_function_config.",
+ "\nupdate_function will be removed in a future version of this",
+ "package."
+ )
+ )
+ update_function_config(
+ name, description, handler, role, runtime, timeout, ...
+ )
+ }
+}
+
+#' @rdname create_function
+#' @export
+publish_function_version <- function(name, description, ...) {
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/versions")
+ b <- list()
+ if (!missing(description)) {
+ b[["Description"]] <- description
+ }
+ r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
+ return(r)
}
#' @rdname create_function
#' @export
make_function_version <- function(name, description, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/versions")
- b <- list()
- if (!missing(description)) {
- b[["Description"]] <- description
- }
- r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
- return(r)
+ .Deprecated(
+ new = "publish_function_version",
+ package = "aws.lambda",
+ msg = paste(
+ "make_function_version has been renamed to publish_function_version",
+ "to better match the api.",
+ "\nmake_function_version will be removed in a future version",
+ "of this package."
+ )
+ )
+ publish_function_version(name = name, description = description, ...)
}
diff --git a/R/functions.R b/R/functions.R
index dffbf2e..18e83c2 100644
--- a/R/functions.R
+++ b/R/functions.R
@@ -7,81 +7,96 @@
#' @param n An integer specifying the number of results to return.
#' @template dots
#' @return An object of class \dQuote{aws_lambda_function}.
-#' @details \code{list_functions} lists all functions. \code{get_function} retrieves a specific function and \code{get_function_versions} retrieves all versions of that function. \code{get_function_configuration} returns the configuration details used when creating or updating the function. \code{delete_function} deletes a function, if you have permission to do so.
+#' @details \code{list_functions} lists all functions. \code{get_function}
+#' retrieves a specific function and \code{list_function_versions} retrieves
+#' all versions of that function. \code{get_function_policy} returns the
+#' resource-based IAM policy for a function. \code{delete_function} deletes a
+#' function, if you have permission to do so.
#' @references
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html}{API Reference: GetFunction}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListVersionsByFunction.html}{API Reference: ListVersionsByFunction}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListFunctions.html}{API Reference: ListFunctions}
-#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetFunctionConfiguration.html}{API Reference: GetFunctionConfiguration}
-#' @seealso \code{\link{create_function}}, \code{\link{update_function}}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html}{API
+#' Reference: GetFunction}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListVersionsByFunction.html}{API
+#' Reference: ListVersionsByFunction}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListFunctions.html}{API
+#' Reference: ListFunctions}
+#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetPolicy.html}{API
+#' Reference: GetPolicy}
+#' @seealso \code{\link{create_function}}, \code{\link{update_function_code}},
+#' \code{\link{update_function_config}}
#' @export
get_function <- function(name, qualifier, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name)
- query <- list()
- if (!missing(qualifier)) {
- query[["Qualifier"]] <- qualifier
- }
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- structure(c(r[["Configuration"]], list(Code = r[["Code"]], Tags = r[["Tags"]])),
- class = "aws_lambda_function")
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name)
+ query <- list()
+ if (!missing(qualifier)) {
+ query[["Qualifier"]] <- qualifier
+ }
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ structure(
+ c(r[["Configuration"]], list(Code = r[["Code"]], Tags = r[["Tags"]])),
+ class = "aws_lambda_function"
+ )
}
#' @rdname functions
#' @export
list_functions <- function(marker, n, ...) {
- act <- paste0("/2015-03-31/functions")
- query <- list()
- if (!missing(marker)) {
- query[["Marker"]] <- marker
- }
- if (!missing(n)) {
- query[["MaxItems"]] <- n
- }
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- structure(lapply(r[["Functions"]], `class<-`, "aws_lambda_function"),
- marker = r[["NextMarker"]])
+ act <- paste0("/2015-03-31/functions")
+ query <- list()
+ if (!missing(marker)) {
+ query[["Marker"]] <- marker
+ }
+ if (!missing(n)) {
+ query[["MaxItems"]] <- n
+ }
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ structure(
+ lapply(r[["Functions"]], `class<-`, "aws_lambda_function"),
+ marker = r[["NextMarker"]]
+ )
}
#' @rdname functions
#' @export
list_function_versions <- function(name, marker, n, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/versions")
- query <- list()
- if (!missing(marker)) {
- query[["Marker"]] <- marker
- }
- if (!missing(n)) {
- query[["MaxItems"]] <- n
- }
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- structure(lapply(r[["Versions"]], `class<-`, "aws_lambda_function"),
- marker = r[["NextMarker"]])
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/versions")
+ query <- list()
+ if (!missing(marker)) {
+ query[["Marker"]] <- marker
+ }
+ if (!missing(n)) {
+ query[["MaxItems"]] <- n
+ }
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ structure(
+ lapply(r[["Versions"]], `class<-`, "aws_lambda_function"),
+ marker = r[["NextMarker"]]
+ )
}
#' @rdname functions
#' @export
delete_function <- function(name, qualifier, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/aliases/", name)
- query <- list()
- if (!missing(qualifier)) {
- query[["Qualifier"]] <- qualifier
- }
- r <- lambdaHTTP(verb = "DELETE", action = act, query = query, ...)
- return(TRUE)
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name)
+ query <- list()
+ if (!missing(qualifier)) {
+ query[["Qualifier"]] <- qualifier
+ }
+ r <- lambdaHTTP(verb = "DELETE", action = act, query = query, ...)
+ return(TRUE)
}
#' @rdname functions
#' @export
get_function_policy <- function(name, qualifier, ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/policy")
- query <- list()
- if (!missing(qualifier)) {
- query[["Qualifier"]] <- qualifier
- }
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- return(r)
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/policy")
+ query <- list()
+ if (!missing(qualifier)) {
+ query[["Qualifier"]] <- qualifier
+ }
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ return(r)
}
diff --git a/R/http.R b/R/http.R
index 942b65e..e1a0eaf 100644
--- a/R/http.R
+++ b/R/http.R
@@ -1,135 +1,131 @@
#' @title Execute AWS Lambda API Request
-#' @description This is the workhorse function to execute calls to the Lambda API.
+#' @description This is the workhorse function to execute calls to the Lambda
+#' API.
#' @param verb A character string specifying the HTTP verb to use.
#' @param action A character string specifying the API version and endpoint.
-#' @param query An optional named list containing query string parameters and their character values.
+#' @param query An optional named list containing query string parameters and
+#' their character values.
#' @param headers A list of headers to pass to the HTTP request.
#' @param body The HTTP request body.
-#' @param verbose A logical indicating whether to be verbose. Default is given by \code{options("verbose")}.
-#' @param region A character string specifying an AWS region. See \code{\link[aws.signature]{locate_credentials}}.
-#' @param key A character string specifying an AWS Access Key. See \code{\link[aws.signature]{locate_credentials}}.
-#' @param secret A character string specifying an AWS Secret Key. See \code{\link[aws.signature]{locate_credentials}}.
-#' @param session_token Optionally, a character string specifying an AWS temporary Session Token to use in signing a request. See \code{\link[aws.signature]{locate_credentials}}.
-#' @param \dots Additional arguments passed to \code{\link[httr]{GET}} or another httr request function.
-#' @return If successful, a named list. Otherwise, a data structure of class \dQuote{aws-error} containing any error message(s) from AWS and information about the request attempt.
-#' @details This function constructs and signs an AWS Lambda API request and returns the results thereof, or relevant debugging information in the case of error.
+#' @param verbose A logical indicating whether to be verbose. Default is given
+#' by \code{options("verbose")}.
+#' @param region A character string specifying an AWS region. See
+#' \code{\link[aws.signature]{locate_credentials}}.
+#' @param key A character string specifying an AWS Access Key. See
+#' \code{\link[aws.signature]{locate_credentials}}.
+#' @param secret A character string specifying an AWS Secret Key. See
+#' \code{\link[aws.signature]{locate_credentials}}.
+#' @param session_token Optionally, a character string specifying an AWS
+#' temporary Session Token to use in signing a request. See
+#' \code{\link[aws.signature]{locate_credentials}}.
+#' @param \dots Additional arguments passed to \code{\link[httr]{GET}} or
+#' another httr request function.
+#' @return If successful, a named list. Otherwise, a data structure of class
+#' \dQuote{aws-error} containing any error message(s) from AWS and information
+#' about the request attempt.
+#' @details This function constructs and signs an AWS Lambda API request and
+#' returns the results thereof, or relevant debugging information in the case
+#' of error.
#' @author Thomas J. Leeper
-#' @seealso \code{\link{get_lambda_account}}, which works well as a hello world for the package
-#' @import httr
-#' @importFrom utils str
-#' @importFrom jsonlite fromJSON toJSON
-#' @importFrom aws.signature signature_v4_auth
+#' @seealso \code{\link{get_lambda_account}}, which works well as a hello world
+#' for the package
+#' @importFrom httr GET DELETE PUT POST add_headers http_error headers
+#' stop_for_status content
+#' @importFrom aws.signature locate_credentials signature_v4_auth
+#' @importFrom jsonlite toJSON
#' @export
-lambdaHTTP <-
-function(
- verb = "GET",
- action,
- query = list(),
- headers = list(),
- body = NULL,
- verbose = getOption("verbose", FALSE),
- region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"),
- key = NULL,
- secret = NULL,
- session_token = NULL,
- ...
-) {
- # locate and validate credentials
- credentials <- locate_credentials(key = key, secret = secret, session_token = session_token, region = region, verbose = verbose)
- key <- credentials[["key"]]
- secret <- credentials[["secret"]]
- session_token <- credentials[["session_token"]]
- region <- credentials[["region"]]
-
- # generate request signature
- d_timestamp <- format(Sys.time(), "%Y%m%dT%H%M%SZ", tz = "UTC")
- url <- paste0("https://lambda.", region, ".amazonaws.com", action)
-
- if (length(body)) {
- if (is.list(body)) {
- body <- jsonlite::toJSON(body, auto_unbox = TRUE)
- }
+lambdaHTTP <- function(verb = "GET",
+ action,
+ query = NULL,
+ headers = list(),
+ body = NULL,
+ verbose = getOption("verbose", FALSE),
+ region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"),
+ key = NULL,
+ secret = NULL,
+ session_token = NULL,
+ ...) {
+ # locate and validate credentials
+ credentials <- aws.signature::locate_credentials(
+ key = key, secret = secret, session_token = session_token,
+ region = region, verbose = verbose
+ )
+ key <- credentials[["key"]]
+ secret <- credentials[["secret"]]
+ session_token <- credentials[["session_token"]]
+ region <- credentials[["region"]]
+
+ # generate request signature
+ d_timestamp <- format(Sys.time(), "%Y%m%dT%H%M%SZ", tz = "UTC")
+ url <- paste0("https://lambda.", region, ".amazonaws.com", action)
+
+ if (length(body)) {
+ if (is.list(body)) {
+ body <- jsonlite::toJSON(body, auto_unbox = TRUE)
+ }
+ } else {
+ body <- NULL
+ }
+
+ query <- if (length(query)) query else NULL
+
+ headers[["host"]] <- paste0("lambda.", region, ".amazonaws.com")
+ headers[["x-amz-date"]] <- d_timestamp
+ Sig <- aws.signature::signature_v4_auth(
+ datetime = d_timestamp,
+ region = region,
+ service = "lambda",
+ verb = verb,
+ action = action,
+ query_args = query,
+ canonical_headers = headers,
+ request_body = body %||% "",
+ key = key,
+ secret = secret,
+ session_token = session_token,
+ verbose = verbose
+ )
+ headers[["x-amz-content-sha256"]] <- Sig$BodyHash
+ headers[["Authorization"]] <- Sig[["SignatureHeader"]]
+ if (!is.null(session_token) && session_token != "") {
+ headers[["x-amz-security-token"]] <- session_token
+ }
+ H <- do.call(httr::add_headers, headers)
+
+ # execute request
+ if (verb == "GET") {
+ r <- httr::GET(url, H, query = query, ...)
+ } else if (verb == "DELETE") {
+ r <- httr::DELETE(url, H, query = query, ...)
+ } else if (verb == "PUT") {
+ if (is.null(body)) {
+ r <- httr::PUT(url, H, query = query, ...)
} else {
- body <- NULL
+ r <- httr::PUT(url, H, query = query, body = body, encode = "json", ...)
}
-
- headers[["host"]] <- paste0("lambda.",region,".amazonaws.com")
- headers[["x-amz-date"]] <- d_timestamp
- Sig <- signature_v4_auth(
- datetime = d_timestamp,
- region = region,
- service = "lambda",
- verb = verb,
- action = action,
- query_args = if (length(query)) query else NULL,
- canonical_headers = if (length(headers)) headers else NULL,
- request_body = if (is.null(body)) "" else body,
- key = key,
- secret = secret,
- session_token = session_token,
- verbose = verbose)
- headers[["x-amz-content-sha256"]] <- Sig$BodyHash
- headers[["Authorization"]] <- Sig[["SignatureHeader"]]
- if (!is.null(session_token) && session_token != "") {
- headers[["x-amz-security-token"]] <- session_token
+ } else if (verb == "POST") {
+ if (is.null(body)) {
+ r <- httr::POST(url, H, query = query, ...)
+ } else {
+ r <- httr::POST(url, H, query = query, body = body, encode = "json", ...)
}
- H <- do.call("add_headers", headers)
-
- # execute request
- if (verb == "GET") {
- if (length(query)) {
- r <- GET(url, H, query = query, ...)
- } else {
- r <- GET(url, H, ...)
- }
- } else if (verb == "DELETE") {
- if (length(query)) {
- r <- DELETE(url, H, query = query, ...)
- } else {
- r <- DELETE(url, H, ...)
- }
- } else if (verb == "PUT") {
- if (length(query)) {
- if (is.null(body)) {
- r <- PUT(url, H, query = query, ...)
- } else {
- r <- PUT(url, H, query = query, body = body, encode = "json", ...)
- }
- } else {
- if (is.null(body)) {
- r <- PUT(url, H, ...)
- } else {
- r <- PUT(url, H, body = body, encode = "json", ...)
- }
- }
- } else if (verb == "POST") {
- if (length(query)) {
- if (is.null(body)) {
- r <- POST(url, H, query = query, ...)
- } else {
- r <- POST(url, H, query = query, body = body, encode = "json", ...)
- }
- } else {
- if (is.null(body)) {
- r <- POST(url, H, ...)
- } else {
- r <- POST(url, H, body = body, encode = "json", ...)
- }
- }
- }
-
- if (http_error(r)) {
- h <- headers(r)
- content <- try(content(r, "parsed", encoding = "UTF-8"), silent = TRUE)
- if (!inherits(content, "try-error")) {
- r[["content"]] <- content
- }
- out <- structure(r, headers = h, class = "aws_error")
- attr(out, "request_canonical") <- Sig$CanonicalRequest
- attr(out, "request_string_to_sign") <- Sig$StringToSign
- attr(out, "request_signature") <- Sig$SignatureHeader
- print(out)
- stop_for_status(r)
+ }
+
+ if (httr::http_error(r)) {
+ h <- httr::headers(r)
+ content <- try(
+ httr::content(r, "parsed", encoding = "UTF-8"),
+ silent = TRUE
+ )
+ if (!inherits(content, "try-error")) {
+ r[["content"]] <- content
}
- content(r, "parsed", encoding = "UTF-8")
+ out <- structure(r, headers = h, class = "aws_error")
+ attr(out, "request_canonical") <- Sig$CanonicalRequest
+ attr(out, "request_string_to_sign") <- Sig$StringToSign
+ attr(out, "request_signature") <- Sig$SignatureHeader
+ print(out)
+ httr::stop_for_status(r)
+ }
+ httr::content(r, "parsed", encoding = "UTF-8")
}
diff --git a/R/invoke.R b/R/invoke.R
index c9da140..4de54aa 100644
--- a/R/invoke.R
+++ b/R/invoke.R
@@ -2,30 +2,40 @@
#' @description Invoke a lambda function
#' @template name
#' @template qualifier
-#' @param payload Optionally, the JSON body to send to the function.
-#' @param type A character string specifying one of: (1) \dQuote{Event} (asynchronous execution), (2) \dQuote{RequestResponse} (the default), or (3) \dQuote{DryRun} to test the function without executing it.
+#' @param payload Optionally, a list of parameters to send in the JSON body to
+#' the function.
+#' @param type A character string specifying one of: (1) \dQuote{Event}
+#' (asynchronous execution), (2) \dQuote{RequestResponse} (the default), or
+#' (3) \dQuote{DryRun} to test the function without executing it.
#' @param log A character string to control log response.
#' @template dots
-#' @seealso \code{\link{create_function}}, \code{\link{list_functions}},
+#' @seealso \code{\link{create_function}}, \code{\link{list_functions}},
#' @export
-invoke_function <-
-function(name, qualifier, payload = NULL,
- type = c("RequestResponse", "Event", "DryRun"),
- log = c("None", "Tail"),
- #context,
- ...) {
- name <- get_function_name(name)
- act <- paste0("/2015-03-31/functions/", name, "/invocations")
- query <- list()
- if (!missing(qualifier)) {
- query[["Qualifier"]] <- qualifier
- }
- h <- list("X-Amz-Invocation-Type" = match.arg(type),
- "X-Amz-Log-Type" = match.arg(log))#,
- #"X-Amz-Client-Context" = context)
- r <- lambdaHTTP(verb = "POST", action = act,
- headers = h,
- query = query,
- body = payload, ...)
- return(r)
+invoke_function <- function(name,
+ qualifier,
+ payload = NULL,
+ type = c("RequestResponse", "Event", "DryRun"),
+ log = c("None", "Tail"),
+ # context,
+ ...) {
+ name <- get_function_name(name)
+ act <- paste0("/2015-03-31/functions/", name, "/invocations")
+ query <- list()
+ if (!missing(qualifier)) {
+ query[["Qualifier"]] <- qualifier
+ }
+ h <- list(
+ "X-Amz-Invocation-Type" = match.arg(type),
+ "X-Amz-Log-Type" = match.arg(log) # ,
+ # "X-Amz-Client-Context" = context
+ )
+ r <- lambdaHTTP(
+ verb = "POST",
+ action = act,
+ headers = h,
+ query = query,
+ body = payload,
+ ...
+ )
+ return(r)
}
diff --git a/R/permissions.R b/R/permissions.R
index fe6f72d..fea8227 100644
--- a/R/permissions.R
+++ b/R/permissions.R
@@ -1,13 +1,17 @@
+# These functions are not yet exported, and I don't think they're pointing to a
+# valid endpoint (they need a date before /functions/). I'm not deleting yet,
+# but I also have not verified these.
+
add_permission <- function(func, qualifier, ...) {
- act <- paste0("/functions/", func, "/policy")
- query <- list(Qualifier = qualifier)
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- return(r)
+ act <- paste0("/functions/", func, "/policy")
+ query <- list(Qualifier = qualifier)
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ return(r)
}
remove_permission <- function(func, qualifier, id, ...) {
- act <- paste0("/functions/", func, "/policy/", id)
- query <- list(Qualifier = qualifier)
- r <- lambdaHTTP(verb = "DELETE", action = act, query = query, ...)
- return(r)
+ act <- paste0("/functions/", func, "/policy/", id)
+ query <- list(Qualifier = qualifier)
+ r <- lambdaHTTP(verb = "DELETE", action = act, query = query, ...)
+ return(r)
}
diff --git a/R/source_mapping.R b/R/source_mapping.R
index f07fccb..b24bb6d 100644
--- a/R/source_mapping.R
+++ b/R/source_mapping.R
@@ -1,30 +1,37 @@
+# The endpoints ("act") need to be updated on these before they're exported.
+
create_eventsource <- function(body, ...) {
- act <- paste0("/event-source-mapping")
- r <- lambdaHTTP(verb = "POST", action = act, body = body, ...)
- return(r)
+ act <- paste0("/event-source-mapping")
+ r <- lambdaHTTP(verb = "POST", action = act, body = body, ...)
+ return(r)
}
update_eventsource <- function(source, body, ...) {
- act <- paste0("/event-source-mapping/", source)
- r <- lambdaHTTP(verb = "PUT", action = act, body = body, ...)
- return(r)
+ act <- paste0("/event-source-mapping/", source)
+ r <- lambdaHTTP(verb = "PUT", action = act, body = body, ...)
+ return(r)
}
delete_eventsource <- function(source, ...) {
- act <- paste0("/event-source-mapping/", source)
- r <- lambdaHTTP(verb = "DELETE", action = act, ...)
- return(r)
+ act <- paste0("/event-source-mapping/", source)
+ r <- lambdaHTTP(verb = "DELETE", action = act, ...)
+ return(r)
}
get_eventsource <- function(source, ...) {
- act <- paste0("/event-source-mapping/", source)
- r <- lambdaHTTP(verb = "GET", action = act, ...)
- return(r)
+ act <- paste0("/event-source-mapping/", source)
+ r <- lambdaHTTP(verb = "GET", action = act, ...)
+ return(r)
}
list_eventsources <- function(stream, func, marker, n, ...) {
- act <- paste0("/event-source-mappings/")
- query <- list(EventSourceArn = stream, FunctionName = func, Marker = marker, MaxItems = n)
- r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
- return(r)
+ act <- paste0("/event-source-mappings/")
+ query <- list(
+ EventSourceArn = stream,
+ FunctionName = func,
+ Marker = marker,
+ MaxItems = n
+ )
+ r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
+ return(r)
}
diff --git a/R/utils.R b/R/utils.R
index b06a981..6066fac 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -1,6 +1,6 @@
print.aws_lambda_function <- function(x, ...) {
- print(str(x))
- return(invisible(x))
+ print(utils::str(x))
+ return(invisible(x))
}
#' @rdname get_function_name
@@ -10,17 +10,30 @@ print.aws_lambda_function <- function(x, ...) {
#' @param \dots Additional arguments passed to methods
#' @export
get_function_name <- function(x, ...) {
- UseMethod("get_function_name")
+ UseMethod("get_function_name")
}
#' @rdname get_function_name
#' @export
get_function_name.character <- function(x, ...) {
- x
+ x
}
#' @rdname get_function_name
#' @export
get_function_name.aws_lambda_function <- function(x, ...) {
- x[["FunctionName"]]
+ x[["FunctionName"]]
+}
+
+#' Default value for `NULL`
+#'
+#' This infix function makes it easy to replace `NULL`s with a default
+#' value. It's inspired by the way that Ruby's or operation (`||`)
+#' works. Copied from the rlang package.
+#'
+#' @param x,y If `x` is NULL, will return `y`; otherwise returns `x`.
+#' @keywords internal
+#' @name op-null-default
+`%||%` <- function(x, y) {
+ if (is.null(x)) y else x
}
diff --git a/README.Rmd b/README.Rmd
index 8ae22c4..0b37e1a 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -1,12 +1,47 @@
-# AWS Lambda Client Package
+---
+output: github_document
+---
+
+
+
+```{r, include = FALSE}
+knitr::opts_chunk$set(
+ collapse = TRUE,
+ comment = "#>",
+ fig.path = "man/figures/README-",
+ out.width = "100%"
+)
+```
+
+# aws.lambda
-**aws.lambda** is a simple client package for the [Amazon Web Services (AWS) Lambda API](https://aws.amazon.com/lambda/).
+
+[](https://CRAN.R-project.org/package=aws.lambda)
+
+
+**aws.lambda** is a client package for the [Amazon Web Services (AWS) Lambda API](https://aws.amazon.com/lambda/).
+
+## Installation
+
+You can install the released version of aws.lambda from [CRAN](https://CRAN.R-project.org) with:
+
+``` r
+install.packages("aws.lambda")
+```
+
+And the development version from [GitHub](https://github.com/) with:
+
+``` r
+# install.packages("remotes")
+remotes::install_github("cloudyr/aws.lambda")
+```
+## API Keys
To use the package, you will need an AWS account and to enter your credentials into R. Your keypair can be generated on the [IAM Management Console](https://aws.amazon.com/) under the heading *Access Keys*. Note that you only have access to your secret key once. After it is generated, you need to save it in a secure location. New keypairs can be generated at any time if yours has been lost, stolen, or forgotten. The [**aws.iam** package](https://github.com/cloudyr/aws.iam) profiles tools for working with IAM, including creating roles, users, groups, and credentials programmatically; it is not needed to *use* IAM credentials.
-A detailed description of how credentials can be specified is provided at: https://github.com/cloudyr/aws.signature/. The easiest way is to simply set environment variables on the command line prior to starting R or via an `Renviron.site` or `.Renviron` file, which are used to set environment variables in R during startup (see `? Startup`). They can be also set within R:
+A detailed description of how credentials can be specified is provided at: https://github.com/cloudyr/aws.signature/. The easiest way is to simply set environment variables on the command line prior to starting R or via an `Renviron.site` or `.Renviron` file, which are used to set environment variables in R during startup (see `? Startup`). They can also be set within R:
-```R
+```{r eval=FALSE}
Sys.setenv("AWS_ACCESS_KEY_ID" = "mykey",
"AWS_SECRET_ACCESS_KEY" = "mysecretkey",
"AWS_DEFAULT_REGION" = "us-east-1",
@@ -17,7 +52,7 @@ Sys.setenv("AWS_ACCESS_KEY_ID" = "mykey",
The package is still under rapid development, but a simple and literal "Hello, world!" example can be found by doing the following:
-```{r}
+```{r eval=FALSE}
library("aws.lambda")
# get list of all current functions
@@ -26,7 +61,8 @@ funclist <- sapply(list_functions(), get_function_name)
# 'hello world!' example code
hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
-# get IAM role for Lambda execution
+# get IAM role for Lambda execution. Note: This is not currently sufficient, and
+# will be updated in an upcoming update to the package.
requireNamespace("aws.iam")
id <- aws.iam::get_caller_identity()[["Account"]]
role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
@@ -42,15 +78,15 @@ if (!"helloworld" %in% funclist) {
invoke_function(func)
```
-```{r, echo=FALSE, results="hide"}
+```{r eval=FALSE}
delete_function(func)
```
Obviously this is a trivial lambda function, but the point is that basically anything (in node.js, python, or java) could be written into the "deployment package" and called in this way.
-A sligtly more complex example shows how to pass arguments to the lambda function via the function's `payload` and examine the response.
+A slightly more complex example shows how to pass arguments to the lambda function via the function's `payload` and examine the response.
-```{r}
+```{r eval=FALSE}
# example function that performs simple addition
plus <- system.file("templates", "plus.js", package = "aws.lambda")
@@ -72,33 +108,9 @@ invoke_function(func, payload = list(a = -5, b = 7))
```
-```{r, echo=FALSE, results="hide"}
+```{r eval=FALSE}
delete_function(func)
```
-## Installation
-
-[](https://cran.r-project.org/package=aws.lambda)
-
-[](https://travis-ci.org/cloudyr/aws.lambda)
-[](https://codecov.io/github/cloudyr/aws.lambda?branch=master)
-
-This package is not yet on CRAN. To install the latest development version you can install from the cloudyr drat repository:
-
-```R
-# latest stable version
-install.packages("aws.s3", repos = c("cloudyr" = "http://cloudyr.github.io/drat"))
-```
-
-To install the latest development version from GitHub, run the following:
-
-```R
-if (!require("remotes")){
- install.packages("remotes")
-}
-remotes::install_github("cloudyr/aws.lambda")
-```
-
-
---
[](https://github.com/cloudyr)
diff --git a/README.html b/README.html
deleted file mode 100644
index ada811e..0000000
--- a/README.html
+++ /dev/null
@@ -1,75 +0,0 @@
-AWS Lambda Client Package
-aws.lambda is a simple client package for the Amazon Web Services (AWS) Lambda API.
-To use the package, you will need an AWS account and enter your credentials into R. Your keypair can be generated on the IAM Management Console under the heading Access Keys. Note that you only have access to your secret key once. After it is generated, you need to save it in a secure location. New keypairs can be generated at any time if yours has been lost, stolen, or forgotten.
-By default, all cloudyr packages look for the access key ID and secret access key in environment variables. You can also use this to specify a default region or a temporary "session token". For example:
-Sys.setenv("AWS_ACCESS_KEY_ID" = "mykey",
- "AWS_SECRET_ACCESS_KEY" = "mysecretkey",
- "AWS_DEFAULT_REGION" = "us-east-1",
- "AWS_SESSION_TOKEN" = "mytoken")
-These can alternatively be set on the command line prior to starting R or via an Renviron.site or .Renviron file, which are used to set environment variables in R during startup (see ? Startup).
-If you work with multiple AWS accounts, another option that is consistent with other Amazon SDKs is to create a centralized ~/.aws/credentials file, containing credentials for multiple accounts. You can then use credentials from this file on-the-fly by simply doing:
-# use your 'default' account credentials
-aws.signature::use_credentials()
-
-# use an alternative credentials profile
-aws.signature::use_credentials(profile = "bob")
-Temporary session tokens are stored in environment variable AWS_SESSION_TOKEN (and will be stored there by the use_credentials() function). The aws.iam package provides an R interface to IAM roles and the generation of temporary session tokens via the security token service (STS).
-Code Examples
-The package is still under rapid development, but a simple and literal "Hello, world!" example can be found by doing the following:
-library("aws.lambda")
-
-# get list of all current functions
-funclist <- sapply(list_functions(), get_function_name)
-
-# 'hello world!' example code
-hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
-
-# get IAM role for Lambda execution
-requireNamespace("aws.iam")
-## Loading required namespace: aws.iam
-id <- aws.iam::get_caller_identity()[["Account"]]
-role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
-
-if (!"helloworld" %in% funclist) {
- func <- create_function(name = "helloworld", func = hello,
- handler = "helloworld.handler", role = role)
-} else {
- func <- get_function("helloworld")
-}
-
-# invoke function
-invoke_function(func)
-## [1] "Hello, world!"
-Obviously this is a trivial lambda function, but the point is that basically anything (in node.js, python, or java) could be written into the "deployment package" and called in this way. A sligtly more complex example shows how to pass arguments to the lambda function and examine the response.
-# example function that performs addition
-plus <- system.file("templates", "plus.js", package = "aws.lambda")
-
-# get IAM role for Lambda execution
-requireNamespace("aws.iam")
-id <- aws.iam::get_caller_identity()[["Account"]]
-role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
-
-if (!"plus" %in% funclist) {
- func <- create_function(name = "plus", func = plus,
- handler = "plus.handler", role = role)
-} else {
- func <- get_function("plus")
-}
-
-# invoke function
-invoke_function(func, payload = list(a = 2, b = 3))
-## [1] 5
-invoke_function(func, payload = list(a = -5, b = 7))
-## [1] 2
-Installation
-

-This package is not yet on CRAN. To install the latest development version you can install from the cloudyr drat repository:
-# latest stable version
-install.packages("aws.s3", repos = c("cloudyr" = "http://cloudyr.github.io/drat"))
-To install the latest development version from GitHub, run the following:
-if (!require("ghit")){
- install.packages("ghit")
-}
-ghit::install_github("cloudyr/aws.lambda")
-
-
diff --git a/README.md b/README.md
index 6e91647..e4dc222 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,53 @@
-# AWS Lambda Client Package
-**aws.lambda** is a simple client package for the [Amazon Web Services (AWS) Lambda API](https://aws.amazon.com/lambda/).
+
-To use the package, you will need an AWS account and to enter your credentials into R. Your keypair can be generated on the [IAM Management Console](https://aws.amazon.com/) under the heading *Access Keys*. Note that you only have access to your secret key once. After it is generated, you need to save it in a secure location. New keypairs can be generated at any time if yours has been lost, stolen, or forgotten. The [**aws.iam** package](https://github.com/cloudyr/aws.iam) profiles tools for working with IAM, including creating roles, users, groups, and credentials programmatically; it is not needed to *use* IAM credentials.
+# aws.lambda
-A detailed description of how credentials can be specified is provided at: https://github.com/cloudyr/aws.signature/. The easiest way is to simply set environment variables on the command line prior to starting R or via an `Renviron.site` or `.Renviron` file, which are used to set environment variables in R during startup (see `? Startup`). They can be also set within R:
+
-```R
+[](https://CRAN.R-project.org/package=aws.lambda)
+
+
+**aws.lambda** is a client package for the [Amazon Web Services (AWS)
+Lambda API](https://aws.amazon.com/lambda/).
+
+## Installation
+
+You can install the released version of aws.lambda from
+[CRAN](https://CRAN.R-project.org) with:
+
+``` r
+install.packages("aws.lambda")
+```
+
+And the development version from [GitHub](https://github.com/) with:
+
+``` r
+# install.packages("remotes")
+remotes::install_github("cloudyr/aws.lambda")
+```
+
+## API Keys
+
+To use the package, you will need an AWS account and to enter your
+credentials into R. Your keypair can be generated on the [IAM Management
+Console](https://aws.amazon.com/) under the heading *Access Keys*. Note
+that you only have access to your secret key once. After it is
+generated, you need to save it in a secure location. New keypairs can be
+generated at any time if yours has been lost, stolen, or forgotten. The
+[**aws.iam** package](https://github.com/cloudyr/aws.iam) profiles tools
+for working with IAM, including creating roles, users, groups, and
+credentials programmatically; it is not needed to *use* IAM credentials.
+
+A detailed description of how credentials can be specified is provided
+at: . The easiest way is to
+simply set environment variables on the command line prior to starting R
+or via an `Renviron.site` or `.Renviron` file, which are used to set
+environment variables in R during startup (see `? Startup`). They can
+also be set within R:
+
+``` r
Sys.setenv("AWS_ACCESS_KEY_ID" = "mykey",
"AWS_SECRET_ACCESS_KEY" = "mysecretkey",
"AWS_DEFAULT_REGION" = "us-east-1",
@@ -15,10 +56,10 @@ Sys.setenv("AWS_ACCESS_KEY_ID" = "mykey",
## Code Examples
-The package is still under rapid development, but a simple and literal "Hello, world!" example can be found by doing the following:
+The package is still under rapid development, but a simple and literal
+“Hello, world\!” example can be found by doing the following:
-
-```r
+``` r
library("aws.lambda")
# get list of all current functions
@@ -27,15 +68,9 @@ funclist <- sapply(list_functions(), get_function_name)
# 'hello world!' example code
hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
-# get IAM role for Lambda execution
+# get IAM role for Lambda execution. Note: This is not currently sufficient, and
+# will be updated in an upcoming update to the package.
requireNamespace("aws.iam")
-```
-
-```
-## Loading required namespace: aws.iam
-```
-
-```r
id <- aws.iam::get_caller_identity()[["Account"]]
role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
@@ -50,18 +85,18 @@ if (!"helloworld" %in% funclist) {
invoke_function(func)
```
+``` r
+delete_function(func)
```
-## [1] "Hello, world!"
-```
-
-
-Obviously this is a trivial lambda function, but the point is that basically anything (in node.js, python, or java) could be written into the "deployment package" and called in this way.
+Obviously this is a trivial lambda function, but the point is that
+basically anything (in node.js, python, or java) could be written into
+the “deployment package” and called in this way.
-A sligtly more complex example shows how to pass arguments to the lambda function via the function's `payload` and examine the response.
+A slightly more complex example shows how to pass arguments to the
+lambda function via the function’s `payload` and examine the response.
-
-```r
+``` r
# example function that performs simple addition
plus <- system.file("templates", "plus.js", package = "aws.lambda")
@@ -79,46 +114,14 @@ if (!"plus" %in% funclist) {
# invoke function
invoke_function(func, payload = list(a = 2, b = 3))
-```
-
-```
-## [1] 5
-```
-
-```r
invoke_function(func, payload = list(a = -5, b = 7))
```
-```
-## [1] 2
-```
-
-
-
-
-## Installation
-
-[](https://cran.r-project.org/package=aws.lambda)
-
-[](https://travis-ci.org/cloudyr/aws.lambda)
-[](https://codecov.io/github/cloudyr/aws.lambda?branch=master)
-
-This package is not yet on CRAN. To install the latest development version you can install from the cloudyr drat repository:
-
-```R
-# latest stable version
-install.packages("aws.s3", repos = c("cloudyr" = "http://cloudyr.github.io/drat"))
-```
-
-To install the latest development version from GitHub, run the following:
-
-```R
-if (!require("ghit")){
- install.packages("ghit")
-}
-ghit::install_github("cloudyr/aws.lambda")
+``` r
+delete_function(func)
```
+-----
----
-[](https://github.com/cloudyr)
+[](https://github.com/cloudyr)
diff --git a/cran-comments.md b/cran-comments.md
new file mode 100644
index 0000000..e5ca9ae
--- /dev/null
+++ b/cran-comments.md
@@ -0,0 +1,11 @@
+## Test environments
+* local R installation, R 3.6.3
+* ubuntu 16.04 (on travis-ci), R 3.6.3
+* win-builder (devel)
+
+## R CMD check results
+
+0 errors | 0 warnings | 1 note
+
+* This is a new release.
+** This isn't really new, but I'm taking over an orphaned package.
diff --git a/inst/CITATION b/inst/CITATION
deleted file mode 100644
index 1109e79..0000000
--- a/inst/CITATION
+++ /dev/null
@@ -1,13 +0,0 @@
-citHeader("To cite package 'aws.lambda' in publications use:")
- year <- sub(".*(2[[:digit:]]{3})-.*", "\\1", meta$Date, perl = TRUE)
- vers <- paste("R package version", meta$Version)
- citEntry(entry="Manual",
- title = "aws.lambda: AWS Lambda Client Package",
- author = personList(as.person("Thomas J. Leeper")),
- year = year,
- note = vers,
- textVersion =
- paste("Thomas J. Leeper (",
- year,
- "). aws.lambda: AWS Lambda Client Package. ",
- vers, ".", sep=""))
diff --git a/man/alias.Rd b/man/alias.Rd
index 6ed9e70..4c42311 100644
--- a/man/alias.Rd
+++ b/man/alias.Rd
@@ -8,9 +8,9 @@
\alias{list_function_aliases}
\title{Alias Management}
\usage{
-create_function_alias(name, alias, description, version, ...)
+create_function_alias(name, alias, version, description, ...)
-update_function_alias(name, alias, description, version, ...)
+update_function_alias(name, alias, version, description, ...)
delete_function_alias(name, alias, ...)
@@ -23,9 +23,11 @@ list_function_aliases(name, version, marker, n, ...)
\item{alias}{A character string specifying a function alias}
-\item{description}{Optionally, a max 256-character description of the function for your own use.}
+\item{version}{A character string specifying a function version to associate
+with this alias.}
-\item{version}{A character string specifying a function version}
+\item{description}{Optionally, a max 256-character description of the
+function for your own use.}
\item{\dots}{Additional arguments passed to \code{\link{lambdaHTTP}}.}
@@ -40,14 +42,25 @@ An object of class \dQuote{aws_lambda_function}.
List, create, update, and delete function aliases
}
\details{
-\code{list_functions} lists all functions. \code{get_function} retrieves a specific function and \code{get_function_versions} retrieves all versions of that function. \code{get_function_configuration} returns the configuration details used when creating or updating the function. \code{delete_function} deletes a function, if you have permission to do so.
+\code{create_function_alias} creates a new function alias for a
+ given version of a function. \code{update_function_alias} updates the
+ association between a function alias and the function version.
+ \code{list_function_aliases} lists all function aliases.
+ \code{get_function_alias} retrieves a specific function alias.
+ \code{delete_function_alias} deletes a function alias, but not the
+ associated function version.
}
\references{
-\href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetAlias.html}{API Reference: GetAlias}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html}{API Reference: CreateAlias}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html}{API Reference: UpdateAlias}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_DeleteAlias.html}{API Reference: DeleteAlias}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListAliases.html}{API Reference: ListAliases}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetAlias.html}{API
+Reference: GetAlias}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html}{API
+Reference: CreateAlias}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html}{API
+Reference: UpdateAlias}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_DeleteAlias.html}{API
+Reference: DeleteAlias}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListAliases.html}{API
+Reference: ListAliases}
}
\seealso{
\code{\link{create_function}}, \code{\link{list_functions}}
diff --git a/man/create_function.Rd b/man/create_function.Rd
index 6cad986..02280a2 100644
--- a/man/create_function.Rd
+++ b/man/create_function.Rd
@@ -2,34 +2,84 @@
% Please edit documentation in R/create_function.R
\name{create_function}
\alias{create_function}
+\alias{update_function_code}
+\alias{update_function_config}
\alias{update_function}
+\alias{publish_function_version}
\alias{make_function_version}
\title{Manage AWS Lambda Functions}
\usage{
-create_function(name, description = name, func, handler, role,
- runtime = c("nodejs6.10", "nodejs4.3", "java8", "python2.7",
- "dotnetcore1.0", "nodejs4.3-edge"), timeout = 3L, ...)
+create_function(
+ name,
+ func,
+ handler,
+ role,
+ runtime = c("nodejs12.x", "nodejs10.x", "java11", "java8", "python3.8", "python3.7",
+ "python3.6", "python2.7", "dotnetcore3.1", "dotnetcore2.1", "go1.x", "ruby2.7",
+ "ruby2.5", "provided"),
+ timeout = 3L,
+ description,
+ ...
+)
-update_function(name, func, description, handler, role,
- runtime = c("nodejs6.10", "nodejs4.3", "java8", "python2.7",
- "dotnetcore1.0", "nodejs4.3-edge"), timeout = 3L, ...)
+update_function_code(name, func, ...)
+
+update_function_config(
+ name,
+ description,
+ handler,
+ role,
+ runtime = c("nodejs12.x", "nodejs10.x", "java11", "java8", "python3.8", "python3.7",
+ "python3.6", "python2.7", "dotnetcore3.1", "dotnetcore2.1", "go1.x", "ruby2.7",
+ "ruby2.5", "provided"),
+ timeout = 3L,
+ ...
+)
+
+update_function(
+ name,
+ func,
+ description,
+ handler,
+ role,
+ runtime = c("nodejs12.x", "nodejs10.x", "java11", "java8", "python3.8", "python3.7",
+ "python3.6", "python2.7", "dotnetcore3.1", "dotnetcore2.1", "go1.x", "ruby2.7",
+ "ruby2.5", "provided"),
+ timeout = 3L,
+ ...
+)
+
+publish_function_version(name, description, ...)
make_function_version(name, description, ...)
}
\arguments{
\item{name}{A character string specifying the function name (either a full ARN or a max 64-character string). For functions other than \code{create_function} this can also be an object of class \dQuote{aws_lambda_function}.}
-\item{description}{Optionally, a max 256-character description of the function for your own use.}
+\item{func}{Either (1) a character string containing a url-style AWS S3
+bucket and object key (e.g., \code{"s3://bucketname/objectkey"}) where the
+object is the .zip file containing the AWS Lambda deployment package; (2) a
+file string pointing to a .zip containing the deployment package; or (3) a
+single file (e.g., a javascript file) that will be zipped and used as the
+deployment. The third option is merely a convenience for very simple
+deployment packages.}
-\item{func}{Either (1) a character string containing a url-style AWS S3 bucket and object key (e.g., \code{"s3://bucketname/objectkey"}) where the object is the .zip file containing the AWS Lambda deployment package; (2) a file string pointing to a .zip containing the deployment package; or (3) a single file (e.g., a javascript file) that will be zipped and used as the deployment. The third option is merely a convenience for very simple deployment packages.}
+\item{handler}{A character string specifying the function within your code
+that Lambda calls to begin execution.}
-\item{handler}{A character string specifying the function within your code that Lambda calls to begin execution.}
+\item{role}{A character string containing an IAM role or an object of class
+\dQuote{iam_role}. This is the role that is used when the function is
+invoked, so it must have permissions over any AWS resources needed by the
+function.}
-\item{role}{A character string containing an IAM role or an object of class \dQuote{iam_role}. This is the role that is used when the function is invoked, so it must have permissions over any AWS resources needed by the function.}
+\item{runtime}{A character string specifying the runtime environment for the
+function.}
-\item{runtime}{A character string specifying the runtime environment for the function.}
+\item{timeout}{An integer specifying the timeout for the function, in
+seconds.}
-\item{timeout}{An integer specifying the timeout for the function, in seconds.}
+\item{description}{Optionally, a max 256-character description of the
+function for your own use.}
\item{\dots}{Additional arguments passed to \code{\link{lambdaHTTP}}.}
}
@@ -40,34 +90,48 @@ A list of class \dQuote{aws_lambda_function}.
Create, update, and version AWS Lambda functions
}
\details{
-\code{create_function} creates a new function from a deployment package. \code{update_function} can, separately, update the code within a function or the configuration settings thereof. \code{make_function_version} records a function version (see \code{\link{list_function_versions}}; changes made between versioning are not recorded.
+\code{create_function} creates a new function from a deployment
+ package. \code{update_function_code} updates the code within a function.
+ \code{update_function_config} updates the configuration settings of a
+ function. \code{publish_function_version} records a function version (see
+ \code{\link{list_function_versions}}; changes made between versioning are
+ not recorded.
}
\examples{
\dontrun{
- # 'hello world!' example code
- hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
-
- # get IAM role for Lambda execution
- library("aws.iam")
- id <- get_caller_identity()[["Account"]]
- role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
-
- func <- create_function("helloworld", func = hello,
- handler = "helloworld.handler",
- role = role)
-
- # invoke function
- invoke_function(func)
-
- # delete function
- delete_function(func)
+# 'hello world!' example code
+hello <- system.file("templates", "helloworld.js", package = "aws.lambda")
+
+# get IAM role for Lambda execution
+library("aws.iam")
+id <- get_caller_identity()[["Account"]]
+# Note: This role may not work. We recommend copying the ARN of a
+# Lambda-capable role from the console once until we're able to more
+# smoothly integrate with aws.iam.
+role <- paste0("arn:aws:iam::", id, ":role/lambda_basic_execution")
+
+lambda_func <- create_function("helloworld",
+ func = hello,
+ handler = "helloworld.handler",
+ role = role
+)
+
+# invoke function
+invoke_function(lambda_func)
+
+# delete function
+delete_function(lambda_func)
}
}
\references{
-\href{http://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html}{API Reference: CreateFunction}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunction.html}{API Reference: UpdateFunction}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_PublishFunction.html}{API Reference: PublishFunction}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html}{API
+Reference: CreateFunction}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionCode.html}{API
+Reference: UpdateFunctionCode}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_PublishVersion.html}{API
+Reference: PublishVersion}
}
\seealso{
-\code{\link{invoke_function}}, \code{\link{create_function_alias}}, \code{\link{list_functions}}, \code{\link{delete_function}}
+\code{\link{invoke_function}}, \code{\link{create_function_alias}},
+ \code{\link{list_functions}}, \code{\link{delete_function}}
}
diff --git a/man/functions.Rd b/man/functions.Rd
index 78495ee..332ad4e 100644
--- a/man/functions.Rd
+++ b/man/functions.Rd
@@ -36,14 +36,23 @@ An object of class \dQuote{aws_lambda_function}.
List functions, function versions, and function policies
}
\details{
-\code{list_functions} lists all functions. \code{get_function} retrieves a specific function and \code{get_function_versions} retrieves all versions of that function. \code{get_function_configuration} returns the configuration details used when creating or updating the function. \code{delete_function} deletes a function, if you have permission to do so.
+\code{list_functions} lists all functions. \code{get_function}
+ retrieves a specific function and \code{list_function_versions} retrieves
+ all versions of that function. \code{get_function_policy} returns the
+ resource-based IAM policy for a function. \code{delete_function} deletes a
+ function, if you have permission to do so.
}
\references{
-\href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html}{API Reference: GetFunction}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListVersionsByFunction.html}{API Reference: ListVersionsByFunction}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListFunctions.html}{API Reference: ListFunctions}
- \href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetFunctionConfiguration.html}{API Reference: GetFunctionConfiguration}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html}{API
+Reference: GetFunction}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListVersionsByFunction.html}{API
+Reference: ListVersionsByFunction}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListFunctions.html}{API
+Reference: ListFunctions}
+\href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetPolicy.html}{API
+Reference: GetPolicy}
}
\seealso{
-\code{\link{create_function}}, \code{\link{update_function}}
+\code{\link{create_function}}, \code{\link{update_function_code}},
+ \code{\link{update_function_config}}
}
diff --git a/man/get_lambda_account.Rd b/man/get_lambda_account.Rd
index cd471b3..828cdd7 100644
--- a/man/get_lambda_account.Rd
+++ b/man/get_lambda_account.Rd
@@ -17,6 +17,6 @@ Get account settings
}
\examples{
\dontrun{
- get_lambda_account()
+get_lambda_account()
}
}
diff --git a/man/invoke_function.Rd b/man/invoke_function.Rd
index 4b0e6ca..0078802 100644
--- a/man/invoke_function.Rd
+++ b/man/invoke_function.Rd
@@ -4,17 +4,26 @@
\alias{invoke_function}
\title{Invoke Lambda Function}
\usage{
-invoke_function(name, qualifier, payload = NULL, type = c("RequestResponse",
- "Event", "DryRun"), log = c("None", "Tail"), ...)
+invoke_function(
+ name,
+ qualifier,
+ payload = NULL,
+ type = c("RequestResponse", "Event", "DryRun"),
+ log = c("None", "Tail"),
+ ...
+)
}
\arguments{
\item{name}{A character string specifying the function name (either a full ARN or a max 64-character string). For functions other than \code{create_function} this can also be an object of class \dQuote{aws_lambda_function}.}
\item{qualifier}{Optionally, either a function version or alias. If omitted, information about the latest version is returned.}
-\item{payload}{Optionally, the JSON body to send to the function.}
+\item{payload}{Optionally, a list of parameters to send in the JSON body to
+the function.}
-\item{type}{A character string specifying one of: (1) \dQuote{Event} (asynchronous execution), (2) \dQuote{RequestResponse} (the default), or (3) \dQuote{DryRun} to test the function without executing it.}
+\item{type}{A character string specifying one of: (1) \dQuote{Event}
+(asynchronous execution), (2) \dQuote{RequestResponse} (the default), or
+(3) \dQuote{DryRun} to test the function without executing it.}
\item{log}{A character string to control log response.}
diff --git a/man/lambdaHTTP.Rd b/man/lambdaHTTP.Rd
index 70f4c98..4f4ab35 100644
--- a/man/lambdaHTTP.Rd
+++ b/man/lambdaHTTP.Rd
@@ -4,45 +4,68 @@
\alias{lambdaHTTP}
\title{Execute AWS Lambda API Request}
\usage{
-lambdaHTTP(verb = "GET", action, query = list(), headers = list(),
- body = NULL, verbose = getOption("verbose", FALSE),
- region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"), key = NULL,
- secret = NULL, session_token = NULL, ...)
+lambdaHTTP(
+ verb = "GET",
+ action,
+ query = NULL,
+ headers = list(),
+ body = NULL,
+ verbose = getOption("verbose", FALSE),
+ region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"),
+ key = NULL,
+ secret = NULL,
+ session_token = NULL,
+ ...
+)
}
\arguments{
\item{verb}{A character string specifying the HTTP verb to use.}
\item{action}{A character string specifying the API version and endpoint.}
-\item{query}{An optional named list containing query string parameters and their character values.}
+\item{query}{An optional named list containing query string parameters and
+their character values.}
\item{headers}{A list of headers to pass to the HTTP request.}
\item{body}{The HTTP request body.}
-\item{verbose}{A logical indicating whether to be verbose. Default is given by \code{options("verbose")}.}
+\item{verbose}{A logical indicating whether to be verbose. Default is given
+by \code{options("verbose")}.}
-\item{region}{A character string specifying an AWS region. See \code{\link[aws.signature]{locate_credentials}}.}
+\item{region}{A character string specifying an AWS region. See
+\code{\link[aws.signature]{locate_credentials}}.}
-\item{key}{A character string specifying an AWS Access Key. See \code{\link[aws.signature]{locate_credentials}}.}
+\item{key}{A character string specifying an AWS Access Key. See
+\code{\link[aws.signature]{locate_credentials}}.}
-\item{secret}{A character string specifying an AWS Secret Key. See \code{\link[aws.signature]{locate_credentials}}.}
+\item{secret}{A character string specifying an AWS Secret Key. See
+\code{\link[aws.signature]{locate_credentials}}.}
-\item{session_token}{Optionally, a character string specifying an AWS temporary Session Token to use in signing a request. See \code{\link[aws.signature]{locate_credentials}}.}
+\item{session_token}{Optionally, a character string specifying an AWS
+temporary Session Token to use in signing a request. See
+\code{\link[aws.signature]{locate_credentials}}.}
-\item{\dots}{Additional arguments passed to \code{\link[httr]{GET}} or another httr request function.}
+\item{\dots}{Additional arguments passed to \code{\link[httr]{GET}} or
+another httr request function.}
}
\value{
-If successful, a named list. Otherwise, a data structure of class \dQuote{aws-error} containing any error message(s) from AWS and information about the request attempt.
+If successful, a named list. Otherwise, a data structure of class
+ \dQuote{aws-error} containing any error message(s) from AWS and information
+ about the request attempt.
}
\description{
-This is the workhorse function to execute calls to the Lambda API.
+This is the workhorse function to execute calls to the Lambda
+ API.
}
\details{
-This function constructs and signs an AWS Lambda API request and returns the results thereof, or relevant debugging information in the case of error.
+This function constructs and signs an AWS Lambda API request and
+ returns the results thereof, or relevant debugging information in the case
+ of error.
}
\seealso{
-\code{\link{get_lambda_account}}, which works well as a hello world for the package
+\code{\link{get_lambda_account}}, which works well as a hello world
+ for the package
}
\author{
Thomas J. Leeper
diff --git a/man/op-null-default.Rd b/man/op-null-default.Rd
new file mode 100644
index 0000000..f1ea964
--- /dev/null
+++ b/man/op-null-default.Rd
@@ -0,0 +1,18 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/utils.R
+\name{op-null-default}
+\alias{op-null-default}
+\alias{\%||\%}
+\title{Default value for `NULL`}
+\usage{
+x \%||\% y
+}
+\arguments{
+\item{x, y}{If `x` is NULL, will return `y`; otherwise returns `x`.}
+}
+\description{
+This infix function makes it easy to replace `NULL`s with a default
+value. It's inspired by the way that Ruby's or operation (`||`)
+works. Copied from the rlang package.
+}
+\keyword{internal}