This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auto_scaling.tf | |
resource "aws_appautoscaling_target" "target" { | |
service_namespace = "ecs" | |
resource_id = "service/${aws_ecs_cluster.main.name}/${aws_ecs_service.main.name}" | |
scalable_dimension = "ecs:service:DesiredCount" | |
role_arn = aws_iam_role.ecs_auto_scale_role.arn | |
min_capacity = 3 | |
max_capacity = 6 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# logs.tf | |
# Set up CloudWatch group and log stream and retain logs for 30 days | |
resource "aws_cloudwatch_log_group" "cb_log_group" { | |
name = "/ecs/cb-app" | |
retention_in_days = 30 | |
tags = { | |
Name = "cb-log-group" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# outputs.tf | |
output "alb_hostname" { | |
value = aws_alb.main.dns_name | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/sha256" | |
"encoding/hex" | |
"fmt" | |
"log" | |
"github.com/btcsuite/btcd/chaincfg" | |
"github.com/btcsuite/btcutil" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/bradford-hamilton/go-graphql-api/gql" | |
"github.com/bradford-hamilton/go-graphql-api/postgres" | |
"github.com/bradford-hamilton/go-graphql-api/server" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE users ( | |
id serial PRIMARY KEY, | |
name VARCHAR (50) NOT NULL, | |
age INT NOT NULL, | |
profession VARCHAR (50) NOT NULL, | |
friendly BOOLEAN NOT NULL | |
); | |
INSERT INTO users VALUES | |
(1, 'kevin', 35, 'waiter', true), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package postgres | |
import ( | |
"database/sql" | |
"fmt" | |
// postgres driver | |
_ "github.com/lib/pq" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gql | |
import ( | |
"github.com/bradford-hamilton/go-graphql-api/postgres" | |
"github.com/graphql-go/graphql" | |
) | |
// Root holds a pointer to a graphql object | |
type Root struct { | |
Query *graphql.Object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gql | |
import ( | |
"github.com/bradford-hamilton/go-graphql-api/postgres" | |
"github.com/graphql-go/graphql" | |
) | |
// Resolver struct holds a connection to our database | |
type Resolver struct { | |
db *postgres.Db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gql | |
import "github.com/graphql-go/graphql" | |
// User describes a graphql object containing a User | |
var User = graphql.NewObject( | |
graphql.ObjectConfig{ | |
Name: "User", | |
Fields: graphql.Fields{ | |
"id": &graphql.Field{ |