Skip to content

Commit

Permalink
Merge pull request #1 from GSA/fix_timeout
Browse files Browse the repository at this point in the history
Fix timeout
  • Loading branch information
bryanlalexander authored Sep 19, 2019
2 parents 80fdd1b + ab29721 commit e1e5ff9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Lint Checks:** [![CircleCI](https://circleci.com/gh/GSA/grace-inventory.svg?style=svg)](https://circleci.com/gh/GSA/grace-inventory)

**Unit/Integration Tests:** [![CircleCI](https://circleci.com/gh/GSA/grace-inventory-lambda.svg?style=svg&circle-token=f42001ceadc8013191d56097c18d356b202e706e)](https://circleci.com/gh/GSA/grace-inventory-lambda)
**Unit/Integration Tests:** [![CircleCI](https://circleci.com/gh/GSA/grace-inventory-tests.svg?style=svg&circle-token=f86712ce5167665fe0d4a23d4af4fe7e9a20f7de)](https://circleci.com/gh/GSA/grace-inventory-tests)

Lambda function to list all accounts in an organization, inventory the AWS
services in those accounts and write the results to an S3 bucket as an Excel
Expand Down Expand Up @@ -78,7 +78,6 @@ Control | CSP/AWS | HOST/OS | App/DB | How is it implemented?
- **terraform**: Terraform module to deploy and configure Lambda function, S3 Bucket and IAM roles and policies
- **examples**: Examples of how to use the terraform module
- **tests**: Root module for testing deployment of Lambda function
- **integration**: Integration tests for resources deployed by Terraform

[top](#top)

Expand All @@ -94,7 +93,7 @@ download the binary release from Github or compile the handler locally.
```bash
mkdir -p release
cd release
wget https://github.com/GSA/grace-inventory/releases/download/v0.1.0/grace-inventory-lambda.zip
curl -L https://github.com/GSA/grace-inventory/releases/download/v0.1.0/grace-inventory-lambda.zip -o grace-inventory-lambda.zip
cd ..
```

Expand Down
23 changes: 7 additions & 16 deletions handler/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/aws/aws-sdk-go/service/ssm"
)

const self = "self"
var self = []*string{aws.String("self")}

// KmsKey ... extends kms.KeyMetadata to add AliasName
type KmsKey struct {
Expand Down Expand Up @@ -227,9 +227,7 @@ func Images(cfg client.ConfigProvider, cred *credentials.Credentials) ([]*ec2.Im
return nil, errors.New("nil ConfigProvider")
}
svc := ec2.New(cfg, &aws.Config{Credentials: cred})
input := &ec2.DescribeImagesInput{}
owner := self
input.Owners = []*string{&owner}
input := &ec2.DescribeImagesInput{Owners: self}
result, err := svc.DescribeImages(input)
if err != nil {
return nil, err
Expand Down Expand Up @@ -262,7 +260,8 @@ func Snapshots(cfg client.ConfigProvider, cred *credentials.Credentials) ([]*ec2
}
svc := ec2.New(cfg, &aws.Config{Credentials: cred})
var results []*ec2.Snapshot
err := svc.DescribeSnapshotsPages(&ec2.DescribeSnapshotsInput{},
input := &ec2.DescribeSnapshotsInput{OwnerIds: self}
err := svc.DescribeSnapshotsPages(input,
func(page *ec2.DescribeSnapshotsOutput, lastPage bool) bool {
results = append(results, page.Snapshots...)
return !lastPage
Expand Down Expand Up @@ -405,21 +404,13 @@ func ConfigRules(cfg client.ConfigProvider, cred *credentials.Credentials) ([]*c
return nil, err
}
rules := result.ConfigRules
token := ""
if result.NextToken != nil {
token = *result.NextToken
}
for token != "" {
input.NextToken = &token
result, err := svc.DescribeConfigRules(input)
for result.NextToken != nil {
input.NextToken = result.NextToken
result, err = svc.DescribeConfigRules(input)
if err != nil {
return nil, err
}
rules = append(rules, result.ConfigRules...)
token = ""
if result.NextToken != nil {
token = *result.NextToken
}
}
return rules, nil
}
Expand Down

0 comments on commit e1e5ff9

Please sign in to comment.