Skip to content

Commit bf6bb03

Browse files
committed
aws-go-sdk v1.15.49 (was 1.13.37), ssm buffering issue fixed within more than 10 smm batch vars, debugging logs, special flag
1 parent 93d9c25 commit bf6bb03

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

src/cli.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ func Init() (a *App) {
5555
Short('V').
5656
BoolVar(&a.log.verbose)
5757

58+
a.cli.Flag("fuck", "lets say fuck off AWS").
59+
Default("false").
60+
Hidden().
61+
BoolVar(&a.log.awsDebug)
62+
5863
ConfigureEnvCommand(a)
5964
ConfigureDotEnvCommand(a)
6065
ConfigureBackendCommand(a)

src/command_dotenv.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ func ConfigureDotEnvCommand(a *App) {
9797
}
9898

9999
func (c *DotEnvCommand) initSsmClient() {
100-
awsSession, err := session.NewSession()
100+
awsConfig := &aws.Config{
101+
LogLevel: aws.LogLevel(aws.LogOff),
102+
}
103+
104+
if c.log.awsDebug {
105+
awsConfig.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody)
106+
}
107+
awsSession, err := session.NewSession(awsConfig)
101108
c.log.must(err)
102109
c.ssm = ssm.New(awsSession)
103110
}
@@ -193,6 +200,8 @@ func (c *DotEnvCommand) processDotEnv() error {
193200
}
194201
}
195202

203+
c.log.Debug("uniqNames = %v", len(uniqNames))
204+
196205
if len(uniqNames) == 0 {
197206
// Nothing to do, no SSM parameters.
198207
return nil
@@ -205,13 +214,18 @@ func (c *DotEnvCommand) processDotEnv() error {
205214
i++
206215
}
207216

217+
c.log.Debug("names = %v", len(names))
218+
208219
for i := 0; i < len(names); i += c.batchSize {
209220
j := i + c.batchSize
210221
if j > len(names) {
211222
j = len(names)
212223
}
213224

214-
values, err := c.getParameters(names[i:j], c.decrypt, ssmVars[i:j])
225+
c.log.Debug("Batch [%v-%v], names: %v, ssmVars: %v", i, j, len(names[i:j]), len(ssmVars[i:j]))
226+
227+
values, err := c.getParameters(names[i:j], c.decrypt, ssmVars)
228+
c.log.Debug("Batch [%v-%v], values: %v", i, j, len(values))
215229
if err != nil {
216230
return err
217231
}
@@ -238,7 +252,11 @@ func (c *DotEnvCommand) getParameters(names []string, decrypt bool, ssmVars []ss
238252
input.Names = append(input.Names, aws.String(n))
239253
}
240254

255+
c.log.Debug("REQ: Batch [%v], input.Name: %v", len(ssmVars), len(input.Names))
256+
241257
resp, err := c.ssm.GetParameters(input)
258+
c.log.Debug("RESP: Batch [%v], resp.Parameters: %v", len(ssmVars), len(resp.Parameters))
259+
242260
c.log.must(err)
243261

244262
for _, v := range ssmVars {

src/logs.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Log struct {
1515
verbose bool
1616
silent bool
1717
isQuite bool
18+
awsDebug bool
1819
}
1920

2021
func (a *App) Logger() *Log {
@@ -24,6 +25,7 @@ func (a *App) Logger() *Log {
2425
verbose: false,
2526
silent: false,
2627
isQuite: false,
28+
awsDebug: false,
2729
ioWriter: os.Stdout,
2830
}
2931
}
@@ -34,6 +36,10 @@ func (l *Log) HandleSilent() {
3436
}
3537
}
3638

39+
func (l *Log) EnableAwsDebug() {
40+
l.awsDebug = true
41+
}
42+
3743
func (l *Log) Quite() {
3844
if !l.verbose {
3945
l.isQuite = true
@@ -50,6 +56,12 @@ func (l *Log) Info(format string, s ...interface{}) {
5056
showLog("INFO", fmt.Sprintf(format, s...), false, l.isQuite, l.ioWriter)
5157
}
5258

59+
func (l *Log) Debug(format string, s ...interface{}) {
60+
if l.verbose {
61+
showLog("DEBUG", fmt.Sprintf(format, s...), false, l.isQuite, l.ioWriter)
62+
}
63+
}
64+
5365
func (l *Log) Warning(format string, s ...interface{}) {
5466
showLog("WARNING", fmt.Sprintf(format, s...), false, l.isQuite, l.ioWriter)
5567
}

src/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package main
22

3-
const Version = "v0.3.5"
3+
const Version = "v0.4.0"
44

55
const CiEnvVar = "CI"
66
const TerraformLocalEnvVar = "TF_LOCAL"

0 commit comments

Comments
 (0)