Skip to content

Commit

Permalink
Allow specifying the ID in a lambda (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughevans authored Mar 26, 2023
1 parent 6e2c249 commit 1a1b162
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/resources/lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function populate(jwt, user, registration) {

## Argument Reference

* `lambda_id` - (Optional) The Id to use for the new lambda. If not specified a secure random UUID will be generated.
* `body` - (Required) The lambda function body, a JavaScript function.
* `debug` - (Optional) Whether or not debug event logging is enabled for this Lambda.
* `engine_type` - (Optional) The JavaScript execution engine for the lambda.
Expand Down
10 changes: 9 additions & 1 deletion fusionauth/resource_fusionauth_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ func newLambda() *schema.Resource {
UpdateContext: updateLambda,
DeleteContext: deleteLambda,
Schema: map[string]*schema.Schema{
"lambda_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The Id to use for the new lambda. If not specified a secure random UUID will be generated.",
ValidateFunc: validation.IsUUID,
},
"body": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -82,6 +89,7 @@ func newLambda() *schema.Resource {

func buildLambda(data *schema.ResourceData) fusionauth.Lambda {
l := fusionauth.Lambda{
Id: data.Get("lambda_id").(string),
Body: data.Get("body").(string),
Debug: data.Get("debug").(bool),
Name: data.Get("name").(string),
Expand All @@ -94,7 +102,7 @@ func buildLambda(data *schema.ResourceData) fusionauth.Lambda {
func createLambda(_ context.Context, data *schema.ResourceData, i interface{}) diag.Diagnostics {
client := i.(Client)
l := buildLambda(data)
resp, faErrs, err := client.FAClient.CreateLambda("", fusionauth.LambdaRequest{
resp, faErrs, err := client.FAClient.CreateLambda(l.Id, fusionauth.LambdaRequest{
Lambda: l,
})
if err != nil {
Expand Down

0 comments on commit 1a1b162

Please sign in to comment.