generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update call-profiles to invoke call-profile using lambdaInvokd
- Loading branch information
Showing
5 changed files
with
69 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
env.json | ||
samconfig.toml | ||
*/firestore-debug.log | ||
scripts/local-dev.sh | ||
scripts/deploy-local.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package utils | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/lambda" | ||
) | ||
|
||
type ProfileLambdaCallPayload struct { | ||
UserId string `json:"userId"` | ||
SessionID string `json:"sessionId"` | ||
} | ||
|
||
func InvokeProfileLambda(payload ProfileLambdaCallPayload) error { | ||
session := session.Must(session.NewSession()) | ||
client := lambda.New(session) | ||
|
||
payloadBytes, err := json.Marshal(payload) | ||
if err != nil { | ||
return fmt.Errorf("error marshalling payload: %w", err) | ||
} | ||
|
||
functionName := "CallProfileFunction" | ||
fmt.Println("functionName", functionName) | ||
if functionName == "" { | ||
return fmt.Errorf("PROFILE_LAMBDA_FUNCTION_ARN is not set") | ||
} | ||
|
||
input := &lambda.InvokeInput{ | ||
FunctionName: aws.String(functionName), | ||
Payload: payloadBytes, | ||
} | ||
|
||
_, err = client.Invoke(input) | ||
if err != nil { | ||
fmt.Println("error invoking lambda", err) | ||
return fmt.Errorf("error invoking lambda: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters