1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

fix deploy script

This commit is contained in:
Lee Brown
2019-08-13 18:12:20 -08:00
parent c4b7abf685
commit 5ea41923c7
4 changed files with 23 additions and 3 deletions

View File

@ -14,7 +14,7 @@
"awslogs-group": "{AWS_LOGS_GROUP}",
"awslogs-region": "{AWS_REGION}",
"awslogs-stream-prefix": "ecs",
"awslogs-datetime-format": "%Y-%m-%d %H:%M:%S.%f"
"awslogs-datetime-format": "%Y/%m/%d %H:%M:%S.%L"
}
},
"portMappings": [

View File

@ -14,7 +14,7 @@
"awslogs-group": "{AWS_LOGS_GROUP}",
"awslogs-region": "{AWS_REGION}",
"awslogs-stream-prefix": "ecs",
"awslogs-datetime-format": "%Y-%m-%d %H:%M:%S.%f"
"awslogs-datetime-format": "%Y/%m/%d %H:%M:%S.%L"
}
},
"portMappings": [

View File

@ -96,6 +96,10 @@ func RegisterEcsServiceTasksRoute53(log *log.Logger, awsSession *session.Session
return errors.Wrapf(err, "failed to list tasks for cluster '%s' service '%s'", ecsClusterName, ecsServiceName)
}
if len(servceTaskRes.TaskArns) == 0 {
continue
}
taskRes, err := svc.DescribeTasks(&ecs.DescribeTasksInput{
Cluster: aws.String(ecsClusterName),
Tasks: servceTaskRes.TaskArns,
@ -148,6 +152,10 @@ func RegisterEcsServiceTasksRoute53(log *log.Logger, awsSession *session.Session
time.Sleep((time.Duration(a) * time.Second * 10) * time.Duration(a))
}
if len(networkInterfaceIds) == 0 {
return errors.New("Unable to update public IPs. No network interfaces found.")
}
log.Println("Get public IPs for network interface IDs.")
var publicIps []string
for a := 0; a <= 3; a++ {
@ -202,7 +210,11 @@ func RegisterEcsServiceTasksRoute53(log *log.Logger, awsSession *session.Session
}
// Add all the A record names with the same set of public IPs.
addedNames := make(map[string]bool)
for _, aName := range aNames {
if addedNames[aName] {
continue
}
log.Printf("\t\tAdd A record for '%s'.\n", aName)
input.ChangeBatch.Changes = append(input.ChangeBatch.Changes, &route53.Change{
@ -214,6 +226,7 @@ func RegisterEcsServiceTasksRoute53(log *log.Logger, awsSession *session.Session
Type: aws.String("A"),
},
})
addedNames[aName] = true
}
_, err := svc.ChangeResourceRecordSets(input)

View File

@ -235,3 +235,10 @@ instance will be a dedicated host since we need it always up and running, thus i
```bash
sudo gitlab-runner restart
```
## Examples
```bash
go run main.go deploy -service=web-app -env=dev -enable_https=true -primary_host=example.saasstartupkit.com -host_names=example.saasstartupkit.com,dev.example.saasstartupkit.com -private_bucket=saas-starter-kit-private -public_bucket=saas-starter-kit-public -public_bucket_cloudfront=true -static_files_s3=true -static_files_img_resize=1 -recreate_service=0
```