immutable infrastructure deployment€¦ · immutable infrastructure deployment nick hibberd. data...
TRANSCRIPT
![Page 1: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/1.jpg)
Immutable Infrastructure Deployment
Nick Hibberd
![Page 2: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/2.jpg)
data lake
![Page 3: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/3.jpg)
![Page 4: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/4.jpg)
Accidental chaos monkeys
![Page 5: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/5.jpg)
![Page 6: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/6.jpg)
![Page 7: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/7.jpg)
![Page 8: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/8.jpg)
![Page 9: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/9.jpg)
Solutions
![Page 10: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/10.jpg)
![Page 11: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/11.jpg)
fib = 0 : scanl (+) 1 fib
![Page 12: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/12.jpg)
1 import Control.Monad.State 2 fib n = flip evalState (0,1) $ do 3 forM [0..(n-1)] $ \_ -> do 4 (a,b) <- get 5 put (b,a+b) 6 (a,b) <- get 7 return a
![Page 13: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/13.jpg)
0, 1, 1, 2, 3, 5, 8, …
![Page 14: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/14.jpg)
![Page 15: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/15.jpg)
1 commission image itype role tags userData subnet name azs sg = 2 resp <- send $ runInstances image 1 1 3 & rInstanceType .~ Just itype 4 & rBlockDeviceMappings .~ instanceDeviceMappings it 5 & rIAMInstanceProfile .~ 6 fmap (\r -> iamInstanceProfileSpecification & iapsName .~ Just r)) role 7 & rUserData .~ Just (userDataBase64 userData) 8 & rSubnetId .~ fmap subnetId subnet 9 & rPlacement .~ 10 ((\az -> placement 11 & pAvailabilityZone .~ Just (availabilityZone az)) <$> azs) 12 & rSecurityGroupIds .~ [securityGroupIdText sg] 13 i <- maybe liftInvariant (pure . InstanceId) . listToMaybe . 14 fmap (view insInstanceId) . view rInstances $ resp 15 16 send $ createTags 17 & cTags .~ (fmap ec2Tag $ nameTag name : filterReservedTags tags) 18 & cResources .~ [instanceId i] 19 20 pure i
![Page 16: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/16.jpg)
Solving complex problems
with simple patterns
![Page 17: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/17.jpg)
Concepts
![Page 18: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/18.jpg)
![Page 19: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/19.jpg)
![Page 20: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/20.jpg)
![Page 21: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/21.jpg)
![Page 22: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/22.jpg)
![Page 23: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/23.jpg)
![Page 24: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/24.jpg)
v1
![Page 25: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/25.jpg)
![Page 26: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/26.jpg)
![Page 27: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/27.jpg)
v1 v2
?
![Page 28: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/28.jpg)
A
v1 v2
A
![Page 29: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/29.jpg)
v1 v2
A A A
![Page 30: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/30.jpg)
v1 v2
A A A
![Page 31: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/31.jpg)
v1 v2
A A A
![Page 32: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/32.jpg)
v1 v2
A A
![Page 33: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/33.jpg)
v2
![Page 34: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/34.jpg)
![Page 35: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/35.jpg)
1 commission image itype role tags userData subnet name azs sg = 2 resp <- send $ runInstances image 1 1 3 & rInstanceType .~ Just itype 4 & rBlockDeviceMappings .~ instanceDeviceMappings it 5 & rIAMInstanceProfile .~ 6 fmap (\r -> iamInstanceProfileSpecification & iapsName .~ Just r)) role 7 & rUserData .~ Just (userDataBase64 userData) 8 & rSubnetId .~ fmap subnetId subnet 9 & rPlacement .~ 10 ((\az -> placement 11 & pAvailabilityZone .~ Just (availabilityZone az)) <$> azs) 12 & rSecurityGroupIds .~ [securityGroupIdText sg] 13 i <- maybe liftInvariant (pure . InstanceId) . listToMaybe . 14 fmap (view insInstanceId) . view rInstances $ resp 15 16 send $ createTags 17 & cTags .~ (fmap ec2Tag $ nameTag name : filterReservedTags tags) 18 & cResources .~ [instanceId i] 19 20 pure i
![Page 36: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/36.jpg)
data Configuration = Configuration { capacity :: DesiredInstances , availabilityZones :: NonEmpty AvailabilityZone , instanceType :: InstanceType , market :: Market , security :: [SecurityGroup] , iam :: IamRole , software :: [Software] , users :: [Users] , flavour :: Flavour , elb :: [LoadBalancer] , context :: Context , service :: ServiceName } deriving (Eq, Show)
![Page 37: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/37.jpg)
data Configuration = Configuration { capacity :: DesiredInstances , availabilityZones :: NonEmpty AvailabilityZone , instanceType :: InstanceType , market :: Market , security :: [SecurityGroup] , iam :: IamRole , software :: [Software] , users :: [Users] , flavour :: Flavour , elb :: [LoadBalancer] , context :: Context , service :: ServiceName } deriving (Eq, Show)
![Page 38: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/38.jpg)
data Configuration = Configuration { capacity :: DesiredInstances , availabilityZones :: NonEmpty AvailabilityZone , instanceType :: InstanceType , market :: Market , security :: [SecurityGroup] , iam :: IamRole , software :: [Software] , users :: [Users] , flavour :: Flavour , elb :: [LoadBalancer] , context :: Context , service :: ServiceName } deriving (Eq, Show)
![Page 39: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/39.jpg)
data Configuration = Configuration { capacity :: DesiredInstances , availabilityZones :: NonEmpty AvailabilityZone , instanceType :: InstanceType , market :: Market , security :: [SecurityGroup] , iam :: IamRole , software :: [Software] , users :: [Users] , flavour :: Flavour , elb :: [LoadBalancer] , context :: Context , service :: ServiceName } deriving (Eq, Show)
![Page 40: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/40.jpg)
data Configuration = Configuration { capacity :: DesiredInstances , availabilityZones :: NonEmpty AvailabilityZone , instanceType :: InstanceType , market :: Market , security :: [SecurityGroup] , iam :: IamRole , software :: [Software] , users :: [Users] , flavour :: Flavour , elb :: [LoadBalancer] , context :: Context , service :: ServiceName } deriving (Eq, Show)
![Page 41: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/41.jpg)
![Page 42: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/42.jpg)
data Group = Group { groupName :: GroupName , groupConfiguration :: ConfigurationName , groupCreationTime :: UTCTime , groupCapacity :: DesiredInstances , groupAvailabilityZones :: NonEmpty AvailabilityZone , groupInstances :: [InstanceId] , groupInstanceHealth :: [InstanceHealth] , groupService :: ServiceName , groupLifeCycle :: LifeCycle , groupEnvironment :: Environment , groupELB :: [LoadBalancer] } deriving (Eq, Show)
![Page 43: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/43.jpg)
data Group = Group { groupName :: GroupName , groupConfiguration :: ConfigurationName , groupCreationTime :: UTCTime , groupCapacity :: DesiredInstances , groupAvailabilityZones :: NonEmpty AvailabilityZone , groupInstances :: [InstanceId] , groupInstanceHealth :: [InstanceHealth] , groupService :: ServiceName , groupLifeCycle :: LifeCycle , groupEnvironment :: Environment , groupELB :: [LoadBalancer] } deriving (Eq, Show)
![Page 44: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/44.jpg)
data Group = Group { groupName :: GroupName , groupConfiguration :: ConfigurationName , groupCreationTime :: UTCTime , groupCapacity :: DesiredInstances , groupAvailabilityZones :: NonEmpty AvailabilityZone , groupInstances :: [InstanceId] , groupInstanceHealth :: [InstanceHealth] , groupService :: ServiceName , groupLifeCycle :: LifeCycle , groupEnvironment :: Environment , groupELB :: [LoadBalancer] } deriving (Eq, Show)
![Page 45: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/45.jpg)
data Group = Group { groupName :: GroupName , groupConfiguration :: ConfigurationName , groupCreationTime :: UTCTime , groupCapacity :: DesiredInstances , groupAvailabilityZones :: NonEmpty AvailabilityZone , groupInstances :: [InstanceId] , groupInstanceHealth :: [InstanceHealth] , groupService :: ServiceName , groupLifeCycle :: LifeCycle , groupEnvironment :: Environment , groupELB :: [LoadBalancer] } deriving (Eq, Show)
![Page 46: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/46.jpg)
data Group = Group { groupName :: GroupName , groupConfiguration :: ConfigurationName , groupCreationTime :: UTCTime , groupCapacity :: DesiredInstances , groupAvailabilityZones :: NonEmpty AvailabilityZone , groupInstances :: [InstanceId] , groupInstanceHealth :: [InstanceHealth] , groupService :: ServiceName , groupLifeCycle :: LifeCycle , groupEnvironment :: Environment , groupELB :: [LoadBalancer] } deriving (Eq, Show)
![Page 47: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/47.jpg)
Deployment as a function
![Page 48: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/48.jpg)
Configuration -> [Group] -> ?
![Page 49: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/49.jpg)
1 commission image itype role tags userData subnet name azs sg = 2 resp <- send $ runInstances image 1 1 3 & rInstanceType .~ Just itype 4 & rBlockDeviceMappings .~ instanceDeviceMappings it 5 & rIAMInstanceProfile .~ 6 fmap (\r -> iamInstanceProfileSpecification & iapsName .~ Just r)) role 7 & rUserData .~ Just (userDataBase64 userData) 8 & rSubnetId .~ fmap subnetId subnet 9 & rPlacement .~ 10 ((\az -> placement 11 & pAvailabilityZone .~ Just (availabilityZone az)) <$> azs) 12 & rSecurityGroupIds .~ [securityGroupIdText sg] 13 i <- maybe liftInvariant (pure . InstanceId) . listToMaybe . 14 fmap (view insInstanceId) . view rInstances $ resp 15 16 send $ createTags 17 & cTags .~ (fmap ec2Tag $ nameTag name : filterReservedTags tags) 18 & cResources .~ [instanceId i] 19 20 pure i
![Page 50: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/50.jpg)
Configuration -> [Group] -> Goal
![Page 51: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/51.jpg)
data Goal = CreateGroup Configuration | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 52: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/52.jpg)
data Goal = CreateGroup Configuration | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 53: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/53.jpg)
Deployment tool
AA A
![Page 54: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/54.jpg)
A
AA A A A A A A
service x
A
Deployment tool
A
![Page 55: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/55.jpg)
A
service x
A
Deployment tool
A
AA A A A A A A
A A A A A A A
![Page 56: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/56.jpg)
AAdd 7
AA A A A A A A
A A
![Page 57: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/57.jpg)
A
A A A A A A A
A A A A A A A
A A A A A A A
AA A
![Page 58: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/58.jpg)
A
AA A A A A A A
A ASet total to 14
![Page 59: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/59.jpg)
AA A A A A A A
AA A
A A A A A A A
![Page 60: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/60.jpg)
Idempotent actions
data Goal = CreateGroup Configuration | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 61: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/61.jpg)
data Goal = CreateGroup Configuration | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 62: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/62.jpg)
![Page 63: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/63.jpg)
data Goal = CreateGroup Configuration | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 64: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/64.jpg)
data Goal = CreateGroup Resolved | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 65: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/65.jpg)
data Goal = CreateGroup Resolved | SetCapacity GroupName DesiredInstances | SetLifeCycle GroupName Resolved LifeCycle | NotYetHealthy GroupName [InstanceHealth] | DoNothing
![Page 66: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/66.jpg)
Rules
![Page 67: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/67.jpg)
data Result a = TerminateFailure Error | TerminateSuccess Goal | Continue a
![Page 68: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/68.jpg)
data Result a = TerminateFailure Error | TerminateSuccess Goal | Continue a
![Page 69: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/69.jpg)
data Result a = TerminateFailure Error | TerminateSuccess Goal | Continue a
![Page 70: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/70.jpg)
data Result a = TerminateFailure Error | TerminateSuccess Goal | Continue a
![Page 71: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/71.jpg)
data Result a = TerminateFailure Error | TerminateSuccess Goal | Continue a
![Page 72: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/72.jpg)
1 instance Monad Result where 2 (>>=) ma f = 3 case ma of 4 TerminateSuccess p -> 5 TerminateSuccess p 6 TerminateFailure be -> 7 TerminateFailure be 8 Continue a -> 9 f a 10 11 return = 12 Continue
![Page 73: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/73.jpg)
1 instance Monad Result where 2 (>>=) ma f = 3 case ma of 4 TerminateSuccess p -> 5 TerminateSuccess p 6 TerminateFailure be -> 7 TerminateFailure be 8 Continue a -> 9 f a 10 11 return = 12 Continue
![Page 74: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/74.jpg)
1 instance Monad Result where 2 (>>=) ma f = 3 case ma of 4 TerminateSuccess p -> 5 TerminateSuccess p 6 TerminateFailure be -> 7 TerminateFailure be 8 Continue a -> 9 f a 10 11 return = 12 Continue
![Page 75: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/75.jpg)
1 instance Monad Result where 2 (>>=) ma f = 3 case ma of 4 TerminateSuccess p -> 5 TerminateSuccess p 6 TerminateFailure be -> 7 TerminateFailure be 8 Continue a -> 9 f a 10 11 return = 12 Continue
![Page 76: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/76.jpg)
1 success :: Goal -> Result () 2 success p = 3 TerminateSuccess p
![Page 77: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/77.jpg)
1 with :: Maybe a -> (a -> Result ()) -> Result () 2 with m f = 3 case m of 4 Just v -> 5 f v 6 Nothing -> 7 pure ()
![Page 78: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/78.jpg)
Create a server
![Page 79: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/79.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 4 when (noMatchingVersions conf cs) . 5 success $ CreateGroup conf 6 7 ...
![Page 80: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/80.jpg)
Aside
![Page 81: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/81.jpg)
if software /= software' then if users /= users' then if permissions /= permissions' then if metadata /= metadata' then if location /= location' then if market /= market' then DONT DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY
![Page 82: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/82.jpg)
if software /= software' then if users /= users' then if permissions /= permissions' then if metadata /= metadata' then if location /= location' then if market /= market' then DONT DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY
if users /= users' then if permissions /= permissions' then if metadata /= metadata' then if location /= location' then if market /= market' then DONT DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY else DEPLOY
![Page 83: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/83.jpg)
Hash
#
![Page 84: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/84.jpg)
data HashPayload = HashPayload { hashSoftware :: [Software] , hashUsers :: [User] , hashSecurityGroups :: [SecurityGroup] , hashIam :: Iam , hashFlavour :: Flavour , hashInstanceType :: InstanceType , hashLoadBalancer :: [LoadBalancer] , hashRollover :: Maybe Rollover , hashMarket :: Market , hashClient :: Client , hashAvailabilityZone :: NonEmpty AvailabilityZone }
![Page 85: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/85.jpg)
HashPayload -> Text
![Page 86: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/86.jpg)
HashPayload -> Text
16848e7…137ec4
HashPayload [] [User "jimbob"] [SecurityGroup "ops"] (Iam "ops") (Flavour "base.image") T2_Nano [] None OnDemand (Client "ylj") (AvailabilityZone "ap-southeast-2c" :| [] )
![Page 87: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/87.jpg)
1 noMatchingVersions :: Configuration -> [Group] -> Bool 2 noMatchingVersions conf groups = 3 null $ filter (\g -> hash conf == groupHash g) groups
![Page 88: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/88.jpg)
Immutable infrastructure
![Page 89: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/89.jpg)
2016-04-29
![Page 90: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/90.jpg)
2016-04-29 -> 38651b2f9b047347a682eab7acc4a0459694fa22
2016-04-30 -> aa07113a5aab33559429223015bb90a33ce654f9
![Page 91: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/91.jpg)
Desired
![Page 92: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/92.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 7 with (underCapacity conf r) $ \i -> 8 success . 9 SetCapacity (groupName r) $ increaseInstances i
v1 v2
![Page 93: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/93.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 7 with (underCapacity conf r) $ \i -> 8 success . 9 SetCapacity (groupName r) $ increaseInstances i
![Page 94: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/94.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 7 with (underCapacity conf r) $ \i -> 8 success . 9 SetCapacity (groupName r) $ increaseInstances i
![Page 95: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/95.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 ... 7 8 with (overCapacity conf r) $ \i -> 9 success . 10 SetCapacity (groupName r) $ decreaseInstances i
![Page 96: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/96.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 ... 7 8 with (overCapacity conf r) $ \i -> 9 success . 10 SetCapacity (groupName r) $ decreaseInstances i
![Page 97: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/97.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 ... 7 8 when (not $ whenHealthy r) . 9 success $ NotYetHealthy (groupName r) (groupInstanceHealth r)
![Page 98: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/98.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (desiredGroup conf cs) $ \r -> do 6 7 with (underCapacity conf r) $ \i -> 8 success . 9 SetCapacity (groupName r) $ increaseInstances i 10 11 with (overCapacity conf r) $ \i -> 12 success . 13 SetCapacity (groupName r) $ decreaseInstances i 14 15 when (not $ whenHealthy r) . 16 success $ NotYetHealthy (groupName r) (groupInstanceHealth r)
![Page 99: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/99.jpg)
![Page 100: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/100.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (leastDesirableGroup conf cs)
v1 v2
![Page 101: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/101.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (leastDesirableGroup conf cs) $ \g -> do 6 7 when (active g) . 8 success . SetLifeCycle (groupResultName g) conf $ Inactive
![Page 102: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/102.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 ... 4 5 with (leastDesirableGroup conf cs) $ \g -> do 6 7 ... 8 9 when (inactive g) . 10 success . SetCapacity (groupResultName g) $ DesiredInstances 0
![Page 103: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/103.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 4 when (noMatchingVersions conf cs) . 5 success $ CreateGroup conf 6 7 with (desiredGroup conf cs) $ \r -> do 8 9 with (underCapacity conf r) $ \i -> 10 success . 11 SetCapacity (groupName r) $ increaseInstances i 12 13 with (leastDesirableGroup conf cs) $ \g -> do 14 15 when (active g) . 16 success . SetLifeCycle (groupResultName g) conf $ Inactive 17 18 when (inactive g) . 19 success . SetCapacity (groupResultName g) $ DesiredInstances 0
![Page 104: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/104.jpg)
Maintenance
![Page 105: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/105.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 4 when (noMatchingVersions conf cs) . 5 success $ CreateGroup conf 6 7 ...
![Page 106: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/106.jpg)
v1 v2
![Page 107: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/107.jpg)
v1 v2
![Page 108: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/108.jpg)
v1 v2 v3
![Page 109: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/109.jpg)
v1 v2 v3
![Page 110: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/110.jpg)
v1 v2 v3 v4
![Page 111: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/111.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 4 when (noMatchingVersions conf cs) . 5 success $ CreateGroup conf 6 7 ...
![Page 112: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/112.jpg)
1 calculate :: Configuration -> [Group] -> Result () 2 calculate conf cs = do 3 4 when (noMatchingVersions conf cs && length cs < 2) . 5 success $ CreateGroup conf 6 7 ...
![Page 113: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/113.jpg)
v1 v2
![Page 114: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/114.jpg)
v1 v2
![Page 115: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/115.jpg)
v1 v2
![Page 116: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/116.jpg)
v1 v2
![Page 117: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/117.jpg)
v1 v2
![Page 118: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/118.jpg)
v2
![Page 119: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/119.jpg)
v2 v4
![Page 120: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/120.jpg)
![Page 121: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/121.jpg)
Loop School
![Page 122: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/122.jpg)
The perfect program with haskell syntax
value <- read
let answer = calculate value
doit answer
![Page 123: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/123.jpg)
The perfect Loop with haskell syntax
forever $ do
value <- read
let answer = calculate value
doit answer
![Page 124: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/124.jpg)
value <- IO
let goals = calculate conf groups
doit goals
![Page 125: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/125.jpg)
confs <- retrieveConfigurations
groups <- retrieveGroups
let goals = calculate conf groups
doit goals
![Page 126: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/126.jpg)
Goal -> IO ()
![Page 127: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/127.jpg)
1 runGoal :: Goal -> IO () 2 runGoal goal = 3 case goal of 4 CreateGroup b -> do 6 createGroup g 7
![Page 128: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/128.jpg)
1 createGroup g = 2 continueIfExists . void . send $ A.createAutoScalingGroup 3 (renderName $ groupName g) 4 0 5 10 6 & A.casgAvailabilityZones .~ 7 Just (availabilityZone <$> groupAvailabilityZones g) 8 & A.casgTags .~ 9 (groupTags g) 10 & A.casgLaunchConfigurationName .~ 11 Just (configurationName $ groupConfName g) 12 & A.casgDesiredCapacity .~ 13 Just (desiredInstances . minimumDesiredInstances $ groupDesiredInstances g) 14 & A.casgLoadBalancerNames .~ 15 (loadBalancer <$> groupELB g)
![Page 129: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/129.jpg)
1 runGoal :: Goal -> IO () 2 runGoal goal = 3 case goal of 4 CreateGroup b -> 5 ... 6 7 SetLifeCycle gn b l -> do 8 setLifeCycle gn l 9 when (l == Inactive) . lift $ 10 detachLoadBalancers gn
![Page 130: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/130.jpg)
1 runGoal :: Goal -> IO () 2 runGoal goal = 3 case goal of 4 ... 5 6 SetCapacity gn di -> do 7 setCapacity gn di
![Page 131: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/131.jpg)
1 runGoal :: Goal -> IO () 2 runGoal goal = 3 case goal of 4 ... 5 6 NotYetHealthy gn hs -> do 7 now <- getCurrentTime 8 case checkHealth now hs of 9 [] -> 10 pure () 11 unhealthy -> 12 interverene gn unhealthy
![Page 132: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/132.jpg)
1 runGoal :: Goal -> IO () 2 runGoal goal = 3 case goal of 4 ... 5 6 DoNothing -> 7 pure ()
![Page 133: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/133.jpg)
1 runGoal :: Goal -> IO () 2 runGoal goal = 3 case goal of 4 CreateGroup b -> do 5 createConfiguration c 6 createGroup g 7 8 SetLifeCycle gn b l -> do 9 setLifeCycle gn l 10 when (l == Inactive) . lift $ 11 detachLoadBalancers gn 12 13 SetCapacity gn di -> do 14 setCapacity gn di 15 16 NotYetHealthy gn hs -> do 17 now <- getCurrentTime 18 case checkHealth now hs of 19 [] -> 20 pure () 21 unhealthy -> 22 interverene gn unhealthy 23 24 DoNothing -> 25 pure ()
![Page 134: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/134.jpg)
1 work :: IO () 2 work = do 3 4 confs <- retrieveConfigurations 5 6 groups <- retrieveGroups 7 8 let goals = calculateAll confs groups 9 10 mapM runGoal goal
![Page 135: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/135.jpg)
1 workForever :: IO () 2 workForever = 3 forever $ work
![Page 136: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/136.jpg)
![Page 137: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/137.jpg)
![Page 138: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/138.jpg)
![Page 139: Immutable Infrastructure Deployment€¦ · Immutable Infrastructure Deployment Nick Hibberd. data lake. Accidental chaos monkeys. Solutions. fib = 0 : scanl (+) 1 fib . 1 import](https://reader036.vdocuments.mx/reader036/viewer/2022070111/605138a7fc9f523ad57acf14/html5/thumbnails/139.jpg)
Immutable Infrastructure Deployment