Skip to content

Commit 318f1ea

Browse files
committed
Merge remote-tracking branch 'origin/primary' into primary
# Conflicts: # go.mod # go.sum
2 parents fa67418 + ba84784 commit 318f1ea

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ zip signed.zip signed
2222
These are the basic steps to create the function using the console. If you're here, you probably already know how to do this, there's nothing special about this project.
2323

2424
1. Choose **Create Function**
25-
1. Select **Author from scratch**
26-
* Function name: `bucketlist`
27-
* Runtime `Go 1.x`
28-
1. Select **Create Function**
29-
1. Select your `signed.zip` file after selecting the **Upload** button.
30-
1. In the **Handler** field enter `signed`
31-
1. Select the **Save** button in the top right.
25+
2. Select **Author from scratch**
26+
* Function name: `bucketlist`
27+
* Runtime `Go 1.x`
28+
3. Select **Create Function**
29+
4. Select your `signed.zip` file after selecting the **Upload** button.
30+
5. In the **Handler** field enter `signed`
31+
6. Select the **Save** button in the top right.
3232

3333
The function doesn't expect any input so you can configure a simple test event (e.g. `{}`) and run the function by clicking the **Test** button. The function will succeed but the output will show that access was denied. You need to add the `s3:ListAllMyBuckets` policy action to your newly created role. Run the test again and you'll see the bucket list.

cmd/signed/main.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"github.com/aws/aws-lambda-go/lambda"
66
"github.com/aws/aws-sdk-go/aws/session"
77
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
8-
"io/ioutil"
8+
"io"
99
"log"
1010
"net/http"
1111
"os"
@@ -30,7 +30,7 @@ func main() {
3030
endpoint: S3Endpoint,
3131
region: S3Region,
3232
signer: signer,
33-
client: &http.Client{},
33+
client: &http.Client{},
3434
}
3535

3636
// If this environment variable is set, assume we're running in a Lambda
@@ -57,8 +57,8 @@ type BucketLister struct {
5757
client *http.Client
5858
}
5959

60-
/**
61-
Log all the buckets available to the assumed role.
60+
/*
61+
List buckets available to the assumed role.
6262
*/
6363
func (b *BucketLister) List() error {
6464
url := fmt.Sprintf("https://%s/", b.endpoint)
@@ -76,8 +76,10 @@ func (b *BucketLister) List() error {
7676
if err != nil {
7777
return fmt.Errorf("error making request: %w", err)
7878
}
79-
defer resp.Body.Close()
80-
body, err := ioutil.ReadAll(resp.Body)
79+
defer func(Body io.ReadCloser) {
80+
_ = Body.Close()
81+
}(resp.Body)
82+
body, err := io.ReadAll(resp.Body)
8183
if err != nil {
8284
return fmt.Errorf("error reading resposne: %w", err)
8385
}

0 commit comments

Comments
 (0)