Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lifecycle args on dynamodb #96

Merged
merged 1 commit into from
Aug 18, 2021
Merged

Remove lifecycle args on dynamodb #96

merged 1 commit into from
Aug 18, 2021

Conversation

nitrocode
Copy link
Member

what

  • Describe high-level what changed as a result of these commits (i.e. in plain-english, what do these changes mean?)
  • Remove the lifecycle ignore changes for billing and read/write units

why

  • We're not using autoscaling so why ignore these arguments

references

@nitrocode nitrocode requested review from a team as code owners August 18, 2021 02:56
Copy link

@bridgecrew bridgecrew bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bridgecrew has found 3 infrastructure configuration errors in this PR ⬇️

write_capacity,
]
}

attribute {
Copy link

@bridgecrew bridgecrew bot Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   DynamoDB Tables do not have Auto Scaling enabled
    Resource: aws_dynamodb_table.with_server_side_encryption | ID: BC_AWS_GENERAL_44

How to Fix

resource "aws_dynamodb_table" "pass" {
  name           = "user"
  hash_key       = "user-id"
  billing_mode   = "PROVISIONED"
  read_capacity  = 10
  write_capacity = 10
  attribute {
    name = "user-id"
    type = "S"
  }
}

resource "aws_appautoscaling_target" "pass" {
  resource_id        = "table/${aws_dynamodb_table.pass.name}"
  scalable_dimension = "dynamodb:table:ReadCapacityUnits"
  service_namespace  = "dynamodb"
  min_capacity       = 1
  max_capacity       = 15
}

resource "aws_appautoscaling_policy" "pass" {
  name               = "rcu-auto-scaling"
  service_namespace  = aws_appautoscaling_target.pass.service_namespace
  scalable_dimension = aws_appautoscaling_target.pass.scalable_dimension
  resource_id        = aws_appautoscaling_target.pass.resource_id
  policy_type        = "TargetTrackingScaling"

  target_tracking_scaling_policy_configuration {
    predefined_metric_specification {
      predefined_metric_type = "RDSReaderAverageCPUUtilization"
      predefined_metric_type = "DynamoDBReadCapacityUtilization"
    }

// or:
    
resource "aws_dynamodb_table" "pass_on_demand" {
  name           = "user"
  hash_key       = "user-id"
  billing_mode   = "PAY_PER_REQUEST"

  attribute {
    name = "user-id"
    type = "S"
  }
}

Description

Checks if DynamoDB tables have autoscaling configuration. Note that for tables with billing_mode = "PAY_PER_REQUEST" such configuration is embedded by default.

write_capacity,
]
}

attribute {
Copy link

@bridgecrew bridgecrew bot Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   Unencrypted DynamoDB Tables
    Resource: aws_dynamodb_table.without_server_side_encryption | ID: BC_AWS_GENERAL_52

How to Fix

resource "aws_dynamodb_table" "basic-dynamodb-table" {
              name           = "GameScores"
              billing_mode   = "PROVISIONED"
              read_capacity  = 20
              write_capacity = 20
              hash_key       = "UserId"
              range_key      = "UserId"
            
              attribute {
                name = "UserId"
                type = "S"
              }
           
              server_side_encryption {
                  enabled = true
              }
            } 

Description

Checks if the Amazon DynamoDB tables are encrypted.

write_capacity,
]
}

attribute {
Copy link

@bridgecrew bridgecrew bot Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   DynamoDB Tables do not have Auto Scaling enabled
    Resource: aws_dynamodb_table.without_server_side_encryption | ID: BC_AWS_GENERAL_44

How to Fix

resource "aws_dynamodb_table" "pass" {
  name           = "user"
  hash_key       = "user-id"
  billing_mode   = "PROVISIONED"
  read_capacity  = 10
  write_capacity = 10
  attribute {
    name = "user-id"
    type = "S"
  }
}

resource "aws_appautoscaling_target" "pass" {
  resource_id        = "table/${aws_dynamodb_table.pass.name}"
  scalable_dimension = "dynamodb:table:ReadCapacityUnits"
  service_namespace  = "dynamodb"
  min_capacity       = 1
  max_capacity       = 15
}

resource "aws_appautoscaling_policy" "pass" {
  name               = "rcu-auto-scaling"
  service_namespace  = aws_appautoscaling_target.pass.service_namespace
  scalable_dimension = aws_appautoscaling_target.pass.scalable_dimension
  resource_id        = aws_appautoscaling_target.pass.resource_id
  policy_type        = "TargetTrackingScaling"

  target_tracking_scaling_policy_configuration {
    predefined_metric_specification {
      predefined_metric_type = "RDSReaderAverageCPUUtilization"
      predefined_metric_type = "DynamoDBReadCapacityUtilization"
    }

// or:
    
resource "aws_dynamodb_table" "pass_on_demand" {
  name           = "user"
  hash_key       = "user-id"
  billing_mode   = "PAY_PER_REQUEST"

  attribute {
    name = "user-id"
    type = "S"
  }
}

Description

Checks if DynamoDB tables have autoscaling configuration. Note that for tables with billing_mode = "PAY_PER_REQUEST" such configuration is embedded by default.

@nitrocode
Copy link
Member Author

/test all

@nitrocode nitrocode changed the title remove lifecycle args on dynamodb Remove lifecycle args on dynamodb Aug 18, 2021
@nitrocode
Copy link
Member Author

I checked with @mcalhoun and there is no reason to keep this here for compliance.

@nitrocode nitrocode merged commit a7657b3 into master Aug 18, 2021
@nitrocode nitrocode deleted the rm-lifecycle-args branch August 18, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the read_capacity and write_capacity from lifecycle change ignore
2 participants