aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.5k stars 1.17k forks source link

Bug: DBProxyTargetGroup Creation is very slow when using SAM deploy #7403

Closed Guydada closed 5 days ago

Guydada commented 2 weeks ago

Description:

When deploying a stack defining an RDS database including a DBProxyTargetGroup, it takes more than 45 minutes to finish the deployment.

Steps to reproduce:

Include a proxy group definition:

DBInstance:
    Type: AWS::RDS::DBInstance
    Properties:
      Engine: aurora-postgresql
      DBClusterIdentifier: !Ref NVSearchDBCluster
      DBInstanceClass: db.r7g.xlarge
      PubliclyAccessible: false
      EnablePerformanceInsights: true
      PerformanceInsightsRetentionPeriod: 7

DBProxy:
  Type: AWS::RDS::DBProxy
  Properties:
    DBProxyName: nvsearch-db-proxy
    EngineFamily: POSTGRESQL
    RoleArn: !GetAtt DBProxyRole.Arn
    IdleClientTimeout: 120
    RequireTLS: true
    DebugLogging: false
    Auth:
      - { AuthScheme: SECRETS, SecretArn: !Ref DBProxySecret }

    VpcSubnetIds:
      - !Ref Subnet1
      - !Ref Subnet2
      - !Ref Subnet3
    VpcSecurityGroupIds:
      - !Ref RDSSecurityGroupId

DBProxyTargetGroup:
  Type: AWS::RDS::DBProxyTargetGroup
  DependsOn:
    - DBInstance
  Properties:
    DBProxyName: !Ref DBProxy
    TargetGroupName: default
    DBClusterIdentifiers:
      - !Ref NVSearchDBCluster
    ConnectionPoolConfigurationInfo:
      MaxConnectionsPercent: 5
      MaxIdleConnectionsPercent: 4
      ConnectionBorrowTimeout: 120

Run:

sam build && sam deploy

Observed result:

Deployment takes > 45 minutes to complete successfully

Expected result:

Faster deployment times, as this complicates CICD pipelines

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 22.04
  2. sam --version: SAM CLI, version 1.123.0
  3. AWS region: us-east-2
{
  "version": "1.123.0",
  "system": {
    "python": "3.11.8",
    "os": "Linux-6.8.0-40-generic-x86_64-with-glibc2.35"
  },
  "additional_dependencies": {
    "docker_engine": "27.1.2",
    "aws_cdk": "2.151.0 (build b8289e2)",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
mildaniel commented 2 weeks ago

Hi @Guydada, unfortunately CloudFormation deployment times are not something we can control through SAM CLI. Under the hood, we use CloudFormation SDKs to create and execute changesets. The rest is handled by the CloudFormation service.

hnnasit commented 5 days ago

Closing as there is no action to be taken from the SAM CLI side. Please open a new issue if you still have questions or concerns.

github-actions[bot] commented 5 days ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.