Skip to content

Commit

Permalink
Add support for EC2::NatGateway (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
keerts authored and brabster committed Dec 9, 2017
1 parent b13127d commit 167c4ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/crucible/aws/ec2.clj
Expand Up @@ -33,7 +33,8 @@

(defresource eip (ec2 "EIP") ::eip)

(s/def ::allocation-id string?)
(s/def ::allocation-id (spec-or-ref string?))
(s/def ::subnet-id (spec-or-ref string?))
(s/def ::eip string?)
(s/def ::private-ip-address string?)

Expand All @@ -47,6 +48,9 @@

(defresource internet-gateway (ec2 "InternetGateway") (s/? (s/keys :opt [::tags])))

(defresource nat-gateway (ec2 "NatGateway") (s/keys :req [::allocation-id ::subnet-id]
:opt [::tags]))

(s/def ::vpc-gateway-attachment (s/keys :req [::vpc-id]
:opt [::internet-gateway-id
::vpn-gateway-id]))
Expand Down
20 changes: 20 additions & 0 deletions test/crucible/aws/ec2_test.clj
Expand Up @@ -14,6 +14,26 @@
(testing "minimal spec"
(is (s/valid? ::res/resource (second (ec2/internet-gateway {}))))))

(deftest nat-gateway-test
(testing "minimal spec"
(is (s/valid? ::res/resource (second (ec2/nat-gateway {::ec2/allocation-id "id"
::ec2/subnet-id "id"})))))
(testing "full spec"
(is (s/valid? ::res/resource (second (ec2/nat-gateway {::ec2/allocation-id "id"
::ec2/subnet-id "id"
::ec2/tags [{::res/key "key" ::res/value "value"}]})))))
(testing "template with multiple conditions"
(is (= {"AWSTemplateFormatVersion" "2010-09-09"
"Description" "t"
"Resources" {"NatGateway" {"Type" "AWS::EC2::NatGateway"
"Properties" {"AllocationId" "id"
"SubnetId" "id"}}}}
(cheshire.core/decode
(encode
(template "t"
:nat-gateway (ec2/nat-gateway {::ec2/allocation-id "id"
::ec2/subnet-id "id"}))))))))

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

0 comments on commit 167c4ab

Please sign in to comment.