Amazon DocumentDB Cluster

Creates an Amazon DocumentDB cluster and primary instance.

4

Votes

Description:  "AWS CloudFormation Sample Template DocumentDB_Quick_Create: Sample template showing how to create a DocumentDB DB cluster and DB instance. **WARNING** This template creates an Amazon DocumentDB resources and you will be billed for the AWS resources used if you create a stack from this template."

Parameters: 
  DBClusterName: 
    Default: "MyCluster"
    Description : "Cluster name"
    Type: "String"
    MinLength: "1"
    MaxLength: "64"
    AllowedPattern : "[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*"
    ConstraintDescription : "Must begin with a letter and contain only alphanumeric characters."

  DBInstanceName: 
    Default: "MyInstance"
    Description : "Instance name"
    Type: "String"
    MinLength: "1"
    MaxLength: "64"
    AllowedPattern : "[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*"
    ConstraintDescription : "Must begin with a letter and contain only alphanumeric characters."

  MasterUser:
    NoEcho: "true"
    Description : "The database admin account username"
    Type: "String"
    MinLength: "1"
    MaxLength: "16"
    AllowedPattern: "[a-zA-Z][a-zA-Z0-9]*"
    ConstraintDescription : "Must begin with a letter and contain only alphanumeric characters."

  MasterPassword:
    NoEcho: "true"
    Description : "The database admin account password"
    Type: "String"
    MinLength: "1"
    MaxLength: "41"
    AllowedPattern : "[a-zA-Z0-9]+"
    ConstraintDescription : "must contain only alphanumeric characters."

  DBInstanceClass:
    Description : "Instance class. Please refer to: https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-classes-by-region"
    Type: "String"
    AllowedValues:
      - db.r4.large
      - db.r4.xlarge
      - db.r4.2xlarge
      - db.r4.4xlarge
      - db.r4.8xlarge
      - db.r4.16xlarge
      - db.r5.large
      - db.r5.xlarge
      - db.r5.2xlarge
      - db.r5.4xlarge
      - db.r5.12xlarge
      - db.r5.24xlarge                             
    ConstraintDescription : "Instance type must be of the ones supported for the region. Please refer to: https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-classes-by-region"  

Resources:
  DBCluster:
    Type: "AWS::DocDB::DBCluster"
    DeletionPolicy: Delete
    Properties:
      DBClusterIdentifier: !Ref DBClusterName
      MasterUsername: !Ref MasterUser
      MasterUserPassword: !Ref MasterPassword

  DBInstance:
    Type: "AWS::DocDB::DBInstance"
    Properties:
      DBClusterIdentifier: !Ref DBCluster
      DBInstanceIdentifier: !Ref DBInstanceName
      DBInstanceClass: !Ref DBInstanceClass
    DependsOn: DBCluster

Outputs:
  ClusterId:
    Value: !Ref DBCluster
  ClusterEndpoint:
    Value: !GetAtt DBCluster.Endpoint
  ClusterReadEndpoint:
    Value: !GetAtt DBCluster.ReadEndpoint
  ClusterPort:
    Value: !GetAtt DBCluster.Port
  InstanceId:
    Value: !Ref DBInstance
  InstancePort:
    Value: !GetAtt DBInstance.Port
  InstanceEndpoint:
    Value: !GetAtt DBInstance.Endpoint

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png