Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtyler committed Feb 13, 2024
1 parent 29ffa6a commit 5b6eefc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion lambda/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (

"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/eventbridge"
"github.com/ministryofjustice/opg-data-lpa-store/internal/ddb"
"github.com/ministryofjustice/opg-data-lpa-store/internal/shared"
"github.com/ministryofjustice/opg-go-common/logging"
Expand All @@ -30,6 +33,7 @@ type Lambda struct {
store Store
verifier Verifier
logger Logger
eb *eventbridge.EventBridge
}

func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
Expand Down Expand Up @@ -91,6 +95,22 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe
return shared.ProblemInternalServerError.Respond()
}

_, err = l.eb.PutEvents(&eventbridge.PutEventsInput{
Entries: []*eventbridge.PutEventsRequestEntry{
{
EventBusName: aws.String(os.Getenv("EVENT_BUS_NAME")),
DetailType: aws.String("test"),
Source: aws.String("opg.poas.lpastore"),
Detail: aws.String("{\"ok\": true}"),
},
},
})

if err != nil {
l.logger.Print(err)
return shared.ProblemInternalServerError.Respond()
}

// respond
response.StatusCode = 201
response.Body = `{}`
Expand All @@ -99,14 +119,19 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe
}

func main() {
sess := session.Must(session.NewSession())
// endpoint := "http://localstack:4566"
// sess.Config.Endpoint = &endpoint

l := &Lambda{
store: ddb.New(
store: ddb.New(
os.Getenv("AWS_DYNAMODB_ENDPOINT"),
os.Getenv("DDB_TABLE_NAME_DEEDS"),
os.Getenv("DDB_TABLE_NAME_CHANGES"),
),
verifier: shared.NewJWTVerifier(),
logger: logging.New(os.Stdout, "opg-data-lpa-store"),
eb: eventbridge.New(sess),
}

lambda.Start(l.HandleEvent)
Expand Down
2 changes: 1 addition & 1 deletion terraform/environment/terraform.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"arn:aws:iam::493907465011:role/lpa-store-ci"
],
"target_event_buses": [
"arn:aws:events:eu-west-1:288342028542:event-bus/dev-poas"
"arn:aws:events:eu-west-1:288342028542:event-bus/vega-2333-poas"
]
},
"development": {
Expand Down

0 comments on commit 5b6eefc

Please sign in to comment.