Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyfrs committed Aug 8, 2024
1 parent 889770f commit 437f77e
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 30 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
AWS_ACCESS_KEY_ID: "fakekey"
AWS_SECRET_ACCESS_KEY: "fakeaccesskey"
AWS_DYNAMODB_ENDPOINT: http://paymentsdb:54000
AWS_REGION: us-east-2
AWS_REGION: us-east-1
MOCK_PAYMENT_PROVIDER: true
MP_TOKEN: token
MP_USER_ID: userId
Expand All @@ -40,7 +40,7 @@ services:
environment:
AWS_ACCESS_KEY_ID: "fakekey"
AWS_SECRET_ACCESS_KEY: "fakeaccesskey"
AWS_REGION: us-east-2
AWS_REGION: us-east-1
command: ["-D\"java.library.path\"=./DynamoDBLocal_lib", "-jar", "DynamoDBLocal.jar", "-inMemory", "-sharedDb"]
healthcheck:
test: ["CMD-SHELL", "curl localhost:8000"]
Expand All @@ -56,7 +56,7 @@ services:
- "4510-4559:4510-4559"
environment:
- SERVICES=sqs,sns
- AWS_DEFAULT_REGION=us-east-2
- AWS_DEFAULT_REGION=us-east-1
volumes:
- ./src/main/resources/localstack/localstack-init.sh:/etc/localstack/init/ready.d/init-aws.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@
"name": "mercadopago.integration.webhookBaseUrl",
"type": "java.lang.String",
"description": "Description for mercadopago.integration.webhookBaseUrl."
},
{
"name": "sqs.queues.request-payment",
"type": "java.lang.String",
"description": "Description for sqs.queues.request-payment."
},
{
"name": "sns.topics.response-payment",
"type": "java.lang.String",
"description": "Description for sns.topics.response-payment."
},
{
"name": "security.enable",
"type": "java.lang.String",
"description": "Description for security.enable."
}
]
}
8 changes: 0 additions & 8 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,5 @@ spring:
region:
static: ${AWS_REGION}

sqs:
queues:
request-payment: request-payment_queue

sns:
topics:
response-payment: arn:aws:sns:us-east-2:000000000000:payment-response_topic

server:
port: 8081
6 changes: 1 addition & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ sqs:

sns:
topics:
response-payment: ${SNS_TOPIC_RESPONSE_PAYMENT_ARN}

clients:
orders-api:
url: ${ORDERS_SERVICE_URL}
response-payment: payment-response_topic

server:
port: 8082
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

export AWS_ACCESS_KEY_ID=fakekey
export AWS_SECRET_ACCESS_KEY=fakeaccesskey
export AWS_REGION=us-east-2
export AWS_REGION=us-east-1

aws dynamodb create-table \
--table-name payments \
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/localstack/localstack-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ done

aws sns subscribe \
--endpoint-url=http://localhost:4566 \
--topic-arn=arn:aws:sqs:us-east-2:000000000000:request-payment_topic \
--topic-arn=arn:aws:sqs:us-east-1:000000000000:request-payment_topic \
--protocol=sqs \
--notification-endpoint=arn:aws:sns:us-east-2:000000000000:request-payment_queue
--notification-endpoint=arn:aws:sns:us-east-1:000000000000:request-payment_queue

echo "Topic request-payment_queue subscribe"

aws sns subscribe \
--endpoint-url=http://localhost:4566 \
--topic-arn=arn:aws:sqs:us-east-2:000000000000:payment-response_topic \
--topic-arn=arn:aws:sqs:us-east-1:000000000000:payment-response_topic \
--protocol=sqs \
--notification-endpoint=arn:aws:sns:us-east-2:000000000000:payment-response_queue
--notification-endpoint=arn:aws:sns:us-east-1:000000000000:payment-response_queue

echo "Topic payment-response_queue subscribe"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class LocalStackContainerInitializer :
"spring.cloud.aws.credentials.access-key=${instance.accessKey}",
"spring.cloud.aws.credentials.secret-key=${instance.secretKey}",
"spring.cloud.aws.region.static=${instance.region}",
"sns.topics.response-payment=${getTopicArn(snsClient, "payment-response_topic")}",
).applyTo(configurableApplicationContext)
}

Expand Down
8 changes: 4 additions & 4 deletions terraform/sns.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
resource "aws_sns_topic" "request_payment_topic" {
name = "request-payment_topic"
}

resource "aws_sns_topic" "payment_response_topic" {
name = "payment-response_topic"
}
Expand All @@ -14,6 +10,10 @@ resource "aws_sns_topic_subscription" "request_payment_subscription" {
raw_message_delivery = true
}

resource "aws_sns_topic" "request_payment_topic" {
name = "request-payment_topic"
}

resource "aws_sns_topic_subscription" "payment_response_subscription" {
topic_arn = aws_sns_topic.payment_response_topic.arn
protocol = "sqs"
Expand Down
12 changes: 8 additions & 4 deletions terraform/sqs.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# REQUEST QUEUE

resource "aws_sqs_queue" "request_payment_dlq" {
name = "request-payment_queue_dlq"
}

resource "aws_sqs_queue" "payment_response_dlq" {
name = "payment-response_queue_dlq"
}

resource "aws_sqs_queue" "request_payment_queue" {
name = "request-payment_queue"

Expand All @@ -17,6 +15,12 @@ resource "aws_sqs_queue" "request_payment_queue" {
delay_seconds = 5
}

# RESPONSE QUEUE

resource "aws_sqs_queue" "payment_response_dlq" {
name = "payment-response_queue_dlq"
}

resource "aws_sqs_queue" "payment_response_queue" {
name = "payment-response_queue"

Expand Down

0 comments on commit 437f77e

Please sign in to comment.