Skip to content

Commit

Permalink
Add support for EC2::Route and EC2::RouteTable (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
keerts authored and brabster committed Dec 10, 2017
1 parent 13aadf1 commit 6e7a2de
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/crucible/aws/ec2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@
(s/def ::subnet-id (spec-or-ref string?))
(s/def ::private-ip-address string?)

(s/def ::route-table (s/keys :req [::vpc-id]
:opt [::res/tags]))

(defresource route-table (ec2 "RouteTable") ::route-table)

(s/def ::destination-cidr-block (spec-or-ref string?))
(s/def ::destination-ipv6-cidr-block (spec-or-ref string?))
(s/def ::egress-only-internet-gateway-id (spec-or-ref string?))
(s/def ::gateway-id (spec-or-ref string?))
(s/def ::instance-id (spec-or-ref string?))
(s/def ::nat-gateway-id (spec-or-ref string?))
(s/def ::network-interface-id (spec-or-ref string?))
(s/def ::vpc-peering-connection-id (spec-or-ref string?))

(s/def ::route (s/keys :req [::route-table-id]
:opt [::destination-cidr-block
::destination-ipv6-cidr-block
::egress-only-internet-gateway-id
::gateway-id
::instance-id
::nat-gateway-id
::network-interface-id
::vpc-peering-connection-id]))

(defresource route (ec2 "Route") ::route)

(s/def ::eip-association (s/keys :opt [::allocation-id
::eip
::instance-id
Expand Down
16 changes: 16 additions & 0 deletions test/crucible/aws/ec2_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@
:nat-gateway (ec2/nat-gateway {::ec2/allocation-id "id"
::ec2/subnet-id "id"}))))))))

(deftest route-table-test
(testing "minimal spec"
(is (s/valid? ::res/resource (second (ec2/route-table {::ec2/vpc-id "id"})))))
(testing "full spec"
(is (s/valid? ::res/resource (second (ec2/route-table {::ec2/vpc-id "id"
::ec2/tags [{::res/key "key" ::res/value "value"}]})))))
(testing "template with route table"
(is (= {"AWSTemplateFormatVersion" "2010-09-09"
"Description" "t"
"Resources" {"RouteTable" {"Type" "AWS::EC2::RouteTable"
"Properties" {"VpcId" "id"}}}}
(cheshire.core/decode
(encode
(template "t"
:route-table (ec2/route-table {::ec2/vpc-id "id"}))))))))

(deftest sg-test
(testing "encode"
(is (= {"AWSTemplateFormatVersion" "2010-09-09"
Expand Down

0 comments on commit 6e7a2de

Please sign in to comment.