Skip to content

Commit

Permalink
Merge pull request #10 from ln80/dx_bugs_fixes
Browse files Browse the repository at this point in the history
stack: upgrade to use 0.2.2
  • Loading branch information
redaLaanait authored Jul 27, 2022
2 parents ac39ddf + dd51515 commit 494fcbf
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion stack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export CRON_FUNC=$(STACK_NAME)-CronFunction
export AWS_REGION=$(REGION)
export DYNAMODB_TABLE=$(STACK_NAME)-key-table

TEST_PARAMS = AppPrefix=$(STACK_NAME) GracePeriod=$(GRACE_PERIOD)
TEST_PARAMS = GracePeriod=$(GRACE_PERIOD)

stackname:
echo $(STACK_NAME)
Expand Down
10 changes: 5 additions & 5 deletions stack/cron/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/aws/aws-lambda-go/events"
piidb "github.com/ln80/pii/dynamodb"
piidbtest "github.com/ln80/pii/dynamodb/testutil"
pii_testutil "github.com/ln80/pii/testutil"
)

var _ = (func() interface{} {
Expand All @@ -34,7 +34,7 @@ func TestHandler(t *testing.T) {
func() tc {
err := errors.New("ListNamespace mock err")
return tc{
Eng: &piidbtest.EngineMock{
Eng: &pii_testutil.EngineMock{
ListNamespaceErr: err,
},
Ok: false,
Expand All @@ -44,7 +44,7 @@ func TestHandler(t *testing.T) {
func() tc {
err := errors.New("DeleteKey mock err")
return tc{
Eng: &piidbtest.EngineMock{
Eng: &pii_testutil.EngineMock{
ListNamespaceErr: nil,
NamespaceList: []string{"ns_1, ns_2"},
DeleteKeyErr: err,
Expand All @@ -56,7 +56,7 @@ func TestHandler(t *testing.T) {
func() tc {
err := errors.New("DeleteKey mock err")
return tc{
Eng: &piidbtest.EngineMock{
Eng: &pii_testutil.EngineMock{
ListNamespaceErr: nil,
NamespaceList: []string{}, // namespaces not found
DeleteKeyErr: err,
Expand All @@ -65,7 +65,7 @@ func TestHandler(t *testing.T) {
}
}(),
{
Eng: &piidbtest.EngineMock{
Eng: &pii_testutil.EngineMock{
ListNamespaceErr: nil,
NamespaceList: []string{"ns_1, ns_2"},
DeleteKeyErr: nil,
Expand Down
3 changes: 1 addition & 2 deletions stack/cron/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/ln80/pii/core"
piidb "github.com/ln80/pii/dynamodb"
)

Expand Down Expand Up @@ -42,7 +41,7 @@ func init() {
}

svc := dynamodb.NewFromConfig(cfg)
engine = piidb.NewKeyEngine(svc, table, func(ec *core.KeyEngineConfig) {
engine = piidb.NewKeyEngine(svc, table, func(ec *piidb.KeyEngineConfig) {
if gp := os.Getenv("GRACE_PERIOD"); gp != "" {
d, err := strconv.Atoi(gp)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion stack/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/aws/aws-lambda-go v1.32.0
github.com/aws/aws-sdk-go-v2/config v1.15.8
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.6
github.com/ln80/pii v0.2.1
github.com/ln80/pii v0.2.2
)

require (
Expand Down
22 changes: 8 additions & 14 deletions stack/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@ Metadata:
ReadmeUrl: ../README.md
Labels: ['go', 'pii', 'gdpr', 'crypto-shredding', 'dynamodb']
HomePageUrl: https://github.com/ln80/pii
SemanticVersion: 0.0.2
SemanticVersion: 0.0.3
SourceCodeUrl: https://github.com/ln80/pii

Parameters:
AppPrefix:
Type: String
Description: |
A prefix is used in stack resource names (ex: myapp-pii-staging).
Default: ""

ScheduleExpression:
Type: String
Description: |
Schedule for trigger the execution of internal jobs, mainly to check and remove unused keys.
Default: rate(2 hours)
Default: rate(4 hours)

GracePeriod:
Type: Number
Expand Down Expand Up @@ -70,7 +64,7 @@ Resources:
KeyTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub ${AppPrefix}-key-table
TableName: !Sub ${AWS::StackName}-key-table
AttributeDefinitions:
-
AttributeName: _pk
Expand Down Expand Up @@ -152,9 +146,9 @@ Resources:
CronFunction:
Type: AWS::Serverless::Function
Properties:
Timeout: 15
Timeout: 30
Runtime: go1.x
FunctionName: !Sub ${AppPrefix}-CronFunction
FunctionName: !Sub ${AWS::StackName}-CronFunction
CodeUri: cron/
Handler: cron
Events:
Expand All @@ -180,8 +174,8 @@ Resources:
ComparisonOperator: GreaterThanOrEqualToThreshold
Dimensions:
- Name: FunctionName
Value: !Sub ${AppPrefix}-CronFunction
EvaluationPeriods: 1
Value: !Sub ${AWS::StackName}-CronFunction
EvaluationPeriods: 2
MetricName: Errors
Namespace: AWS/Lambda
Period: 30
Expand All @@ -192,7 +186,7 @@ Resources:

Outputs:
KeyTable:
Description: "Key Engine Table name"
Description: "Key Engine Dynamodb Table name"
Value: !Ref KeyTable

# WritePolicy:
Expand Down

0 comments on commit 494fcbf

Please sign in to comment.