Skip to content

Commit

Permalink
Merge pull request #129 from p4tin/arn_fix
Browse files Browse the repository at this point in the history
Use region in all Arns
  • Loading branch information
p4tin authored Jan 20, 2018
2 parents a5b8f61 + 72f7d89 commit 0b96b58
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
13 changes: 6 additions & 7 deletions app/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func LoadYamlConfig(filename string, env string) []string {
ports := []string{"4100"}

if filename == "" {
filename, _ = filepath.Abs("./app/conf/goaws.yaml")
filename, _ = filepath.Abs("./conf/goaws.yaml")
}
log.Warnf("Loading config file: %s", filename)
yamlFile, err := ioutil.ReadFile(filename)
Expand All @@ -34,9 +34,8 @@ func LoadYamlConfig(filename string, env string) []string {
env = "Local"
}

region := "local"
if envs[env].Region != "" {
region = envs[env].Region
if envs[env].Region == "" {
app.CurrentEnvironment.Region = "local"
}

if envs[env].Port != "" {
Expand All @@ -62,12 +61,12 @@ func LoadYamlConfig(filename string, env string) []string {
app.SyncTopics.Lock()
for _, queue := range envs[env].Queues {
queueUrl := "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/queue/" + queue.Name
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Host + ":000000000000:" + queue.Name
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Region + ":000000000000:" + queue.Name
app.SyncQueues.Queues[queue.Name] = &app.Queue{Name: queue.Name, TimeoutSecs: 30, Arn: queueArn, URL: queueUrl}
}

for _, topic := range envs[env].Topics {
topicArn := "arn:aws:sns:" + region + ":000000000000:" + topic.Name
topicArn := "arn:aws:sns:" + app.CurrentEnvironment.Region + ":000000000000:" + topic.Name

newTopic := &app.Topic{Name: topic.Name, Arn: topicArn}
newTopic.Subscriptions = make([]*app.Subscription, 0, 0)
Expand All @@ -76,7 +75,7 @@ func LoadYamlConfig(filename string, env string) []string {
if _, ok := app.SyncQueues.Queues[subs.QueueName]; !ok {
//Queue does not exist yet, create it.
queueUrl := "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/queue/" + subs.QueueName
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Host + ":000000000000:" + subs.QueueName
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Region + ":000000000000:" + subs.QueueName
app.SyncQueues.Queues[subs.QueueName] = &app.Queue{Name: subs.QueueName, TimeoutSecs: 30, Arn: queueArn, URL: queueUrl}
}
qUrl := app.SyncQueues.Queues[subs.QueueName].URL
Expand Down
1 change: 1 addition & 0 deletions app/conf/goaws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Local: # Environment name that can be passed on the
Port: 4100 # port to listen on.
# SqsPort: 9324 # alterante Sqs Port
# SnsPort: 9292 # alternate Sns Port
Region: local-01
LogMessages: true # Log messages (true/false)
LogFile: ./goaws_messages.log # Log filename (for message logging
Queues: # List of queues to create at startup
Expand Down
2 changes: 1 addition & 1 deletion app/gosns/gosns.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func CreateTopic(w http.ResponseWriter, req *http.Request) {
if _, ok := app.SyncTopics.Topics[topicName]; ok {
topicArn = app.SyncTopics.Topics[topicName].Arn
} else {
topicArn = "arn:aws:sns:local:000000000000:" + topicName
topicArn = "arn:aws:sns:" + app.CurrentEnvironment.Region + ":000000000000:" + topicName

log.Println("Creating Topic:", topicName)
topic := &app.Topic{Name: topicName, Arn: topicArn}
Expand Down
2 changes: 1 addition & 1 deletion app/gosqs/gosqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func CreateQueue(w http.ResponseWriter, req *http.Request) {
queueName := req.FormValue("QueueName")
host := app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port
queueUrl := "http://" + host + "/queue/" + queueName
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Host + ":000000000000:" + queueName
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Region + ":000000000000:" + queueName

if _, ok := app.SyncQueues.Queues[queueName]; !ok {
log.Println("Creating Queue:", queueName)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '2'
services:
yopa:
goaws:
container_name: goaws
image: pafortin/goaws
image: pafortin/goaws:1.0.0
ports:
- 4100:4100
volumes:
Expand Down

0 comments on commit 0b96b58

Please sign in to comment.