Skip to content

Commit

Permalink
Merge 8a8cb3c into aa4845f
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfokken committed Jan 19, 2016
2 parents aa4845f + 8a8cb3c commit ff7ead3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe("Template Lookup") {
- AWS::AutoScaling::ScalingPolicy
- AWS::CloudWatch::Alarm
- AWS::DynamoDB::Table
- AWS::EC2::CustomerGateway
- AWS::EC2::EIP
- AWS::EC2::Instance
- AWS::EC2::InternetGateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ object `AWS::EC2::KeyPair::KeyName` extends DefaultJsonProtocol {
implicit val format: JsonFormat[`AWS::EC2::KeyPair::KeyName`] = jsonFormat2(`AWS::EC2::KeyPair::KeyName`.apply)
}

case class `AWS::EC2::CustomerGateway`(
name: String,
BgpAsn: Int,
IpAddress: String,
Tags: Seq[AmazonTag],
Type: String,
override val Condition: Option[ConditionRef] = None) extends Resource[`AWS::EC2::CustomerGateway`]{

def when(newCondition: Option[ConditionRef] = Condition) = copy(Condition = newCondition)
}
object `AWS::EC2::CustomerGateway` extends DefaultJsonProtocol {
implicit val format: JsonFormat[`AWS::EC2::CustomerGateway`] = jsonFormat6(`AWS::EC2::CustomerGateway`.apply)
}

@implicitNotFound("A Route can only have exactly ONE of GatewayId, InstanceId, NetworkInterfaceId or VpcPeeringConnectionId set")
class ValidRouteCombo[G, I] private ()
object ValidRouteCombo{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.reflect.NameTransformer

// serializes to Type and Properties
abstract class Resource[R <: Resource[R] : ClassTag : JsonFormat]{ self: Resource[R] =>
val Type = NameTransformer.decode(implicitly[ClassTag[R]].runtimeClass.getSimpleName)
val ResourceType = NameTransformer.decode(implicitly[ClassTag[R]].runtimeClass.getSimpleName)
val name: String

val Condition: Option[ConditionRef] = None
Expand All @@ -35,7 +35,7 @@ object Resource extends DefaultJsonProtocol {
val raw = bar._format.asInstanceOf[JsonFormat[obj.RR]].write(bar).asJsObject

val outputFields = Map(
"Type" -> JsString(obj.Type),
"Type" -> JsString(obj.ResourceType),
"Metadata" -> raw.fields.getOrElse("Metadata", JsNull),
"Properties" -> JsObject(raw.fields - "name" - "Metadata" - "UpdatePolicy" - "Condition" - "DependsOn" - "DeletionPolicy"),
"UpdatePolicy" -> raw.fields.getOrElse("UpdatePolicy", JsNull),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.monsanto.arch.cloudformation.model.resource

import com.monsanto.arch.cloudformation.model._
import org.scalatest.{FunSpec, Matchers}
import spray.json._

class CGW_UT extends FunSpec with Matchers {
describe("AWS::EC2::CustomerGateway") {
val bpgAsn = 1234
val ipAddr = "8.8.8.8"
val cgwType = "ipsec.1"
val cgw = `AWS::EC2::CustomerGateway`(
name = "cgw",
BgpAsn = 1234,
IpAddress = "8.8.8.8",
Tags = Seq(),
Type = "ipsec.1"
)
it("should create a valid new Customer Gateway") {
val expected = JsObject(
"cgw" -> JsObject(
"Type" -> JsString("AWS::EC2::CustomerGateway"),
"Properties" -> JsObject(
"BgpAsn" -> JsNumber(bpgAsn),
"IpAddress" -> JsString(ipAddr),
"Tags" -> JsArray(),
"Type" -> JsString(cgwType)
)
)
)
Seq[Resource[_]](cgw).toJson should be(expected)
}
}
}

0 comments on commit ff7ead3

Please sign in to comment.