From b77b4656efcb21adf6e710688509c84a018b8dc8 Mon Sep 17 00:00:00 2001 From: Brian Terry Date: Tue, 25 Aug 2020 20:28:49 -0400 Subject: [PATCH 1/5] Add AWS Account ID, region, partition, system tags, next token in the request to handler (#157) * add request context * update test --- cfn/cfn.go | 17 +++++++++++++++++ cfn/handler/handler_test.go | 9 +++++---- cfn/handler/request.go | 29 ++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/cfn/cfn.go b/cfn/cfn.go index c5b2833f..85d70d80 100644 --- a/cfn/cfn.go +++ b/cfn/cfn.go @@ -119,9 +119,18 @@ func makeEventFunc(h Handler) eventFunc { if err := validateEvent(event); err != nil { return re.report(event, "validation error", err, invalidRequestError) } + rctx := handler.RequestContext{ + StackID: event.StackID, + Region: event.Region, + AccountID: event.AWSAccountID, + StackTags: event.RequestData.StackTags, + SystemTags: event.RequestData.SystemTags, + NextToken: event.NextToken, + } request := handler.NewRequest( event.RequestData.LogicalResourceID, event.CallbackContext, + rctx, credentials.SessionFromCredentialsProvider(&event.RequestData.CallerCredentials), event.RequestData.PreviousResourceProperties, event.RequestData.ResourceProperties, @@ -179,9 +188,17 @@ func makeTestEventFunc(h Handler) testEventFunc { if err != nil { return handler.NewFailedEvent(err), err } + rctx := handler.RequestContext{ + Region: event.Request.Region, + AccountID: event.Request.AWSAccountID, + StackTags: event.Request.DesiredResourceTags, + SystemTags: event.Request.SystemTags, + NextToken: event.Request.NextToken, + } request := handler.NewRequest( event.Request.LogicalResourceIdentifier, event.CallbackContext, + rctx, credentials.SessionFromCredentialsProvider(&event.Credentials), event.Request.PreviousResourceState, event.Request.DesiredResourceState, diff --git a/cfn/handler/handler_test.go b/cfn/handler/handler_test.go index ae997c46..597993ef 100644 --- a/cfn/handler/handler_test.go +++ b/cfn/handler/handler_test.go @@ -12,11 +12,12 @@ type Props struct { } func TestNewRequest(t *testing.T) { + rctx := RequestContext{} t.Run("Happy Path", func(t *testing.T) { prev := Props{} curr := Props{} - req := NewRequest("foo", nil, nil, []byte(`{"color": "red"}`), []byte(`{"color": "green"}`)) + req := NewRequest("foo", nil, rctx, nil, []byte(`{"color": "red"}`), []byte(`{"color": "green"}`)) if err := req.UnmarshalPrevious(&prev); err != nil { t.Fatalf("Unable to unmarshal props: %v", err) @@ -42,7 +43,7 @@ func TestNewRequest(t *testing.T) { t.Run("ResourceProps", func(t *testing.T) { t.Run("Invalid Body", func(t *testing.T) { - req := NewRequest("foo", nil, nil, []byte(``), []byte(``)) + req := NewRequest("foo", nil, rctx, nil, []byte(``), []byte(``)) invalid := struct { Color *int `json:"color"` @@ -60,7 +61,7 @@ func TestNewRequest(t *testing.T) { }) t.Run("Invalid Marshal", func(t *testing.T) { - req := NewRequest("foo", nil, nil, []byte(`{"color": "ref"}`), []byte(`---BAD JSON---`)) + req := NewRequest("foo", nil, rctx, nil, []byte(`{"color": "ref"}`), []byte(`---BAD JSON---`)) var invalid Props @@ -78,7 +79,7 @@ func TestNewRequest(t *testing.T) { t.Run("PreviousResourceProps", func(t *testing.T) { t.Run("Invalid Marshal", func(t *testing.T) { - req := NewRequest("foo", nil, nil, []byte(`---BAD JSON---`), []byte(`{"color": "green"}`)) + req := NewRequest("foo", nil, rctx, nil, []byte(`---BAD JSON---`), []byte(`{"color": "green"}`)) var invalid Props diff --git a/cfn/handler/request.go b/cfn/handler/request.go index 69d0955f..f44c2cb6 100644 --- a/cfn/handler/request.go +++ b/cfn/handler/request.go @@ -27,6 +27,10 @@ type Request struct { // identifier which can be used to continue polling for stabilization CallbackContext map[string]interface{} + // The RequestContext is information about the current + // invocation. + RequestContext RequestContext + // An authenticated AWS session that can be used with the AWS Go SDK Session *session.Session @@ -34,14 +38,37 @@ type Request struct { resourcePropertiesBody []byte } +// RequestContext represents information about the current +// invocation request of the handler. +type RequestContext struct { + // The stack ID of the CloudFormation stack + StackID string + + // The Region of the requester + Region string + + // The Account ID of the requester + AccountID string + + // The stack tags associated with the cloudformation stack + StackTags map[string]string + + // The SystemTags associated with the request + SystemTags map[string]string + + // The NextToken provided in the request + NextToken string +} + // NewRequest returns a new Request based on the provided parameters -func NewRequest(id string, ctx map[string]interface{}, sess *session.Session, previousBody, body []byte) Request { +func NewRequest(id string, ctx map[string]interface{}, requestCTX RequestContext, sess *session.Session, previousBody, body []byte) Request { return Request{ LogicalResourceID: id, CallbackContext: ctx, Session: sess, previousResourcePropertiesBody: previousBody, resourcePropertiesBody: body, + RequestContext: requestCTX, } } From cb80be9ce341b2a8e9112c056f0987b6b0d869d3 Mon Sep 17 00:00:00 2001 From: Pat Myron Date: Tue, 25 Aug 2020 19:52:56 -0700 Subject: [PATCH 2/5] wildcard .gitignore pattern in case rpdk.log rotates (#158) https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/pull/110#discussion_r468196022 --- python/rpdk/go/data/go.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rpdk/go/data/go.gitignore b/python/rpdk/go/data/go.gitignore index bb0947ad..ac1ee256 100644 --- a/python/rpdk/go/data/go.gitignore +++ b/python/rpdk/go/data/go.gitignore @@ -3,7 +3,7 @@ ._* # our logs -rpdk.log +rpdk.log* #compiled file bin/ From c1261e85f57d527c71d9f5a5a4a96018a442fffa Mon Sep 17 00:00:00 2001 From: Brian Terry Date: Thu, 27 Aug 2020 18:13:19 -0400 Subject: [PATCH 3/5] Fix log throttle (#159) * only create the log group once * update test * remove extra line --- cfn/cfn.go | 23 ++++++++---- cfn/logging/cloudwatchlogs.go | 16 ++------- cfn/logging/cloudwatchlogs_test.go | 58 +++++++++++++++--------------- cfn/logging/logging.go | 2 -- 4 files changed, 47 insertions(+), 52 deletions(-) diff --git a/cfn/cfn.go b/cfn/cfn.go index 85d70d80..74bdc2ec 100644 --- a/cfn/cfn.go +++ b/cfn/cfn.go @@ -7,6 +7,7 @@ import ( "log" "os" "path" + "sync" "time" "github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/cfnerr" @@ -39,6 +40,8 @@ const ( listAction = "LIST" ) +var once sync.Once + // Handler is the interface that all resource providers must implement // // Each method of Handler maps directly to a CloudFormation action. @@ -97,15 +100,21 @@ type handlerFunc func(request handler.Request) handler.ProgressEvent // MakeEventFunc is the entry point to all invocations of a custom resource func makeEventFunc(h Handler) eventFunc { return func(ctx context.Context, event *event) (response, error) { - //pls := credentials.SessionFromCredentialsProvider(&event.RequestData.PlatformCredentials) ps := credentials.SessionFromCredentialsProvider(&event.RequestData.ProviderCredentials) - l, err := logging.NewCloudWatchLogsProvider( - cloudwatchlogs.New(ps), - event.RequestData.ProviderLogGroupName, - ) - // Set default logger to output to CWL in the provider account - logging.SetProviderLogOutput(l) m := metrics.New(cloudwatch.New(ps), event.ResourceType) + once.Do(func() { + l, err := logging.NewCloudWatchLogsProvider( + cloudwatchlogs.New(ps), + event.RequestData.ProviderLogGroupName, + ) + if err != nil { + log.Printf("Error: %v, Logging to Stdout", err) + m.PublishExceptionMetric(time.Now(), event.Action, err) + l = os.Stdout + } + // Set default logger to output to CWL in the provider account + logging.SetProviderLogOutput(l) + }) re := newReportErr(m) if err := scrubFiles("/tmp"); err != nil { log.Printf("Error: %v", err) diff --git a/cfn/logging/cloudwatchlogs.go b/cfn/logging/cloudwatchlogs.go index f82772db..5357a331 100644 --- a/cfn/logging/cloudwatchlogs.go +++ b/cfn/logging/cloudwatchlogs.go @@ -1,7 +1,6 @@ package logging import ( - "context" "io" "log" "os" @@ -132,10 +131,7 @@ func (p *cloudWatchLogsProvider) Write(b []byte) (int, error) { // // do something // } func CloudWatchLogGroupExists(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string) (bool, error) { - ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500) - defer cancel() - - resp, err := client.DescribeLogGroupsWithContext(ctx, &cloudwatchlogs.DescribeLogGroupsInput{ + resp, err := client.DescribeLogGroups(&cloudwatchlogs.DescribeLogGroupsInput{ Limit: aws.Int64(1), LogGroupNamePrefix: aws.String(logGroupName), }) @@ -163,10 +159,7 @@ func CloudWatchLogGroupExists(client cloudwatchlogsiface.CloudWatchLogsAPI, logG // panic("Unable to create log group", err) // } func CreateNewCloudWatchLogGroup(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string) error { - ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500) - defer cancel() - - if _, err := client.CreateLogGroupWithContext(ctx, &cloudwatchlogs.CreateLogGroupInput{ + if _, err := client.CreateLogGroup(&cloudwatchlogs.CreateLogGroupInput{ LogGroupName: aws.String(logGroupName), }); err != nil { return err @@ -177,10 +170,7 @@ func CreateNewCloudWatchLogGroup(client cloudwatchlogsiface.CloudWatchLogsAPI, l // CreateNewLogStream creates a log stream inside of a LogGroup func CreateNewLogStream(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string, logStreamName string) error { - ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500) - defer cancel() - - _, err := client.CreateLogStreamWithContext(ctx, &cloudwatchlogs.CreateLogStreamInput{ + _, err := client.CreateLogStream(&cloudwatchlogs.CreateLogStreamInput{ LogGroupName: aws.String(logGroupName), LogStreamName: aws.String(logStreamName), }) diff --git a/cfn/logging/cloudwatchlogs_test.go b/cfn/logging/cloudwatchlogs_test.go index cb4f6eac..4e8c8174 100644 --- a/cfn/logging/cloudwatchlogs_test.go +++ b/cfn/logging/cloudwatchlogs_test.go @@ -1,12 +1,10 @@ package logging import ( - "context" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface" ) @@ -14,7 +12,7 @@ import ( func TestCloudWatchLogProvider(t *testing.T) { t.Run("Init", func(t *testing.T) { client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return &cloudwatchlogs.DescribeLogGroupsOutput{ LogGroups: []*cloudwatchlogs.LogGroup{ &cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix}, @@ -22,11 +20,11 @@ func TestCloudWatchLogProvider(t *testing.T) { }, nil }, - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, nil }, - CreateLogStreamFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { + CreateLogStreamFn: func(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { return nil, nil }, @@ -45,15 +43,15 @@ func TestCloudWatchLogProvider(t *testing.T) { t.Run("Init Error Exists", func(t *testing.T) { client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return nil, awserr.New("Invalid", "Invalid", nil) }, - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, nil }, - CreateLogStreamFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { + CreateLogStreamFn: func(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { return nil, nil }, @@ -72,17 +70,17 @@ func TestCloudWatchLogProvider(t *testing.T) { t.Run("Init Error Unable to Create", func(t *testing.T) { client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return &cloudwatchlogs.DescribeLogGroupsOutput{ LogGroups: []*cloudwatchlogs.LogGroup{}, }, nil }, - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, awserr.New("Invalid", "Invalid", nil) }, - CreateLogStreamFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { + CreateLogStreamFn: func(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { return nil, nil }, @@ -101,7 +99,7 @@ func TestCloudWatchLogProvider(t *testing.T) { t.Run("Write", func(t *testing.T) { client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return &cloudwatchlogs.DescribeLogGroupsOutput{ LogGroups: []*cloudwatchlogs.LogGroup{ &cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix}, @@ -109,11 +107,11 @@ func TestCloudWatchLogProvider(t *testing.T) { }, nil }, - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, nil }, - CreateLogStreamFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { + CreateLogStreamFn: func(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { return nil, nil }, @@ -143,7 +141,7 @@ func TestCloudWatchLogProvider(t *testing.T) { t.Run("Write Error", func(t *testing.T) { writeCount := 0 client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return &cloudwatchlogs.DescribeLogGroupsOutput{ LogGroups: []*cloudwatchlogs.LogGroup{ &cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix}, @@ -151,11 +149,11 @@ func TestCloudWatchLogProvider(t *testing.T) { }, nil }, - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, nil }, - CreateLogStreamFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { + CreateLogStreamFn: func(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { return nil, nil }, @@ -187,7 +185,7 @@ func TestCloudWatchLogProvider(t *testing.T) { func TestCloudWatchLogGroupExists(t *testing.T) { t.Run("Success", func(t *testing.T) { client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return &cloudwatchlogs.DescribeLogGroupsOutput{ LogGroups: []*cloudwatchlogs.LogGroup{ &cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix}, @@ -203,7 +201,7 @@ func TestCloudWatchLogGroupExists(t *testing.T) { t.Run("Error", func(t *testing.T) { client := CallbackCloudWatchLogs{ - DescribeLogGroupsFn: func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return nil, awserr.New("Invalid", "Invalid", nil) }, } @@ -217,7 +215,7 @@ func TestCloudWatchLogGroupExists(t *testing.T) { func TestCreateCloudWatchLogGroup(t *testing.T) { t.Run("Success", func(t *testing.T) { client := CallbackCloudWatchLogs{ - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, nil }, } @@ -229,7 +227,7 @@ func TestCreateCloudWatchLogGroup(t *testing.T) { t.Run("Error", func(t *testing.T) { client := CallbackCloudWatchLogs{ - CreateLogGroupFn: func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + CreateLogGroupFn: func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { return nil, awserr.New("Invalid", "Invalid", nil) }, } @@ -243,22 +241,22 @@ func TestCreateCloudWatchLogGroup(t *testing.T) { type CallbackCloudWatchLogs struct { cloudwatchlogsiface.CloudWatchLogsAPI - DescribeLogGroupsFn func(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) - CreateLogGroupFn func(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) - CreateLogStreamFn func(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) + DescribeLogGroupsFn func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) + CreateLogGroupFn func(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) + CreateLogStreamFn func(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) PutLogEventsFn func(input *cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) } -func (cwl CallbackCloudWatchLogs) DescribeLogGroupsWithContext(ctx context.Context, input *cloudwatchlogs.DescribeLogGroupsInput, opts ...request.Option) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { - return cwl.DescribeLogGroupsFn(ctx, input) +func (cwl CallbackCloudWatchLogs) DescribeLogGroups(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { + return cwl.DescribeLogGroupsFn(input) } -func (cwl CallbackCloudWatchLogs) CreateLogGroupWithContext(ctx context.Context, input *cloudwatchlogs.CreateLogGroupInput, opts ...request.Option) (*cloudwatchlogs.CreateLogGroupOutput, error) { - return cwl.CreateLogGroupFn(ctx, input) +func (cwl CallbackCloudWatchLogs) CreateLogGroup(input *cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error) { + return cwl.CreateLogGroupFn(input) } -func (cwl CallbackCloudWatchLogs) CreateLogStreamWithContext(ctx context.Context, input *cloudwatchlogs.CreateLogStreamInput, opts ...request.Option) (*cloudwatchlogs.CreateLogStreamOutput, error) { - return cwl.CreateLogStreamFn(ctx, input) +func (cwl CallbackCloudWatchLogs) CreateLogStream(input *cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) { + return cwl.CreateLogStreamFn(input) } func (cwl CallbackCloudWatchLogs) PutLogEvents(input *cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) { diff --git a/cfn/logging/logging.go b/cfn/logging/logging.go index 72827211..6ada8050 100644 --- a/cfn/logging/logging.go +++ b/cfn/logging/logging.go @@ -25,8 +25,6 @@ const ( // SetProviderLogOutput ... func SetProviderLogOutput(w io.Writer) { - os.Stderr = nil - os.Stdout = nil log.SetOutput(w) From 62fb7b394f63fbd2e9ed6f45ac59c7a7e02bcdce Mon Sep 17 00:00:00 2001 From: Niko Eckerskorn Date: Tue, 1 Sep 2020 11:56:08 +1000 Subject: [PATCH 4/5] Update "generated file" hint to follow go convention. (#161) Go has a documented[1] convention identifying "generated" files: > To convey to humans and machine tools that code is generated, > generated source should have a line that matches the following > regular expression (in Go syntax): > ^// Code generated .* DO NOT EDIT\.$ [1]: https://golang.org/pkg/cmd/go/internal/generate/ --- python/rpdk/go/templates/main.go.tple | 6 +----- python/rpdk/go/templates/types.go.tple | 9 ++------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/python/rpdk/go/templates/main.go.tple b/python/rpdk/go/templates/main.go.tple index 5acac129..4bb57f18 100644 --- a/python/rpdk/go/templates/main.go.tple +++ b/python/rpdk/go/templates/main.go.tple @@ -1,3 +1,4 @@ +// Code generated by 'cfn generate', changes will be undone by the next invocation. DO NOT EDIT. package main import ( @@ -10,11 +11,6 @@ import ( "{{ path }}" ) -/* -This file is autogenerated, do not edit; -changes will be undone by the next 'cfn generate' command. -*/ - // Handler is a container for the CRUDL actions exported by resources type Handler struct{} diff --git a/python/rpdk/go/templates/types.go.tple b/python/rpdk/go/templates/types.go.tple index 2178a2fe..e54eac02 100644 --- a/python/rpdk/go/templates/types.go.tple +++ b/python/rpdk/go/templates/types.go.tple @@ -1,12 +1,7 @@ +// Code generated by 'cfn generate', changes will be undone by the next invocation. DO NOT EDIT. +// Updates to this type are made my editing the schema file and executing the 'generate' command. package resource -/* -This file is autogenerated, do not edit; -changes will be undone by the next 'generate' command. - -Updates to this type are made my editing the schema file -and executing the 'generate' command -*/ {% for model_name, properties in models.items() %} {% if model_name == "ResourceModel" %} From be58f55910a11d66c17f639aa86f17a51e5ab7ec Mon Sep 17 00:00:00 2001 From: omkhegde <69654230+omkhegde@users.noreply.github.com> Date: Fri, 4 Sep 2020 08:27:38 -0700 Subject: [PATCH 5/5] Bump up python plugin version to 2.0.1 (#166) --- python/rpdk/go/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rpdk/go/__init__.py b/python/rpdk/go/__init__.py index 5684f64a..82387703 100644 --- a/python/rpdk/go/__init__.py +++ b/python/rpdk/go/__init__.py @@ -1,5 +1,5 @@ import logging -__version__ = "2.0.0" +__version__ = "2.0.1" logging.getLogger(__name__).addHandler(logging.NullHandler())