Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion e2e/apprunner/back-end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func HealthCheck(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusOK)
}

// ServiceDiscoveryGet just returns true no matter what
// ServiceDiscoveryGet just returns true no matter what.
func ServiceDiscoveryGet(w http.ResponseWriter, req *http.Request) {
log.Printf("Get on ServiceDiscovery endpoint Succeeded with message %s\n", message)
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion e2e/apprunner/front-end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
postgresDriver = "postgres"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
1 change: 1 addition & 0 deletions e2e/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ var _ = Describe("exec flow", func() {
})
Expect(err).NotTo(HaveOccurred())
Expect(len(svc.Routes)).To(Equal(1))
Expect(len(svc.ServiceConnects)).To(Equal(0))

route := svc.Routes[0]
Expect(route.Environment).To(Equal(envName))
Expand Down
7 changes: 4 additions & 3 deletions e2e/internal/client/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ type SvcShowOutput struct {
Type string `json:"type"`
AppName string `json:"application"`
Configs []SvcShowConfigurations `json:"configurations"`
ServiceDiscoveries []SvcShowServiceDiscoveries `json:"serviceDiscovery"`
ServiceDiscoveries []SvcShowServiceEndpoints `json:"serviceDiscovery"`
ServiceConnects []SvcShowServiceEndpoints `json:"serviceConnect"`
Routes []SvcShowRoutes `json:"routes"`
Variables []SvcShowVariables `json:"variables"`
Resources map[string][]*SvcShowResourceInfo `json:"resources"`
Expand All @@ -86,8 +87,8 @@ type SvcShowRoutes struct {
URL string `json:"url"`
}

// SvcShowServiceDiscoveries contains serialized service discovery info for an service.
type SvcShowServiceDiscoveries struct {
// SvcShowServiceEndpoints contains serialized endpoint info for a service.
type SvcShowServiceEndpoints struct {
Environment []string `json:"environment"`
Endpoint string `json:"endpoint"`
}
Expand Down
12 changes: 6 additions & 6 deletions e2e/multi-svc-app/back-end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ func HealthCheck(w http.ResponseWriter, req *http.Request, ps httprouter.Params)
w.WriteHeader(http.StatusOK)
}

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
w.Write([]byte("back-end"))
}

// ServiceDiscoveryGet just returns true no matter what
func ServiceDiscoveryGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get on ServiceDiscovery endpoint Succeeded")
// Get just returns true no matter what.
func Get(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get on service endpoint Succeeded")
w.WriteHeader(http.StatusOK)
w.Write([]byte("back-end-service-discovery"))
w.Write([]byte("back-end-service"))
}

func main() {
router := httprouter.New()
router.GET("/back-end/", SimpleGet)
router.GET("/service-discovery/", ServiceDiscoveryGet)
router.GET("/service-endpoint/", Get)

// Health Check
router.GET("/", HealthCheck)
Expand Down
3 changes: 3 additions & 0 deletions e2e/multi-svc-app/copilot/front-end/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ http:
# To match all requests you can use the "/" path.
path: '/'

network:
connect: true

# Number of CPU units for the task.
cpu: 256
# Amount of memory in MiB used by the task.
Expand Down
28 changes: 18 additions & 10 deletions e2e/multi-svc-app/front-end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,35 @@ var (
volumeName = "efsTestVolume"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
w.Write([]byte("front-end"))
}

// ServiceDiscoveryGet calls the back-end service, via service-discovery.
// ServiceGet calls the back-end service, via service-connect and service-discovery.
// This call should succeed and return the value from the backend service.
// This test assumes the backend app is called "back-end". The 'service-discovery' endpoint
// of the back-end service is unreachable from the LB, so the only way to get it is
// through service discovery. The response should be `back-end-service-discovery`
func ServiceDiscoveryGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
endpoint := fmt.Sprintf("http://back-end.%s/service-discovery/", os.Getenv("COPILOT_SERVICE_DISCOVERY_ENDPOINT"))
resp, err := http.Get(endpoint)
// This test assumes the backend app is called "back-end". The 'service-connect' and
// 'service-discovery' endpoint of the back-end service is unreachable from the LB,
// so the only way to get it is through service connect and service discovery.
// The response should be `back-end-service`
func ServiceGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
resp, err := http.Get("http://back-end/service-endpoint/")
if err != nil {
log.Printf("🚨 could call service connect endpoint: err=%s\n", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
log.Println("Get on service connect endpoint Succeeded")
sdEndpoint := fmt.Sprintf("http://back-end.%s/service-endpoint/", os.Getenv("COPILOT_SERVICE_DISCOVERY_ENDPOINT"))
resp, err = http.Get(sdEndpoint)
if err != nil {
log.Printf("🚨 could call service discovery endpoint: err=%s\n", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
log.Println("Get on ServiceDiscovery endpoint Succeeded")
log.Println("Get on service discovery endpoint Succeeded")
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
w.WriteHeader(http.StatusOK)
Expand Down Expand Up @@ -123,7 +131,7 @@ func PutEFSCheck(w http.ResponseWriter, req *http.Request, ps httprouter.Params)
func main() {
router := httprouter.New()
router.GET("/", SimpleGet)
router.GET("/service-discovery-test", ServiceDiscoveryGet)
router.GET("/service-endpoint-test", ServiceGet)
router.GET("/magicwords/", GetMagicWords)
router.GET("/job-checker/", GetJobCheck)
router.GET("/job-setter/", SetJobCheck)
Expand Down
2 changes: 1 addition & 1 deletion e2e/multi-svc-app/multi_svc_app_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var cli *client.CLI
var aws *client.AWS
var appName string

/**
/*
The multi svc suite runs through several tests focusing on creating multiple
services in one app.
*/
Expand Down
29 changes: 15 additions & 14 deletions e2e/multi-svc-app/multi_svc_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ var _ = Describe("Multiple Service App", func() {
routeURL string
)
BeforeAll(func() {
_, backEndDeployErr = cli.SvcDeploy(&client.SvcDeployInput{
Name: "back-end",
EnvName: "test",
ImageTag: "gallopinggurdey",
})
_, frontEndDeployErr = cli.SvcDeploy(&client.SvcDeployInput{
Name: "front-end",
EnvName: "test",
Expand All @@ -214,11 +219,6 @@ var _ = Describe("Multiple Service App", func() {
EnvName: "test",
ImageTag: "gallopinggurdey",
})
_, backEndDeployErr = cli.SvcDeploy(&client.SvcDeployInput{
Name: "back-end",
EnvName: "test",
ImageTag: "gallopinggurdey",
})
})

It("svc deploy should succeed", func() {
Expand Down Expand Up @@ -301,40 +301,41 @@ var _ = Describe("Multiple Service App", func() {
Expect(svcs["back-end"].Type).To(Equal("Backend Service"))
})

It("service discovery should be enabled and working", func() {
It("service internal endpoint should be enabled and working", func() {
// The front-end service is set up to have a path called
// "/front-end/service-discovery-test" - this route
// "/front-end/service-endpoint-test" - this route
// calls a function which makes a call via the service
// discovery endpoint, "back-end.local". If that back-end
// connect/discovery endpoint, "back-end.local". If that back-end
// call succeeds, the back-end returns a response
// "back-end-service-discovery". This should be forwarded
// "back-end-service". This should be forwarded
// back to us via the front-end api.
// [test] -- http req -> [front-end] -- service-discovery -> [back-end]
// [test] -- http req -> [front-end] -- service-connect -> [back-end]
svcName := "front-end"
svc, svcShowErr := cli.SvcShow(&client.SvcShowRequest{
AppName: appName,
Name: svcName,
})
Expect(svcShowErr).NotTo(HaveOccurred())
Expect(len(svc.Routes)).To(Equal(1))
Expect(len(svc.ServiceConnects)).To(Equal(1))
Expect(svc.ServiceConnects[0].Endpoint).To(Equal(fmt.Sprintf("%s:80", svcName)))

// Calls the front end's service discovery endpoint - which should connect
// Calls the front end's service connect/discovery endpoint - which should connect
// to the backend, and pipe the backend response to us.
route := svc.Routes[0]

Expect(route.Environment).To(Equal("test"))
routeURL = route.URL

resp, fetchErr := http.Get(fmt.Sprintf("%s/service-discovery-test/", route.URL))
resp, fetchErr := http.Get(fmt.Sprintf("%s/service-endpoint-test/", route.URL))
Expect(fetchErr).NotTo(HaveOccurred())
Expect(resp.StatusCode).To(Equal(200))

// Read the response - our deployed apps should return a body with their
// name as the value.
bodyBytes, err := ioutil.ReadAll(resp.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(bodyBytes)).To(Equal("back-end-service-discovery"))

Expect(string(bodyBytes)).To(Equal("back-end-service"))
})

It("should be able to write to EFS volume", func() {
Expand Down
2 changes: 1 addition & 1 deletion e2e/multi-svc-app/www/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/julienschmidt/httprouter"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
4 changes: 2 additions & 2 deletions regression/multi-svc-app/back-end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ func HealthCheck(w http.ResponseWriter, req *http.Request, ps httprouter.Params)
w.WriteHeader(http.StatusOK)
}

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
w.Write([]byte("back-end"))
}

// ServiceDiscoveryGet just returns true no matter what
// ServiceDiscoveryGet just returns true no matter what.
func ServiceDiscoveryGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get on ServiceDiscovery endpoint Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
4 changes: 2 additions & 2 deletions regression/multi-svc-app/back-end/swap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ func HealthCheck(w http.ResponseWriter, req *http.Request, ps httprouter.Params)
w.WriteHeader(http.StatusOK)
}

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
w.Write([]byte("back-end oraoraora")) // NOTE: response body appended with "oraoraora"
}

// ServiceDiscoveryGet just returns true no matter what
// ServiceDiscoveryGet just returns true no matter what.
func ServiceDiscoveryGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get on ServiceDiscovery endpoint Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion regression/multi-svc-app/front-end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/julienschmidt/httprouter"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion regression/multi-svc-app/front-end/swap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/julienschmidt/httprouter"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion regression/multi-svc-app/www/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/julienschmidt/httprouter"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion regression/multi-svc-app/www/swap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/julienschmidt/httprouter"
)

// SimpleGet just returns true no matter what
// SimpleGet just returns true no matter what.
func SimpleGet(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
log.Println("Get Succeeded")
w.WriteHeader(http.StatusOK)
Expand Down
19 changes: 17 additions & 2 deletions site/content/docs/manifest/environment.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,24 @@ ports: 80
<span class="parent-field">network.vpc.security_group.<type\>.</span><a id="network-vpc-security-group-cidr" href="#network-vpc-security-group-cidr" class="field">`cidr`</a> <span class="type">String</span>
The IPv4 address range, in CIDR format.

<span class="parent-field">network.vpc.</span><a id="network-vpc-flowlogs" href="#network-vpc-flowlogs" class="field">`flow_logs`</a> <span class="type">Boolean</span>
Specify true to enable VPC flow logs to capture information about the IP traffic going in and out of the environment VPC.
<span class="parent-field">network.vpc.</span><a id="network-vpc-flowlogs" href="#network-vpc-flowlogs" class="field">`flow_logs`</a> <span class="type">Boolean or Map</span>
If you specify 'true', Copilot will enable VPC flow logs to capture information about the IP traffic going in and out of the environment VPC.
The default value for VPC flow logs is 14 days (2 weeks).

```yaml
network:
vpc:
flow_logs: on
```
You can customize the number of days for retention:
```yaml
network:
vpc:
flow_logs:
retention: 30
```
<span class="parent-field">network.vpc.flow_logs.</span><a id="network-vpc-flowlogs-retention" href="#network-vpc-flowlogs-retention" class="field">`retention`</a> <span class="type">String</span>
The number of days to retain the log events. See [this page](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#cfn-logs-loggroup-retentionindays) for all accepted values.

<div class="separator"></div>

Expand Down
8 changes: 8 additions & 0 deletions site/content/docs/manifest/rd-web-service.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,13 @@ Key-value pairs representing AWS tags that are passed down to your AWS App Runne

<div class="separator"></div>

<a id="count" href="#count" class="field">`count`</a> <span class="type">String</span>
Specify the name of an existing autoscaling configuration.
```yaml
count: high-availability/3
```

<div class="separator"></div>

<a id="environments" href="#environments" class="field">`environments`</a> <span class="type">Map</span>
The environment section lets you override any value in your manifest based on the environment you're in. In the example manifest above, we're overriding the `LOG_LEVEL` environment variable in our 'test' environment.