-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
103 lines (76 loc) · 2.48 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# r2lambda
<!-- badges: start -->
[](https://github.com/discindo/r2lambda/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/discindo/r2lambda?branch=main)
<!-- badges: end -->
The goal of `{r2lambda}` is to make it easier to go from an `R` script to a deployed
`AWS Lambda` function.
## Requirements
- [docker](https://docs.docker.com/get-docker/) is required to build, tag, and push the image.
## Installation
You can install the development version of `{r2lambda}` like so:
``` r
# install_packages("remotes")
remotes::install_github("discindo/r2lambda")
```
## Setup
`r2lambda` assumes environmental variables for connecting to AWS services are available
in the `R` session. This is typically done via an `.Renviron` file that should include:
```
ACCESS_KEY_ID = "YOUR AWS ACCESS KEY ID"
SECRET_ACCESS_KEY = "YOUR AWS SECRET ACCESS KEY"
PROFILE = "YOUR AWS PROFILE"
REGION = "YOUR AWS REGION"
```
## Workflow
### Build a docker image for the lambda function
```{r, eval = FALSE}
runtime_function <- "parity"
runtime_path <- system.file("parity.R", package = "r2lambda")
dependencies <- NULL
# Might take a while, its building a docker image
build_lambda(
tag = "parity1",
runtime_function = runtime_function,
runtime_path = runtime_path,
dependencies = dependencies
)
```
### Test the lambda docker image locally
```{r, eval = FALSE}
payload <- list(number = 2)
tag <- "parity1"
test_lambda(tag = "parity1", payload)
```
### Deploy to AWS Lambda
```{r, eval = FALSE}
# Might take a while, its pushing it to a remote repository
deploy_lambda(tag = "parity1")
```
### Invoke deployed lambda
```{r, eval = FALSE}
invoke_lambda(
function_name = "parity1",
invocation_type = "RequestResponse",
payload = list(number = 2),
include_logs = FALSE
)
#> Lambda response payload:
#> {"parity":"even"}
```
## Code of Conduct
Please note that the r2lambda project is released with a
[Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.