Skip to content

Commit

Permalink
Update time offset update/read (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong authored May 31, 2023
1 parent 2482a06 commit 9ca102b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions resources/Time_Offset/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ vender/
sam-tests/
.hypothesis/
/awscommunity-time-offset.zip

.venv
3 changes: 2 additions & 1 deletion resources/Time_Offset/.rpdk-config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"region": null,
"target_schemas": [],
"import_path": "github.com/aws-cloudformation/awscommunity-registry-extensions/resources/Time_Offset",
"protocolVersion": "2.0.0"
"protocolVersion": "2.0.0",
"pluginVersion": "2.0.4"
}
}
20 changes: 19 additions & 1 deletion resources/Time_Offset/cmd/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,32 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: err.Error(),
HandlerErrorCode: cloudformation.HandlerErrorCodeAlreadyExists,
HandlerErrorCode: cloudformation.HandlerErrorCodeInternalFailure,
ResourceModel: nil,
}, nil
}

// convert a timestamp into the model so we have all the attributes
timeToModel(currentModel, t)

// Save the unique identifier in SSM if it exists its a duplicate
jsonData, _ := json.Marshal(currentModel)
_, err = svc.PutParameter(&ssm.PutParameterInput{
Name: &ssmParameter,
Value: aws.String(string(jsonData)),
Overwrite: aws.Bool(true),
Tier: aws.String("Standard"),
Type: aws.String("String"),
})
if err != nil {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: err.Error(),
HandlerErrorCode: cloudformation.HandlerErrorCodeInternalFailure,
ResourceModel: nil,
}, nil
}

response := handler.ProgressEvent{
OperationStatus: handler.Success,
Message: "Create complete",
Expand Down
2 changes: 1 addition & 1 deletion resources/Time_Offset/makebuild
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.PHONY: build
build:
cfn generate
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="$(TAGS)" -o bin/handler cmd/main.go
env GOOS=linux go build -ldflags="-s -w" -tags="$(TAGS)" -o bin/handler cmd/main.go
2 changes: 2 additions & 0 deletions resources/Time_Offset/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cloudformation-cli==0.2.28
cloudformation-cli-go-plugin==2.0.4

0 comments on commit 9ca102b

Please sign in to comment.