Beispiel #1
0
 def test_stack(self):
     stack = Stack(
         "mystack",
         VpcId="myvpcid",
         DefaultSubnetId="subnetid",
     )
     self.assertTrue(stack.validate())
Beispiel #2
0
 def test_nosubnet(self):
     stack = Stack(
         "mystack",
         VpcId="myvpcid",
     )
     with self.assertRaises(ValueError):
         stack.validate()
Beispiel #3
0
 def test_nosubnet(self):
     stack = Stack(
         "mystack",
         VpcId="myvpcid",
     )
     with self.assertRaises(ValueError):
         stack.validate()
Beispiel #4
0
 def test_stack(self):
     stack = Stack(
         "mystack",
         VpcId="myvpcid",
         DefaultSubnetId="subnetid",
     )
     self.assertTrue(stack.validate())
Beispiel #5
0
 def test_required(self):
     stack = Stack(
         "mystack",
         DefaultInstanceProfileArn="instancearn",
         Name="myopsworksname",
         ServiceRoleArn="arn",
     )
     t = Template()
     t.add_resource(stack)
     t.to_json()
    def test_custom_json(self):
        stack = Stack(
            "mystack",
            DefaultInstanceProfileArn="instancearn",
            Name="myopsworksname",
            ServiceRoleArn="arn",
        )

        # Test dict works
        t = Template()
        stack.CustomJson = {"foo": "bar"}
        t.add_resource(stack)
        t.to_json()

        # Test json string works
        t = Template()
        stack.CustomJson = '{"foo": "bar"}'
        t.add_resource(stack)
        t.to_json()

        # Test boolean fails
        with self.assertRaises(TypeError):
            stack.CustomJson = True
Beispiel #7
0
    def test_custom_json(self):
        stack = Stack(
            "mystack",
            DefaultInstanceProfileArn="instancearn",
            Name="myopsworksname",
            ServiceRoleArn="arn",
        )

        # Test dict works
        t = Template()
        stack.CustomJson = {"foo": "bar"}
        t.add_resource(stack)
        t.to_json()

        # Test json string works
        t = Template()
        stack.CustomJson = '{"foo": "bar"}'
        t.add_resource(stack)
        t.to_json()

        # Test boolean fails
        with self.assertRaises(TypeError):
            stack.CustomJson = True
Beispiel #8
0
 def test_no_required(self):
     stack = Stack("mystack", )
     t = Template()
     t.add_resource(stack)
     with self.assertRaises(ValueError):
         t.to_json()
Beispiel #9
0
        Type="String",
    )
)

myStack = template.add_resource(
    Stack(
        "myStack",
        Name=Ref("AWS::StackName"),
        ServiceRoleArn=Join(
            "", ["arn:aws:iam::", Ref("AWS::AccountId"), ":role/", Ref(ServiceRole)]
        ),
        DefaultInstanceProfileArn=Join(
            "",
            [
                "arn:aws:iam::",
                Ref("AWS::AccountId"),
                ":instance-profile/",
                Ref(InstanceRole),
            ],
        ),
        UseCustomCookbooks=True,
        CustomCookbooksSource=Source(
            Type="git",
            Url="git://github.com/amazonwebservices/"
            + "opsworks-example-cookbooks.git",
        ),
    )
)

myLayer = template.add_resource(
    Layer(
        "myLayer",