Skip to content

Commit e6e821a

Browse files
authored
Tolerate https scheme & update docs (#8)
* Tolerate https scheme & update docs Private networks may need to have the policy updated for VPC endpoints, otherwise gitpod-network-check will fail. * Cleanup
1 parent 355e5fc commit e6e821a

File tree

3 files changed

+89
-4
lines changed

3 files changed

+89
-4
lines changed

gitpod-network-check/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,74 @@ A CLI to check if your network setup is suitable for the installation of Gitpod.
100100
INFO[0122] ✅ Security group 'sg-0a6119dcb6a564fc1' deleted
101101
INFO[0122] ✅ Security group 'sg-07373362953212e54' deleted
102102
```
103+
104+
## FAQ
105+
106+
If the EC2 instances are timing out, or you cannot connect to them with Session Manager, be sure to add the following policies.
107+
108+
For the ssm vpc endpoint, add the following policy:
109+
110+
```json
111+
{
112+
"Effect": "Allow",
113+
"Action": [
114+
"*"
115+
],
116+
"Resource": [
117+
"*"
118+
],
119+
"Principal": {
120+
"AWS": [
121+
"*"
122+
]
123+
},
124+
"Condition": {
125+
"ArnEquals": {
126+
"aws:PrincipalArn": "arn:aws:iam::<aws-account-id>:role/GitpodNetworkCheck"
127+
}
128+
}
129+
},
130+
{
131+
"Effect": "Allow",
132+
"Action": [
133+
"*"
134+
],
135+
"Resource": [
136+
"*"
137+
],
138+
"Principal": {
139+
"AWS": [
140+
"*"
141+
]
142+
},
143+
"Condition": {
144+
"StringEquals": {
145+
"ec2:InstanceProfile": "arn:aws:iam::<aws-account-id>:instance-profile/GitpodNetworkCheck"
146+
}
147+
}
148+
}
149+
```
150+
151+
For the ec2messages and ssmmessages vpc endpoints, add the following policy:
152+
153+
```json
154+
{
155+
"Effect": "Allow",
156+
"Action": [
157+
"*"
158+
],
159+
"Resource": [
160+
"*"
161+
],
162+
"Principal": {
163+
"AWS": [
164+
"*"
165+
]
166+
},
167+
"Condition": {
168+
"ArnEquals": {
169+
"aws:PrincipalArn": "arn:aws:iam::<aws-account-id>:role/GitpodNetworkCheck"
170+
}
171+
}
172+
}
173+
```

gitpod-network-check/cmd/checks.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/base64"
66
"errors"
77
"fmt"
8+
"net/url"
89
"slices"
910
"sort"
1011
"strings"
@@ -129,7 +130,20 @@ var checkCommand = &cobra.Command{ // nolint:gochecknoglobals
129130
httpHosts := map[string]string{}
130131
for _, v := range networkConfig.HttpsHosts {
131132
host := strings.TrimSpace(v)
132-
httpHosts[host] = fmt.Sprintf("https://%s", host)
133+
parsedUrl, err := url.Parse(host)
134+
if err != nil {
135+
log.Warnf("🚧 Invalid Host: %s, skipping due to error: %v", host, err)
136+
continue
137+
}
138+
139+
if parsedUrl.Scheme == "" {
140+
httpHosts[host] = fmt.Sprintf("https://%s", host)
141+
} else if parsedUrl.Scheme == "https" {
142+
httpHosts[host] = parsedUrl.Host
143+
} else {
144+
log.Warnf("🚧 Unsupported scheme: %s, skipping test for %s", parsedUrl.Scheme, host)
145+
continue
146+
}
133147
}
134148
if len(httpHosts) > 0 {
135149
log.Infof("ℹ️ Checking if hosts can be reached with HTTPS from ec2 instances in the main subnets")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
log-level: debug # Options: debug, info, warning, error
22
region: eu-central-1
3-
main-subnets: subnet-0a195092eb78c7674, subnet-05db6651c2ef39639
4-
pod-subnets: subnet-00a5f0d10253fb33c, subnet-09f658fd789fc9b84
5-
https-hosts: accounts.google.com, github.com
3+
main-subnets: subnet-017c6a80f4879d851, subnet-0215744d52cd1c01f
4+
pod-subnets: subnet-00a118009d1d572a5, subnet-062288af00ba50d86
5+
https-hosts: accounts.google.com, https://github.com

0 commit comments

Comments
 (0)