-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added resources and changed a parameter or two. (#111)
* Add MariaDB RDS engine type. Change RDS dbports to be tokens, this allows us to set them via parameters. * Performing updates to local generator branch. Updating monitoring and game stacks. * Added elasticache. Added SubnetNetworkAclAssociation for EC2. Changed Beanstalk environment to take an `Option[ResourceRef[`AWS::ElasticBeanstalk::ConfigurationTemplate`]]` for its comfiguration template parameter. * Added new resources to README.md * Added AWS::ECR::Repository to README.md * Added unit tests to improve coverage.
- Loading branch information
Showing
9 changed files
with
297 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/scala/com/monsanto/arch/cloudformation/model/resource/ECR.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.monsanto.arch.cloudformation.model.resource | ||
|
||
import com.monsanto.arch.cloudformation.model.{ConditionRef, Token} | ||
import spray.json.{DefaultJsonProtocol, JsonFormat} | ||
|
||
/** | ||
* Created by Berthold Alheit on 13/09/16. | ||
*/ | ||
case class `AWS::ECR::Repository`( | ||
name: String, | ||
RepositoryName: Option[Token[String]], | ||
RepositoryPolicyText: Option[Token[PolicyDocument]] = None, | ||
override val Condition: Option[ConditionRef] = None) | ||
extends Resource[`AWS::ECR::Repository`] { | ||
def when(newCondition: Option[ConditionRef] = Condition) = | ||
new `AWS::ECR::Repository`(name, RepositoryName, RepositoryPolicyText, newCondition) | ||
} | ||
object `AWS::ECR::Repository` extends DefaultJsonProtocol { | ||
implicit val format: JsonFormat[`AWS::ECR::Repository`] = jsonFormat4(`AWS::ECR::Repository`.apply) | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/scala/com/monsanto/arch/cloudformation/model/resource/ElastiCache.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.monsanto.arch.cloudformation.model.resource | ||
|
||
import com.monsanto.arch.cloudformation.model.{ConditionRef, ResourceRef, Token} | ||
import spray.json.{DefaultJsonProtocol, JsonFormat} | ||
|
||
/** | ||
* Cache security group. | ||
* | ||
* @param name | ||
* @param Description | ||
* @param SubnetIds | ||
* @param Condition | ||
*/ | ||
case class `AWS::ElastiCache::SubnetGroup`( | ||
name: String, | ||
Description: String, | ||
SubnetIds: Token[Seq[ResourceRef[`AWS::EC2::Subnet`]]], | ||
override val Condition: Option[ConditionRef] = None | ||
) extends Resource[`AWS::ElastiCache::SubnetGroup`]{ | ||
|
||
def when(newCondition: Option[ConditionRef] = Condition) = copy(Condition = newCondition) | ||
} | ||
|
||
/** | ||
* Json format definition for subnet group. | ||
*/ | ||
object `AWS::ElastiCache::SubnetGroup` extends DefaultJsonProtocol { | ||
implicit val format: JsonFormat[`AWS::ElastiCache::SubnetGroup`] = jsonFormat4(`AWS::ElastiCache::SubnetGroup`.apply) | ||
} | ||
|
||
/** | ||
* Cache cluster definition. | ||
* | ||
* @param name | ||
* @param ClusterName | ||
* @param CacheNodeType | ||
* @param CacheSubnetGroupName | ||
* @param VpcSecurityGroupIds | ||
* @param Engine | ||
* @param NumCacheNodes | ||
* @param Tags | ||
* @param Condition | ||
*/ | ||
case class `AWS::ElastiCache::CacheCluster`( | ||
name: String, | ||
ClusterName: String, | ||
CacheNodeType: String, | ||
CacheSubnetGroupName: Token[ResourceRef[`AWS::ElastiCache::SubnetGroup`]], | ||
VpcSecurityGroupIds: Option[Seq[Token[String]]], | ||
Engine: String, | ||
NumCacheNodes: Token[String], | ||
Tags: Option[Seq[AmazonTag]] = None, | ||
override val Condition: Option[ConditionRef] = None | ||
) extends Resource[`AWS::ElastiCache::CacheCluster`]{ | ||
|
||
def when(newCondition: Option[ConditionRef] = Condition) = copy(Condition = newCondition) | ||
} | ||
|
||
/** | ||
* Json format definition for cache cluster | ||
*/ | ||
object `AWS::ElastiCache::CacheCluster` extends DefaultJsonProtocol { | ||
implicit val format: JsonFormat[`AWS::ElastiCache::CacheCluster`] = jsonFormat9(`AWS::ElastiCache::CacheCluster`.apply) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/test/scala/com/monsanto/arch/cloudformation/model/resource/ECR_UT.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.monsanto.arch.cloudformation.model.resource | ||
|
||
import com.monsanto.arch.cloudformation.model._ | ||
import org.scalatest.{FunSpec, Matchers} | ||
import spray.json._ | ||
|
||
class ECR_UT extends FunSpec with Matchers { | ||
describe("AWS::ECR::Repository") { | ||
|
||
val fakePolicyDoc = PolicyDocument(Seq( | ||
PolicyStatement( | ||
"Allow", | ||
Some(DefinedPrincipal(Map("Service" -> Seq("fakePrincipal")))), | ||
Seq("fakeAction") | ||
) | ||
)) | ||
|
||
val repositoryName = "repository" | ||
val repository = `AWS::ECR::Repository`( | ||
repositoryName, | ||
Some("myFakeDockerRepository"), | ||
Some(fakePolicyDoc) | ||
) | ||
|
||
it("should create a valid new ECR repository") { | ||
val expected = JsObject( | ||
repositoryName -> JsObject( | ||
"Type" -> JsString("AWS::ECR::Repository"), | ||
"Properties" -> JsObject( | ||
"RepositoryName" -> JsString("myFakeDockerRepository"), | ||
"RepositoryPolicyText" -> fakePolicyDoc.toJson | ||
))) | ||
Seq[Resource[_]](repository).toJson should be(expected) | ||
} | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
src/test/scala/com/monsanto/arch/cloudformation/model/resource/ElastiCache_UT.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package com.monsanto.arch.cloudformation.model.resource | ||
|
||
import com.monsanto.arch.cloudformation.model._ | ||
import org.scalatest.{FunSpec, Matchers} | ||
import spray.json._ | ||
|
||
class ElastiCache_UT extends FunSpec with Matchers { | ||
describe("AWS::ElastiCache::SubnetGroup") { | ||
val vpc = `AWS::EC2::VPC`( | ||
name = "VPC", | ||
CidrBlock = CidrBlock(10, 10, 10, 10, 16), | ||
Tags = Seq() | ||
) | ||
val subnetName = "subnet" | ||
val subnet = `AWS::EC2::Subnet`( | ||
name = subnetName, | ||
VpcId = ResourceRef(vpc), | ||
AvailabilityZone = Some("us-east-1a"), | ||
CidrBlock = CidrBlock(10, 10, 10, 10, 24), | ||
Tags = Seq() | ||
) | ||
val cacheSubnetGroupName = "cacheSubnetGroup" | ||
val cacheSubnetGroup = `AWS::ElastiCache::SubnetGroup`( | ||
name = cacheSubnetGroupName, | ||
Description = "Not a real group", | ||
SubnetIds = Seq(ResourceRef(subnet)) | ||
) | ||
|
||
it("should create a valid new ElastiCache subnet group") { | ||
val expected = JsObject( | ||
cacheSubnetGroupName -> JsObject( | ||
"Type" -> JsString("AWS::ElastiCache::SubnetGroup"), | ||
"Properties" -> JsObject( | ||
"Description" -> JsString("Not a real group"), | ||
"SubnetIds" -> JsArray(JsObject("Ref" -> JsString(subnetName))) | ||
))) | ||
Seq[Resource[_]](cacheSubnetGroup).toJson should be(expected) | ||
} | ||
} | ||
|
||
describe("AWS::ElastiCache::CacheCluster") { | ||
val vpc = `AWS::EC2::VPC`( | ||
name = "VPC", | ||
CidrBlock = CidrBlock(10, 10, 10, 10, 16), | ||
Tags = Seq() | ||
) | ||
val subnetName = "subnet" | ||
val subnet = `AWS::EC2::Subnet`( | ||
name = subnetName, | ||
VpcId = ResourceRef(vpc), | ||
AvailabilityZone = Some("us-east-1a"), | ||
CidrBlock = CidrBlock(10, 10, 10, 10, 24), | ||
Tags = Seq() | ||
) | ||
val cacheSubnetGroupName = "cacheSubnetGroup" | ||
val cacheSubnetGroup = `AWS::ElastiCache::SubnetGroup`( | ||
name = cacheSubnetGroupName, | ||
Description = "Not a real group", | ||
SubnetIds = Seq(ResourceRef(subnet)) | ||
) | ||
|
||
val cacheSgName = "cacheSecurityGroup" | ||
val cacheSg = `AWS::EC2::SecurityGroup`( | ||
name = cacheSgName, | ||
VpcId = vpc, | ||
GroupDescription = s"Not a real security group", | ||
SecurityGroupIngress = None, | ||
Tags = Seq() | ||
) | ||
|
||
val cacheName = "cache" | ||
val cache = `AWS::ElastiCache::CacheCluster`( | ||
name = cacheName, | ||
ClusterName = "fakeCluster", | ||
CacheNodeType = "cache.t1.micro", | ||
CacheSubnetGroupName = cacheSubnetGroup, | ||
VpcSecurityGroupIds = Some( | ||
Seq(`Fn::Join`("", Seq(`Fn::GetAtt`(Seq(cacheSg.name, "GroupId"))))) | ||
), | ||
Engine = "redis", | ||
NumCacheNodes = "1" | ||
) | ||
|
||
it("should create a valid new ElastiCache instance") { | ||
val expected = JsObject( | ||
cacheName -> JsObject( | ||
"Type" -> JsString("AWS::ElastiCache::CacheCluster"), | ||
"Properties" -> JsObject( | ||
"ClusterName" -> JsString("fakeCluster"), | ||
"CacheNodeType" -> JsString("cache.t1.micro"), | ||
"CacheSubnetGroupName" -> JsObject("Ref" -> JsString(cacheSubnetGroupName)), | ||
"VpcSecurityGroupIds" -> JsArray( | ||
JsObject("Fn::Join" -> | ||
JsArray( | ||
JsString(""), | ||
JsArray( | ||
JsObject("Fn::GetAtt" -> | ||
JsArray( | ||
JsString("cacheSecurityGroup"), | ||
JsString("GroupId")) | ||
))))), | ||
"Engine" -> JsString("redis"), | ||
"NumCacheNodes" -> JsString("1") | ||
) | ||
) | ||
) | ||
Seq[Resource[_]](cache).toJson should be(expected) | ||
} | ||
} | ||
} |