Skip to content

Commit ba9e0db

Browse files
authored
Merge pull request #30 from trussworks/build-and-release-scripts
Build and release scripts
2 parents fc34b72 + ca64122 commit ba9e0db

File tree

15 files changed

+97
-355
lines changed

15 files changed

+97
-355
lines changed

.circleci/config.yml

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,32 @@ orbs:
44
python: circleci/python@0.3.0
55

66
jobs:
7-
terratest:
7+
build-and-release:
88
docker:
9-
- image: trussworks/circleci-docker-primary:c542b22c7fb95db0a1bbe043928a457ae6fbeaca
10-
environment:
11-
- TEST_RESULTS: /tmp/test-results
9+
- image: trussworks/circleci-docker-primary:ghr
10+
steps:
11+
- checkout
12+
- run:
13+
name: Build
14+
command: scripts/build
15+
- run:
16+
name: Release
17+
command: scripts/release
18+
validate:
19+
docker:
20+
- image: trussworks/circleci-docker-primary:e66fbea875bcb788b29b1b5f59142e8231961ec5
1221
steps:
1322
- checkout
1423
- restore_cache:
1524
keys:
1625
- pre-commit-dot-cache-{{ checksum ".pre-commit-config.yaml" }}
17-
- go-mod-sources-v1-{{ checksum "go.sum" }}-{{ checksum "scripts/check-go-version" }}
18-
- run:
19-
name: Adding go binaries to $PATH
20-
command: |
21-
echo 'export PATH=${PATH}:~/go/bin' >> $BASH_ENV
22-
source $BASH_ENV
23-
- run: go get github.com/jstemmer/go-junit-report
2426
- run:
25-
name: Assume role, run pre-commit and run terratest
26-
command: |
27-
temp_role=$(aws sts assume-role \
28-
--role-arn arn:aws:iam::313564602749:role/circleci \
29-
--role-session-name circleci)
30-
export AWS_ACCESS_KEY_ID=$(echo $temp_role | jq .Credentials.AccessKeyId | xargs)
31-
export AWS_SECRET_ACCESS_KEY=$(echo $temp_role | jq .Credentials.SecretAccessKey | xargs)
32-
export AWS_SESSION_TOKEN=$(echo $temp_role | jq .Credentials.SessionToken | xargs)
33-
make test
27+
name: Run pre-commit tests
28+
command: pre-commit run --all-files
3429
- save_cache:
3530
key: pre-commit-dot-cache-{{ checksum ".pre-commit-config.yaml" }}
3631
paths:
37-
- "~/.cache/pre-commit"
38-
- save_cache:
39-
key: go-mod-sources-v1-{{ checksum "go.sum" }}-{{ checksum "scripts/check-go-version" }}
40-
paths:
41-
- "~/go/pkg/mod"
42-
- store_test_results:
43-
path: /tmp/test-results/gotest
32+
- ~/.cache/pre-commit
4433
python-test:
4534
executor: python/default
4635
steps:
@@ -58,5 +47,11 @@ workflows:
5847
version: 2
5948
validate:
6049
jobs:
61-
- terratest
50+
- validate
6251
- python-test
52+
release:
53+
jobs:
54+
- build-and-release:
55+
filters:
56+
branches:
57+
only: master

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,7 @@ venv.bak/
106106
# Terraform
107107
.terraform
108108
terraform.tfstate.backup
109-
terraform.tfstate.*.backup
109+
terraform.tfstate.*.backup
110+
111+
deployment.zip
112+
reqs/

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,3 @@ repos:
1515
rev: v0.22.0
1616
hooks:
1717
- id: markdownlint
18-
19-
- repo: git://github.com/antonbabenko/pre-commit-terraform
20-
rev: v1.30.0
21-
hooks:
22-
- id: terraform_docs
23-
- id: terraform_fmt

README.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,6 @@
33
[Changelog](./CHANGELOG.md)
44

55
<!-- markdownlint-disable MD013 MD033 -->
6-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
7-
## Requirements
8-
9-
| Name | Version |
10-
|------|---------|
11-
| terraform | >= 0.12 |
12-
13-
## Providers
14-
15-
| Name | Version |
16-
|------|---------|
17-
| aws | n/a |
18-
19-
## Inputs
20-
21-
| Name | Description | Type | Default | Required |
22-
|------|-------------|------|---------|:--------:|
23-
| enable\_auto\_expire | Enable expiring AWS Access Keys older than the defined expiration\_age. This will remove AWS API access for expired IAM users | `bool` | `true` | no |
24-
| enable\_sns\_topic | Enable use of sns topic to send messages through | `bool` | `false` | no |
25-
| expiration\_age | The age (in days) at which the keys will be considered expired and will expire if auto disable is turned on. | `number` | `90` | no |
26-
| schedule | Schedule to run the audit. Default daily between M-F at 18:00 UTC | `string` | `"cron(0 18 ? * MON-FRI *)"` | no |
27-
| slack\_message\_text | The content of the message sent to Slack directly | `string` | `""` | no |
28-
| slack\_message\_title | The title of the message sent to Slack directly | `string` | `""` | no |
29-
| slack\_url | The Slack webhook url to directly message Slack | `string` | `""` | no |
30-
| sns\_message | The message that will be sent through the SNS topic | `string` | `""` | no |
31-
| sns\_topic\_arn | SNS topic to send messages to, to be routed to slack-notify | `string` | `""` | no |
32-
| warning\_age | The age (in days) at which the keys will be considered old and the associated user will start to receive warnings | `number` | `80` | no |
33-
34-
## Outputs
35-
36-
No output.
37-
38-
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
396

407
## What is this for
418

@@ -72,17 +39,6 @@ For listing Slack account IDs in bulk look at the [user_hash_dump.py](./scripts/
7239

7340
If the information isn't specified an error will be thrown in the logs and the plain text username will be in the notification.
7441

75-
#### Deploy
76-
77-
Now all the dependencies are ready and the environment is prepped for Sleuth usage we can now deploy the lambda.
78-
79-
```hcl
80-
module "iam_sleuth" {
81-
source = "../to/module/aws-api-key-sleuth"
82-
sns_topic_arn = data.aws_sns_topic.slack_events.arn
83-
}
84-
```
85-
8642
## Screenshots
8743

8844
A user is pinged directly with an AWS key 8 days before of the 90 day limit.
@@ -102,7 +58,7 @@ A user failed to cycle their AWS key. Sleuth disabled the out of compliant key a
10258
Install dependencies:
10359

10460
```sh
105-
brew install circleci pre-commit terraform python direnv
61+
brew install circleci pre-commit python direnv ghr
10662
pre-commit install --install-hooks
10763
```
10864

@@ -123,15 +79,3 @@ To test the Python app:
12379
```sh
12480
pytest
12581
```
126-
127-
To test the module itself:
128-
129-
```sh
130-
make test
131-
```
132-
133-
or
134-
135-
```sh
136-
AWS_VAULT_KEYCHAIN_NAME=<NAME> aws-vault exec <PROFILE> -- make test
137-
```

examples/simple/main.tf

Lines changed: 0 additions & 17 deletions
This file was deleted.

go.mod

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@ module github.com/trussworks/terraform-aws-iam-sleuth
22

33
go 1.14
44

5-
require github.com/gruntwork-io/terratest v0.27.2
5+
require (
6+
github.com/github-release/github-release v0.8.1 // indirect
7+
github.com/gruntwork-io/terratest v0.27.2
8+
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect
9+
github.com/kevinburke/rest v0.0.0-20200429221318-0d2892b400f8 // indirect
10+
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
11+
github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 // indirect
12+
)

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKG
9999
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
100100
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
101101
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
102+
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
102103
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
103104
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
104105
github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 h1:yY9rWGoXv1U5pl4gxqlULARMQD7x0QG85lqEXTWysik=
@@ -114,6 +115,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
114115
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
115116
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
116117
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
118+
github.com/github-release/github-release v0.8.1 h1:FgSRfoHEu9VwiU5l+3oTa1+lhTJIeLlbCp0OUKR3EMI=
119+
github.com/github-release/github-release v0.8.1/go.mod h1:CcaWgA5VoBGz94mOHYIXavqUA8kADNZxU+5/oDQxF6o=
117120
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
118121
github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0 h1:skJKxRtNmevLqnayafdLe2AsenqRupVmzZSqrvb5caU=
119122
github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
@@ -134,6 +137,7 @@ github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
134137
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
135138
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
136139
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
140+
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
137141
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
138142
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
139143
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
@@ -198,6 +202,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
198202
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
199203
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
200204
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
205+
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 h1:KUDFlmBg2buRWNzIcwLlKvfcnujcHQRQ1As1LoaCLAM=
206+
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
201207
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
202208
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
203209
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
@@ -211,6 +217,8 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
211217
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
212218
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
213219
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
220+
github.com/kevinburke/rest v0.0.0-20200429221318-0d2892b400f8 h1:KpuDJTaTPQAyWqETt70dHX3pMz65/XYTAZymrKKNvh8=
221+
github.com/kevinburke/rest v0.0.0-20200429221318-0d2892b400f8/go.mod h1:pD+iEcdAGVXld5foVN4e24zb/6fnb60tgZPZ3P/3T/I=
214222
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
215223
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
216224
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
@@ -230,7 +238,9 @@ github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN
230238
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
231239
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
232240
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
241+
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
233242
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
243+
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
234244
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
235245
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
236246
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
@@ -320,12 +330,16 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
320330
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
321331
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
322332
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
333+
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
334+
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
323335
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
324336
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
325337
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
326338
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
327339
github.com/vdemeester/k8s-pkg-credentialprovider v0.0.0-20200107171650-7c61ffa44238/go.mod h1:JwQJCMWpUDqjZrB5jpw0f5VbN7U95zxFy1ZDpoEarGo=
328340
github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU=
341+
github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 h1:txplJASvd6b/hrE0s/Ixfpp2cuwH9IO9oZBAN9iYa4A=
342+
github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2/go.mod h1:DGCIhurYgnLz8J9ga1fMV/fbLDyUvTyrWXVWUIyJon4=
329343
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
330344
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
331345
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=

0 commit comments

Comments
 (0)