Skip to content

Commit 25a4530

Browse files
shubydojrshollyHart
authored
Fix CICD Pipeline: Upgrade Ubuntu version on Azure DevOps agent, Go dependency errors, and more (#421)
* Upgrade Ubuntu version on Azure DevOps agent * Update CHANGELOG.md * Run go mod tidy before installing linting tools * Upgrade to Go version 1.17 * chore: require terraform version to be 0.12.31 or latest 0.12.x * Publish new version when updating lambda code Co-authored-by: jrsholly <[email protected]> Co-authored-by: Hart <[email protected]>
1 parent c455880 commit 25a4530

File tree

52 files changed

+358
-423
lines changed

Some content is hidden

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

52 files changed

+358
-423
lines changed

CHANGELOG.md

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1+
## next
2+
3+
- Upgrade to Go version 1.17
4+
- Upgrade Ubuntu version on Azure DevOps Agent
5+
- Fix Go dependency errors in pipeline
6+
- Require at least `0.12.31` or later `0.12.x` versions of Terraform to recieve new provider updates
7+
18
## v0.33.8
9+
210
- Upgrade the Swagger UI dependency to remove a very dangerous vulnerability (upgrade Swagger UI to v3.51.2).
311

412
## v0.33.7
13+
514
- Update requirements packages for docs.
615
- Update gotool version for pipeline.
716

817
## v0.33.6
18+
919
- Add LakeFormation to the principal IAM policy.
1020
- Update mocks
1121
- updates requirements packages for docs
1222

1323
## v0.33.5
24+
1425
- rename pipeline credentials inputs
1526

1627
## v0.33.4
28+
1729
- Upgrade aws provider to v2.65.0 to fix SES configuration set. [terraform-provider-aws #12024](https://github.com/hashicorp/terraform-provider-aws/pull/12024)
1830
- Add firewall manager to principal IAM policy.
1931

2032
## v0.33.3
33+
2134
- Remove apigatewayv2 from the principal IAM policy.
2235
- Update to the principal IAM policy name lex-models.
2336

2437
## v0.33.2
38+
2539
- Add to the principal IAM policy:
2640
- apigatewayv2
2741
- comprehend
@@ -32,28 +46,34 @@
3246
- wafv2
3347

3448
## v0.33.1
49+
3550
- Fix populate reset queue when dynamodb returns paginated result
3651
- Add account status to last evaluated key when querying account table using global secondary index
3752
- Fix gosec issue related to G601 (CWE-118): Implicit memory aliasing in for loop
3853

3954
## v0.33.0
55+
4056
- Upgrade aws-nuke to v1.3.0
4157

4258
## v0.32.0
59+
4360
- Upgrade go to 1.15
4461
- Upgrade go mod dependencies version.
4562
- Improved test scenarios.
4663
- Add `iotanalytics:*` policy to the set of allowed services.
4764
- Increase timeout for functional test execution.
4865

4966
## v0.31.3
67+
5068
- Fix data and update visualization for codebuild reset widget and error scrappers.
5169

5270
## v0.31.2
53-
- Fix bug: Status change in account table fails for leased accounts that are expired. See https://github.com/Optum/dce/issues/344
71+
72+
- Fix bug: Status change in account table fails for leased accounts that are expired. See <https://github.com/Optum/dce/issues/344>
5473
- Fix bug: When lease starts today, fixed usage start and end date that was printed in log message.
5574

5675
## v0.30.1
76+
5777
- Added new tool in `tools` folder for generating Markdown and IAM example policy for AWS Nuke
5878
support. See README in `tools/awsnukedocgen`.
5979
- Added new services supported by DCE: Kinesis Analytics, Kinesis Video, Opsworks CM, Robomaker,
@@ -182,7 +202,6 @@ This release also removes the deprecated DynamoDB tables with "Redbox" prefixes.
182202
- RedboxLeaseProd --> Leases
183203
- UsageCache --> Usage
184204

185-
186205
**Migration Notes**
187206

188207
_DynamoDB Migration_
@@ -195,7 +214,6 @@ To do this, you may run the migration script in [/scripts/migrations/v0.21.0_ren
195214

196215
Note that this release does ***not*** delete the old tables, to provide the opportunity to migrate data. Subsequent releases _will_ destroy the old tables.
197216

198-
199217
## v0.20.0
200218

201219
- Fixed a bug in a migration script
@@ -210,12 +228,10 @@ Note that this release does ***not*** delete the old tables, to provide the oppo
210228
- Fixed issue with the lease check logic that was expiring non-expired leases.
211229
- Migration script to fix wrongly expired leases
212230

213-
214231
## v0.19.1
215232

216233
- Fixed issue with lease status reason not being set when the lease was newly created.
217234

218-
219235
## v0.19.0
220236

221237
**BREAKING CHANGES**
@@ -232,7 +248,6 @@ _Other Changes_
232248
- Refactored lease API controller and methods to organize methods into files.
233249
- Add functions to evaluate who is calling an API and what their role is
234250

235-
236251
### Migration Notes for v0.19.0
237252

238253
In order to upgrade your DCE deployment to v0.19.0, you will need to:
@@ -244,7 +259,6 @@ In order to upgrade your DCE deployment to v0.19.0, you will need to:
244259
- Marks all `*Locked` leases as `Inactive`
245260
- Update any DCE API clients to include the `expiresOn` property in their `Lease` record.
246261

247-
248262
### _Expiring Leases Model_
249263

250264
Prior to v0.19.0, leases were held in perpetuity by principals, or until the principal removed their lease via the `DELETE /leases` endpoint. Leased accounts would be "reset" at the end of the week. During reset, the lease would be marked as _Locked_, and then marked as _Active_ again after the reset was complete.
@@ -256,8 +270,8 @@ Changes for this new behavior include:
256270
- Simplified lease status model to include only two statuses: Inactive and Active.
257271
- Changed check_budget to update_lease_status and added check for expiration date.
258272
- Changed SQS and SNS notifications for lease status change to be triggered by lease status change in DB.
259-
- Added https://readthedocs.org/ style documentation, `make documentation` target
260-
- Added generation for API documentation from Swagger YAML to https://readthedocs.org/ format.
273+
- Added <https://readthedocs.org/> style documentation, `make documentation` target
274+
- Added generation for API documentation from Swagger YAML to <https://readthedocs.org/> format.
261275
- Added defaults for leases; if ID isn't specified upon save in the DB a new one will be assigned, and if
262276
the expiration date isn't defined the environment variable `DEFAULT_LEASE_LENGTH_IN_DAYS` will be used and
263277
if that is not defined, a default of seven (7) days will be used.
@@ -323,7 +337,6 @@ This release also disables `aws-nuke` by default, to prevent accidental destruct
323337
- Added publish_locks lambda
324338
- Adds a metadata property to the account object
325339

326-
327340
## v0.12.2
328341

329342
- Tag issue, updating to 0.12.2
@@ -352,7 +365,6 @@ This release also disables `aws-nuke` by default, to prevent accidental destruct
352365

353366
- **BREAKING** Add **required** budget fields to API `/leases` endpoint
354367

355-
356368
- Add local functional testing deployment method via Makefile
357369
- Target "make deploy_local" utilizes scripts/deploy_local terraform to build S3 backend
358370
- Target "make destroy_local" utilizes scripts/deploy_local terraform and modules/ terraform to destroy environment

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ vendor:
1313
go mod vendor
1414

1515
mod:
16-
-go mod init github.com/Optum/dce
16+
go mod tidy -v
1717

1818
vet:
1919
go vet

cmd/codebuild/reset/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package main
55
import (
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"log"
109
"os"
1110
"text/template"
@@ -120,7 +119,7 @@ func nukeAccount(svc *service, isDryRun bool) error {
120119
/*
121120
#nosec CWE-22: This value is derived from env vars. I.e. it is not populated with data from external users.
122121
*/
123-
conf, err := ioutil.ReadFile(configFile)
122+
conf, err := os.ReadFile(configFile)
124123
if err != nil {
125124
return err
126125
}

cmd/lambda/accounts/create_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
func TestWhenCreate(t *testing.T) {
1818
standardMultiValueHeaders := map[string][]string{
19-
"Access-Control-Allow-Origin": []string{"*"},
20-
"Content-Type": []string{"application/json"},
19+
"Access-Control-Allow-Origin": {"*"},
20+
"Content-Type": {"application/json"},
2121
}
2222
standardHeaders := map[string]string{
2323
"Access-Control-Allow-Origin": "*",

cmd/lambda/accounts/delete_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
func TestWhenDelete(t *testing.T) {
1818
standardMultiValueHeaders := map[string][]string{
19-
"Access-Control-Allow-Origin": []string{"*"},
20-
"Content-Type": []string{"application/json"},
19+
"Access-Control-Allow-Origin": {"*"},
20+
"Content-Type": {"application/json"},
2121
}
2222
standardHeaders := map[string]string{
2323
"Access-Control-Allow-Origin": "*",

cmd/lambda/accounts/get_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66
"net/http/httptest"
77
"testing"
88

@@ -75,7 +75,7 @@ func TestGetAccountByID(t *testing.T) {
7575
GetAccountByID(w, r)
7676

7777
resp := w.Result()
78-
body, err := ioutil.ReadAll(resp.Body)
78+
body, err := io.ReadAll(resp.Body)
7979

8080
assert.Nil(t, err)
8181
assert.Equal(t, tt.expResp.StatusCode, resp.StatusCode)

cmd/lambda/accounts/list_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66
"net/http/httptest"
77
"net/url"
88
"testing"
@@ -118,7 +118,7 @@ func TestGetAccounts(t *testing.T) {
118118
GetAccounts(w, r)
119119

120120
resp := w.Result()
121-
body, err := ioutil.ReadAll(resp.Body)
121+
body, err := io.ReadAll(resp.Body)
122122

123123
assert.Nil(t, err)
124124
assert.Equal(t, tt.expResp.StatusCode, resp.StatusCode)

cmd/lambda/accounts/main.go

+29-32
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"log"
7-
"net/url"
8-
9-
"github.com/aws/aws-sdk-go/service/iam"
10-
116
"github.com/Optum/dce/pkg/api"
7+
"github.com/Optum/dce/pkg/config"
128
"github.com/aws/aws-lambda-go/events"
139
"github.com/aws/aws-lambda-go/lambda"
14-
15-
"github.com/Optum/dce/pkg/config"
10+
"github.com/aws/aws-sdk-go/service/iam"
1611
"github.com/awslabs/aws-lambda-go-api-proxy/gorillamux"
12+
"log"
13+
"net/url"
1714
)
1815

1916
type accountControllerConfiguration struct {
@@ -53,39 +50,39 @@ func init() {
5350
// Routes with query strings always go first,
5451
// because the matcher will stop on the first match
5552
api.Route{
56-
"GetAccounts",
57-
"GET",
58-
"/accounts",
59-
api.EmptyQueryString,
60-
GetAccounts,
53+
Name: "GetAccounts",
54+
Method: "GET",
55+
Pattern: "/accounts",
56+
Queries: api.EmptyQueryString,
57+
HandlerFunc: GetAccounts,
6158
},
6259
api.Route{
63-
"GetAccountByID",
64-
"GET",
65-
"/accounts/{accountId}",
66-
api.EmptyQueryString,
67-
GetAccountByID,
60+
Name: "GetAccountByID",
61+
Method: "GET",
62+
Pattern: "/accounts/{accountId}",
63+
Queries: api.EmptyQueryString,
64+
HandlerFunc: GetAccountByID,
6865
},
6966
api.Route{
70-
"UpdateAccountByID",
71-
"PUT",
72-
"/accounts/{accountId}",
73-
api.EmptyQueryString,
74-
UpdateAccountByID,
67+
Name: "UpdateAccountByID",
68+
Method: "PUT",
69+
Pattern: "/accounts/{accountId}",
70+
Queries: api.EmptyQueryString,
71+
HandlerFunc: UpdateAccountByID,
7572
},
7673
api.Route{
77-
"DeleteAccount",
78-
"DELETE",
79-
"/accounts/{accountId}",
80-
api.EmptyQueryString,
81-
DeleteAccount,
74+
Name: "DeleteAccount",
75+
Method: "DELETE",
76+
Pattern: "/accounts/{accountId}",
77+
Queries: api.EmptyQueryString,
78+
HandlerFunc: DeleteAccount,
8279
},
8380
api.Route{
84-
"CreateAccount",
85-
"POST",
86-
"/accounts",
87-
api.EmptyQueryString,
88-
CreateAccount,
81+
Name: "CreateAccount",
82+
Method: "POST",
83+
Pattern: "/accounts",
84+
Queries: api.EmptyQueryString,
85+
HandlerFunc: CreateAccount,
8986
},
9087
}
9188
r := api.NewRouter(accountRoutes)

cmd/lambda/accounts/update_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66
"net/http/httptest"
77
"strings"
88
"testing"
@@ -148,7 +148,7 @@ func TestUpdateAccountByID(t *testing.T) {
148148
UpdateAccountByID(w, r)
149149

150150
resp := w.Result()
151-
body, err := ioutil.ReadAll(resp.Body)
151+
body, err := io.ReadAll(resp.Body)
152152

153153
assert.Nil(t, err)
154154
assert.Equal(t, tt.expResp.StatusCode, resp.StatusCode)

cmd/lambda/credentials_web_page/get_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"context"
5-
"io/ioutil"
5+
"io"
66
"log"
77
"net/http"
88
"os"
@@ -93,7 +93,6 @@ func readFile(path string) string {
9393
log.Fatal(err)
9494
}
9595
defer file.Close()
96-
97-
b, _ := ioutil.ReadAll(file)
96+
b, _ := io.ReadAll(file)
9897
return string(b)
9998
}

cmd/lambda/lease_auth/create.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"log"
99
"net/http"
1010
"net/url"
@@ -169,7 +169,7 @@ func (controller CreateController) getSigninToken(creds sts.Credentials) (string
169169
log.Printf("Error getting signing token: %s", err)
170170
return "", err
171171
}
172-
bodySigninToken, err := ioutil.ReadAll(resSigninToken.Body)
172+
bodySigninToken, err := io.ReadAll(resSigninToken.Body)
173173
if err != nil {
174174
log.Printf("Error getting signing token: %s", err)
175175
return "", err

cmd/lambda/leases/create_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
func TestWhenCreateSuccess(t *testing.T) {
2424
standardMultiValueHeaders := map[string][]string{
25-
"Access-Control-Allow-Origin": []string{"*"},
26-
"Content-Type": []string{"application/json"},
25+
"Access-Control-Allow-Origin": {"*"},
26+
"Content-Type": {"application/json"},
2727
}
2828
standardHeaders := map[string]string{
2929
"Access-Control-Allow-Origin": "*",
@@ -168,8 +168,8 @@ func TestWhenCreateSuccess(t *testing.T) {
168168

169169
func TestWhenCreateError(t *testing.T) {
170170
standardMultiValueHeaders := map[string][]string{
171-
"Access-Control-Allow-Origin": []string{"*"},
172-
"Content-Type": []string{"application/json"},
171+
"Access-Control-Allow-Origin": {"*"},
172+
"Content-Type": {"application/json"},
173173
}
174174
standardHeaders := map[string]string{
175175
"Access-Control-Allow-Origin": "*",

0 commit comments

Comments
 (0)