Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main b 22056 sns sqs deps w endpoint #14551

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d252638
B-22056 - work files copied over for backend api call.
ryan-mchugh Dec 31, 2024
1344c8f
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22056_s…
ryan-mchugh Jan 8, 2025
24daa1a
B-22056 - checkin tests and updates from other branch.
ryan-mchugh Jan 8, 2025
1729cbd
B-22056 - env var updates to match planned in param store.
ryan-mchugh Jan 8, 2025
75deebb
B-22056 - additional test and .envrc cleanup.
ryan-mchugh Jan 9, 2025
e117246
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22056_s…
ryan-mchugh Jan 9, 2025
399bfb4
B-22056 - setup for exp testing.
ryan-mchugh Jan 9, 2025
2d77f6d
B-22056 - fix previous merge.
ryan-mchugh Jan 9, 2025
ed66a16
B-22056 - restore exp env.
ryan-mchugh Jan 9, 2025
bf315ee
B-22056 - additional test for receiving messages on routing.
ryan-mchugh Jan 10, 2025
41dcc68
B-22056 - deploy to exp.
ryan-mchugh Jan 10, 2025
51740dc
B-22056 - restore exp env.
ryan-mchugh Jan 10, 2025
c8424e8
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22056_s…
ryan-mchugh Jan 13, 2025
20f887c
B-22056 - fix tests.
ryan-mchugh Jan 13, 2025
0964e61
B-22056 - using generated mocks for unit tests instead.
ryan-mchugh Jan 14, 2025
25ed4b2
B-22056 - additional security for sqs based on best practices
ryan-mchugh Jan 14, 2025
f80886e
B-22056 - deploy to exp.
ryan-mchugh Jan 14, 2025
e59cff8
B-22056 - restore exp env.
ryan-mchugh Jan 14, 2025
bdade45
B-22056 - delete message after receive.
ryan-mchugh Jan 15, 2025
b8d1a36
B-22056 - attempting to fix test.
ryan-mchugh Jan 15, 2025
890700f
B-22056 - attempting to fix test.
ryan-mchugh Jan 15, 2025
228ac54
B-22056 - attempting to fix test.
ryan-mchugh Jan 15, 2025
e22abd6
B-22056 - attempting to fix test.
ryan-mchugh Jan 15, 2025
c0bf4e2
B-22056 - attempting to fix test.
ryan-mchugh Jan 16, 2025
12c55df
B-22056 - attempting to fix test.
ryan-mchugh Jan 16, 2025
06a593c
B-22056 - deploy to exp.
ryan-mchugh Jan 16, 2025
dc22fd4
B-22056 - update param while in exp.
ryan-mchugh Jan 16, 2025
c50ed5f
B-22056 - update logging while in exp.
ryan-mchugh Jan 16, 2025
5bd0918
B-22056 - update logging while in exp.
ryan-mchugh Jan 16, 2025
f597e96
B-22056 - restore exp env.
ryan-mchugh Jan 16, 2025
855e52e
B-22056 - deploy to exp with updated param format
ryan-mchugh Jan 16, 2025
d17b881
B-22056 - restore format.
ryan-mchugh Jan 16, 2025
6ddfa3d
B-22056 - restore exp env.
ryan-mchugh Jan 16, 2025
7900c0c
B-22056 - remove timer from test.
ryan-mchugh Jan 17, 2025
3ed262c
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22056_s…
ryan-mchugh Jan 17, 2025
80cf552
B-22056 - tests for fakeS3 and local storage.
ryan-mchugh Jan 17, 2025
0f0f6d4
B-22056 - more tests for memory and filesystem.
ryan-mchugh Jan 17, 2025
866c95a
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22056_s…
ryan-mchugh Jan 17, 2025
e6a690c
B-22056 - change local receiver log message.
ryan-mchugh Jan 17, 2025
821067c
B-22056 - deploy to exp.
ryan-mchugh Jan 17, 2025
78f62bb
B-22056 - restore exp env.
ryan-mchugh Jan 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,22 @@ export TZ="UTC"

# AWS development access
#
# To use S3/SES for local builds, you'll need to uncomment the following.
# To use S3/SES or SNS & SQS for local builds, you'll need to uncomment the following.
# Do not commit the change:
#
# export STORAGE_BACKEND=s3
# export EMAIL_BACKEND=ses
# export RECEIVER_BACKEND=sns_sqs
#
# Instructions for using S3 storage backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/1470955567/How+to+test+storing+data+in+S3+locally
# Instructions for using SES email backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/1467973894/How+to+test+sending+email+locally
# Instructions for using SNS&SQS backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/2793242625/How+to+test+notifications+receiver+locally
#
# The default and equivalent to not being set is:
#
# export STORAGE_BACKEND=local
# export EMAIL_BACKEND=local
# export RECEIVER_BACKEND=local
#
# Setting region and profile conditionally while we migrate from com to govcloud.
if [ "$STORAGE_BACKEND" == "s3" ]; then
Expand All @@ -258,6 +261,11 @@ export AWS_S3_KEY_NAMESPACE=$USER
export AWS_SES_DOMAIN="devlocal.dp3.us"
export AWS_SES_REGION="us-gov-west-1"

if [ "$RECEIVER_BACKEND" == "sns_sqs" ]; then
export SNS_TAGS_UPDATED_TOPIC="app_s3_tag_events"
export SNS_REGION="us-gov-west-1"
fi

# To use s3 links aws-bucketname/xx/user/ for local builds,
# you'll need to add the following to your .envrc.local:
#
Expand Down Expand Up @@ -444,4 +452,4 @@ then
fi

# Check that all required environment variables are set
check_required_variables
check_required_variables
7 changes: 7 additions & 0 deletions cmd/milmove/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool
appCtx.Logger().Fatal("notification sender sending not enabled", zap.Error(err))
}

// Notification Receiver
notificationReceiver, err := notifications.InitReceiver(v, appCtx.Logger(), true)
if err != nil {
appCtx.Logger().Fatal("notification receiver not enabled", zap.Error(err))
}

routingConfig.BuildRoot = v.GetString(cli.BuildRootFlag)
sendProductionInvoice := v.GetBool(cli.GEXSendProdInvoiceFlag)

Expand Down Expand Up @@ -567,6 +573,7 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool
dtodRoutePlanner,
fileStorer,
notificationSender,
notificationReceiver,
iwsPersonLookup,
sendProductionInvoice,
gexSender,
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ require (
github.com/aws/aws-sdk-go-v2/service/rds v1.78.2
github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0
github.com/aws/aws-sdk-go-v2/service/ses v1.25.3
github.com/aws/aws-sdk-go-v2/service/sns v1.31.8
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.6
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.8
github.com/aws/aws-sdk-go-v2/service/sts v1.30.7
github.com/aws/smithy-go v1.20.4
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0 h1:Cso4Ev/XauMVsbwdhYEoxg8rxZWw4
github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0/go.mod h1:BSPI0EfnYUuNHPS0uqIo5VrRwzie+Fp+YhQOUs16sKI=
github.com/aws/aws-sdk-go-v2/service/ses v1.25.3 h1:wcfUsE2nqsXhEj68gxr7MnGXNPcBPKx0RW2DzBVgVlM=
github.com/aws/aws-sdk-go-v2/service/ses v1.25.3/go.mod h1:6Ul/Ir8oOCsI3dFN0prULK9fvpxP+WTYmlHDkFzaAVA=
github.com/aws/aws-sdk-go-v2/service/sns v1.31.8 h1:vRSk062d1SmaEVbiqFePkvYuhCTnW2JnPkUdt19nqeY=
github.com/aws/aws-sdk-go-v2/service/sns v1.31.8/go.mod h1:wjhxA9hlVu75dCL/5Wcx8Cwmszvu6t0i8WEDypcB4+s=
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.6 h1:DbjODDHumQBdJ3T+EO7AXVoFUeUhAsJYOdjStH5Ws4A=
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.6/go.mod h1:7idt3XszF6sE9WPS1GqZRiDJOxw4oPtlRBXodWnCGjU=
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.8 h1:7cjN4Wp3U3cud17TsnUxSomTwKzKQGUWdq/N1aWqgMk=
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.8/go.mod h1:nUSNPaG8mv5rIu7EclHnFqZOjhreEUwRKENtKTtJ9aw=
github.com/aws/aws-sdk-go-v2/service/sso v1.22.7 h1:pIaGg+08llrP7Q5aiz9ICWbY8cqhTkyy+0SHvfzQpTc=
Expand Down
53 changes: 53 additions & 0 deletions pkg/cli/receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cli

import (
"fmt"

"github.com/spf13/pflag"
"github.com/spf13/viper"
)

const (
// ReceiverBackend is the Receiver Backend Flag
ReceiverBackendFlag string = "receiver-backend"
// SNSTagsUpdatedTopicFlag is the SNS Tags Updated Topic Flag
SNSTagsUpdatedTopicFlag string = "sns-tags-updated-topic"
// SNSRegionFlag is the SNS Region flag
SNSRegionFlag string = "sns-region"
// SNSAccountId is the application's AWS account id
SNSAccountId string = "aws-account-id"
)

// InitReceiverFlags initializes Storage command line flags
func InitReceiverFlags(flag *pflag.FlagSet) {
flag.String(ReceiverBackendFlag, "local", "Receiver backend to use, either local or sns_sqs.")
flag.String(SNSTagsUpdatedTopicFlag, "", "SNS Topic for receiving event messages")
flag.String(SNSRegionFlag, "", "Region used for SNS and SQS")
flag.String(SNSAccountId, "", "SNS account Id")
}

// CheckReceiver validates Storage command line flags
func CheckReceiver(v *viper.Viper) error {

receiverBackend := v.GetString(ReceiverBackendFlag)
if !stringSliceContains([]string{"local", "sns_sqs"}, receiverBackend) {
return fmt.Errorf("invalid receiver_backend %s, expecting local or sns_sqs", receiverBackend)
}

if receiverBackend == "sns_sqs" {
r := v.GetString(SNSRegionFlag)
if r == "" {
return fmt.Errorf("invalid value for %s: %s", SNSRegionFlag, r)
}
topic := v.GetString(SNSTagsUpdatedTopicFlag)
if topic == "" {
return fmt.Errorf("invalid value for %s: %s", SNSTagsUpdatedTopicFlag, topic)
}
accountId := v.GetString(SNSAccountId)
if topic == "" {
return fmt.Errorf("invalid value for %s: %s", SNSAccountId, accountId)
}
}

return nil
}
6 changes: 6 additions & 0 deletions pkg/cli/receiver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cli

func (suite *cliTestSuite) TestConfigReceiver() {
suite.Setup(InitReceiverFlags, []string{})
suite.NoError(CheckReceiver(suite.viper))
}
9 changes: 9 additions & 0 deletions pkg/gen/internalapi/configure_mymove.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package internalapi

import (
"crypto/tls"
"io"
"net/http"

"github.com/go-openapi/errors"
Expand Down Expand Up @@ -60,6 +61,9 @@ func configureAPI(api *internaloperations.MymoveAPI) http.Handler {

api.BinProducer = runtime.ByteStreamProducer()
api.JSONProducer = runtime.JSONProducer()
api.TextEventStreamProducer = runtime.ProducerFunc(func(w io.Writer, data interface{}) error {
return errors.NotImplemented("textEventStream producer has not yet been implemented")
})

// You may change here the memory limit for this multipart form parser. Below is the default (32 MB).
// ppm.CreatePPMUploadMaxParseMemory = 32 << 20
Expand Down Expand Up @@ -205,6 +209,11 @@ func configureAPI(api *internaloperations.MymoveAPI) http.Handler {
return middleware.NotImplemented("operation transportation_offices.GetTransportationOffices has not yet been implemented")
})
}
if api.UploadsGetUploadStatusHandler == nil {
api.UploadsGetUploadStatusHandler = uploads.GetUploadStatusHandlerFunc(func(params uploads.GetUploadStatusParams) middleware.Responder {
return middleware.NotImplemented("operation uploads.GetUploadStatus has not yet been implemented")
})
}
if api.EntitlementsIndexEntitlementsHandler == nil {
api.EntitlementsIndexEntitlementsHandler = entitlements.IndexEntitlementsHandlerFunc(func(params entitlements.IndexEntitlementsParams) middleware.Responder {
return middleware.NotImplemented("operation entitlements.IndexEntitlements has not yet been implemented")
Expand Down
1 change: 1 addition & 0 deletions pkg/gen/internalapi/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions pkg/gen/internalapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions pkg/gen/internalapi/internaloperations/mymove_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading