def test_stack(self): stack = Stack( "mystack", VpcId="myvpcid", DefaultSubnetId="subnetid", ) self.assertTrue(stack.validate())
def test_nosubnet(self): stack = Stack( "mystack", VpcId="myvpcid", ) with self.assertRaises(ValueError): stack.validate()
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
def test_no_required(self): stack = Stack("mystack", ) t = Template() t.add_resource(stack) with self.assertRaises(ValueError): t.to_json()
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",