Skip to content

Commit dbeb900

Browse files
authored
Merge pull request #4509 from communitybridge/dev
Merging dev to main branch to prepare for the release
2 parents 3d26519 + 5c80b55 commit dbeb900

File tree

71 files changed

+2213
-974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2213
-974
lines changed

.github/workflows/build-pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
branches:
99
- dev
1010

11-
1211
permissions:
1312
id-token: write
1413
contents: read

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,7 @@ dist/*
241241
api-postman/*
242242

243243
cla-backend/run-python-test-example-*.py
244+
245+
# LG
246+
out
247+
*.secret

aws_env.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Setting up AWS environment
2+
3+
You need to have MFA enabled for your AWS user, your `~/.aws/config` shoudl look like this:
4+
```
5+
[profile lfproduct-dev]
6+
role_arn = arn:aws:iam::395594542180:role/product-contractors-role
7+
source_profile = lfproduct
8+
region = us-east-1
9+
output = json
10+
11+
[profile lfproduct-test]
12+
role_arn = arn:aws:iam::726224182707:role/product-contractors-role
13+
source_profile = lfproduct
14+
region = us-east-1
15+
output = json
16+
17+
[profile lfproduct-staging]
18+
role_arn = arn:aws:iam::844390194980:role/product-contractors-role
19+
source_profile = lfproduct
20+
region = us-east-1
21+
output = json
22+
23+
[profile lfproduct-prod]
24+
role_arn = arn:aws:iam::716487311010:role/product-contractors-role
25+
source_profile = lfproduct
26+
region = us-east-1
27+
output = json
28+
29+
[default]
30+
region = us-east-1
31+
output = json
32+
```
33+
34+
It defines 4 profiles to use: `dev`, `staging`, `test` and `prod`.
35+
36+
You will be using one of them.
37+
38+
39+
Your `~/.aws/credentials` file shoudl initially look like this (replace `redacted`):
40+
```
41+
[lfproduct-long-term]
42+
aws_secret_access_key = [access_key_redacted]
43+
aws_access_key_id = [key_id_redacted]
44+
aws_mfa_device = arn:aws:iam::[arn_number_redacted]:mfa/[your_aws_user_redacted]
45+
46+
[default]
47+
aws_access_key_id = [key_id_redacted]
48+
aws_secret_access_key = [access_key_redacted]
49+
```
50+
51+
Now every 36 hours or less you need to refresh your MFA key by calling: `aws-mfa --force --duration 129600 --profile lfproduct`.
52+
53+
When called it adds or replaces the following section (`[lfproduct]` which is used as a source profile for `dev`, `test`, `staging` or `prod` in aws config) in `~/.aws/credentials`:
54+
```
55+
[lfproduct]
56+
assumed_role = False
57+
aws_access_key_id = [key_id_redacted]
58+
aws_secret_access_key = [secret_access_key_redacted]
59+
aws_session_token = [session_token_redacted]
60+
aws_security_token = [session_token_redacted]
61+
expiration = 2024-11-28 16:54:59 [now + 36 hours]
62+
63+
```
64+
65+
66+
Once you have all of this, you must set a correct set of environment variables to run either `python` or `golang` backends.
67+
68+
To do so you need to get credentials for a specific profile `lfproduct-`: `dev`, `test`, `staging`, `prod`. To see full one-time set of credentials you can call:
69+
- for `dev`: `` aws sts assume-role --role-arn arn:aws:iam::395594542180:role/product-contractors-role --profile lfproduct --role-session-name lfproduct-dev-session ``.
70+
- for `prod`: `` aws sts assume-role --role-arn arn:aws:iam::716487311010:role/product-contractors-role --profile lfproduct --role-session-name lfproduct-prod-session ``.
71+
72+
Note - just replace the iam::[number] depending on environment type (`[stage]`) and update `lfproduct-[stage]-name`.
73+
74+
You can set up a script like `setenv.sh` which will set all required variables, example for `dev`:
75+
```
76+
#!/bin/bash
77+
78+
rm -rf /tmp/aws
79+
cp -R /root/.aws /tmp/.aws
80+
81+
data="$(aws sts assume-role --role-arn arn:aws:iam::395594542180:role/product-contractors-role --profile lfproduct --role-session-name lfproduct-dev-session)"
82+
export AWS_ACCESS_KEY_ID="$(echo "${data}" | jq -r '.Credentials.AccessKeyId')"
83+
export AWS_SECRET_ACCESS_KEY="$(echo "${data}" | jq -r '.Credentials.SecretAccessKey')"
84+
export AWS_SESSION_TOKEN="$(echo "${data}" | jq -r '.Credentials.SessionToken')"
85+
export AWS_SECURITY_TOKEN="$(echo "${data}" | jq -r '.Credentials.SessionToken')"
86+
87+
export AWS_SDK_LOAD_CONFIG=true
88+
export AWS_PROFILE='lfproduct-dev'
89+
export AWS_REGION='us-east-1'
90+
export AWS_DEFAULT_REGION='us-east-1'
91+
export DYNAMODB_AWS_REGION='us-east-1'
92+
export REGION='us-east-1'
93+
94+
export PRODUCT_DOMAIN='dev.lfcla.com'
95+
export ROOT_DOMAIN='lfcla.dev.platform.linuxfoundation.org'
96+
export PORT='5000'
97+
export STAGE='dev'
98+
# export STAGE='local'
99+
export GH_ORG_VALIDATION=false
100+
export DISABLE_LOCAL_PERMISSION_CHECKS=true
101+
export COMPANY_USER_VALIDATION=false
102+
export CLA_SIGNATURE_FILES_BUCKET=cla-signature-files-dev
103+
```
104+
105+
Call it via `` . ./setenv.sh `` or `` source setenv.sh `` to execute in the current shell.
106+
107+
You can reset environment variables by exiting the shell session or calling the following `unsetenv.sh` in the current shell via: `` . ./unsetenv.sh `` or `` source unsetenv.sh ``:
108+
```
109+
#!/bin/bash
110+
rm -rf /tmp/.aws
111+
unset AWS_PROFILE
112+
unset AWS_REGION
113+
unset AWS_ACCESS_KEY_ID
114+
unset AWS_SECRET_ACCESS_KEY
115+
unset PRODUCT_DOMAIN
116+
unset ROOT_DOMAIN
117+
unset PORT
118+
unset STAGE
119+
unset AWS_SESSION_TOKEN
120+
unset AWS_SECURITY_TOKEN
121+
unset GH_ORG_VALIDATION
122+
unset DISABLE_LOCAL_PERMISSION_CHECKS
123+
unset COMPANY_USER_VALIDATION
124+
unset CLA_SIGNATURE_FILES_BUCKET
125+
unset DYNAMODB_AWS_REGION
126+
unset REGION
127+
unset AWS_ROLE_ARN
128+
unset AWS_TOKEN_SERIAL
129+
unset AWS_SDK_LOAD_CONFIG
130+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright The Linux Foundation and each contributor to CommunityBridge.
2+
// SPDX-License-Identifier: MIT
3+
4+
package apiclient
5+
6+
import (
7+
"context"
8+
"net/http"
9+
)
10+
11+
type APIClient interface {
12+
GetData(ctx context.Context, url string) (*http.Response, error)
13+
}
14+
15+
type RestAPIClient struct {
16+
Client *http.Client
17+
}
18+
19+
// GetData makes a get request to the specified url
20+
21+
func (c *RestAPIClient) GetData(ctx context.Context, url string) (*http.Response, error) {
22+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
23+
if err != nil {
24+
return nil, err
25+
}
26+
return c.Client.Do(req)
27+
}

cla-backend-go/api_client/mocks/mock_client.go

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)