Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package monsanto
    Definition Classes
    com
  • package arch
    Definition Classes
    monsanto
  • package cloudformation
    Definition Classes
    arch
  • package model

    A DSL to create consistent, type-safe AWS CloudFormation templates.

    A DSL to create consistent, type-safe AWS CloudFormation templates.

    The low-level DSL closely adheres to the objects and parameters in the CloudFormation template JSON specification. If you intend to use this DSL to create CloudFormation templates, it would behoove you to familiarize yourself with the CloudFormation documentation.

    In addition to the low-level, DSL, there are several higher-order builders and convenience methods. See com.monsanto.arch.cloudformation.model.simple.Builders for more information on these helper methods.

    For a discussion of the features and approach of this library, read our blog post.

    Sample usage:

    import com.monsanto.arch.cloudformation.model._
    import com.monsanto.arch.cloudformation.model.resource._
    import com.monsanto.arch.cloudformation.model.simple.Builders._
    
    object SimpleVPC extends VPCWriter {
      val ownerParameter = StringParameter(
        name = "Owner",
        Description = Some("Individual responsible for this template"),
        MinLength = Some(StringBackedInt(1)),
        MaxLength = Some(StringBackedInt(64)),
        AllowedPattern = Some("[-_ a-zA-Z0-9]*"),
        ConstraintDescription = Some("Can contain only alphanumeric characters, spaces, dashes and underscores.")
      )
      val keyNameParameter = `AWS::EC2::KeyPair::KeyName_Parameter`(
        name = "KeyName",
        Description = Some("Name of an existing EC2 KeyPair to enable SSH access to the instances"),
        ConstraintDescription = Some("Value must be a valid AWS key pair name in your account.")
      )
      val allowSSHFromParameter = CidrBlockParameter(
        name = "AllowSSHFrom",
        Description = Some("The net block (CIDR) that SSH is available to.")
      )
      val simpleParameters = Seq(
        ownerParameter,
        keyNameParameter,
        allowSSHFromParameter
      )
    
      val simpleConditions = Seq(
        Condition(
          name = "ShouldDisablePassword",
          function = `Fn::Equals`(
            a = ParameterRef(ownerParameter),
            b = StringToken("rms")
          )
        )
      )
    
      val amazonLinuxAMIMapping = Mapping[AMIId](
        "AmazonLinuxAMI",
        Map(
          "us-east-1"      -> Map("AMI" -> AMIId("ami-1ecae776")),
          "us-west-1"      -> Map("AMI" -> AMIId("ami-d114f295")),
          "us-west-2"      -> Map("AMI" -> AMIId("ami-e7527ed7")),
          "eu-west-1"      -> Map("AMI" -> AMIId("ami-a10897d6")),
          "ap-southeast-1" -> Map("AMI" -> AMIId("ami-68d8e93a")),
          "ap-southeast-2" -> Map("AMI" -> AMIId("ami-fd9cecc7")),
          "ap-northeast-1" -> Map("AMI" -> AMIId("ami-cbf90ecb"))
        )
      )
      val simpleMappings = Seq(amazonLinuxAMIMapping)
    
      val simpleResourceAndOutputs = withVpc(CidrBlock(10, 0, 0, 0, 16)) { implicit vpc =>
        val (internetGatewayResource, gatewayToInternetResource) = withInternetGateway
        val publicRouteTable = withRouteTable("Public", 1)
        val publicRouteTableRoute = publicRouteTable.withRoute(
          visibility = "Public",
          routeTableOrdinal = 1,
          routeOrdinal = 1,
          connectionBobber = InternetGatewayRoute(ResourceRef(internetGatewayResource))
        )
        val gatewayStuff = Template.fromResource(internetGatewayResource) ++
          gatewayToInternetResource ++
          publicRouteTable ++
          publicRouteTableRoute
        val withinAZ = withAZ("us-east-1a") { implicit az =>
          withSubnet("PubSubnet1", CidrBlock(10, 0, 0, 1, 24)) { implicit pubSubnet =>
            val bastionName = "bastion"
            val bastion = ec2(
              name = bastionName,
              InstanceType = "t2.micro",
              KeyName = ParameterRef(keyNameParameter),
              ImageId = `Fn::FindInMap`[AMIId](MappingRef(amazonLinuxAMIMapping), `AWS::Region`, "AMI"),
              SecurityGroupIds = Seq(),
              Tags = AmazonTag.fromName(bastionName),
              UserData = Some(`Fn::Base64`(
                `Fn::Join`("",
                  Seq[Token[String]](
                    "#!/bin/bash -v\n",
                    "yum update -y --security\n",
                    "# EOF\n"
                  )
                )
              ))
            )
            val sshToBastion = ParameterRef(allowSSHFromParameter) ->- 22 ->- bastion
            Template.fromSecurityGroupRoutable(bastion) ++
              bastion.map(_.withEIP("BastionEIP").andOutput("BastionEIP", "Bastion Host EIP")) ++
              Template.collapse(sshToBastion)
          }
        }
        gatewayStuff ++
          withinAZ
      }
      val simpleTemplate = simpleResourceAndOutputs ++
        Template(
          AWSTemplateFormatVersion = Some("2010-09-09"),
          Description = Some("Simple template"),
          Parameters = Some(simpleParameters),
          Conditions = Some(simpleConditions),
          Mappings = Some(simpleMappings),
          Resources = Seq.empty,
          Outputs = None
        )
      writeStaxModule("vpc-simple.json", simpleTemplate)
    }
    SimpleVPC

    The above code utilizes the DSL to create a simple AWS VPC utilizing a single Availability Zone having a single public subnet and a single "bastion" instance. The template output is the IP address of the EIP it creates. It also shows examples of creating and using Parameters and Mappings. A Condition is created but not used.

    Definition Classes
    cloudformation
  • package resource
    Definition Classes
    model
  • object Period extends DefaultJsonProtocol
    Definition Classes
    resource
  • BigDecimalJsonFormat
  • BigIntJsonFormat
  • BooleanJsonFormat
  • ByteJsonFormat
  • CharJsonFormat
  • DAY
  • DoubleJsonFormat
  • FloatJsonFormat
  • IntJsonFormat
  • JsValueFormat
  • LongJsonFormat
  • MONTH
  • OptionFormat
  • RootJsArrayFormat
  • RootJsObjectFormat
  • ShortJsonFormat
  • StringJsonFormat
  • SymbolJsonFormat
  • UnitJsonFormat
  • WEEK

object WEEK extends Period with Product with Serializable

Linear Supertypes
Serializable, Serializable, Product, Equals, Period, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. WEEK
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. Period
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  15. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Period

Inherited from AnyRef

Inherited from Any

Ungrouped