1 00:00:00,130 --> 00:00:01,100 ‫So now let's talk about 2 00:00:01,100 --> 00:00:03,290 ‫a few advanced concepts for CloudFormation. 3 00:00:03,290 --> 00:00:05,530 ‫We will not do hands-on on them, but some of them 4 00:00:05,530 --> 00:00:06,840 ‫we've already seen and some of them 5 00:00:06,840 --> 00:00:08,290 ‫we'll just see in slides. 6 00:00:08,290 --> 00:00:09,690 ‫So the first one is ChangeSets, 7 00:00:09,690 --> 00:00:10,780 ‫and we've seen that already. 8 00:00:10,780 --> 00:00:12,960 ‫When we update a stack, we need to know in advance 9 00:00:12,960 --> 00:00:15,060 ‫what changes will happen before it happens 10 00:00:15,060 --> 00:00:16,460 ‫for a greater confidence, 11 00:00:16,460 --> 00:00:18,340 ‫and so ChangeSets won't say if the update 12 00:00:18,340 --> 00:00:20,670 ‫is successful or not, as we've seen from before, 13 00:00:20,670 --> 00:00:22,490 ‫but it will tell us what will happen. 14 00:00:22,490 --> 00:00:24,300 ‫So, we have the original stack. 15 00:00:24,300 --> 00:00:26,810 ‫We create a ChangeSet by uploading a new stack, 16 00:00:26,810 --> 00:00:28,980 ‫and this is something we've seen in the hands-on. 17 00:00:28,980 --> 00:00:31,234 ‫Then we can view this ChangeSet and we'll feel happy. 18 00:00:31,234 --> 00:00:34,386 ‫We can optionally change to, change our ChangeSet 19 00:00:34,386 --> 00:00:36,847 ‫by uploading a new stack to modify it, 20 00:00:36,847 --> 00:00:39,800 ‫and once we are happy, we can execute the ChangeSet, 21 00:00:39,800 --> 00:00:40,850 ‫and it will be applied 22 00:00:40,850 --> 00:00:42,820 ‫to the current CloudFormation template. 23 00:00:42,820 --> 00:00:45,020 ‫So this is all the steps we've been already doing 24 00:00:45,020 --> 00:00:48,240 ‫through the hands-on when we updated a CloudFormation stack. 25 00:00:48,240 --> 00:00:51,330 ‫Okay, next is a concept of nested stacks. 26 00:00:51,330 --> 00:00:53,440 ‫So nested stacks are CloudFormation stacks 27 00:00:53,440 --> 00:00:55,380 ‫part of other stacks. 28 00:00:55,380 --> 00:00:59,530 ‫They allow you to update and to isolate repeated patterns, 29 00:00:59,530 --> 00:01:01,190 ‫common components in your separate stack, 30 00:01:01,190 --> 00:01:02,940 ‫and call them from other stacks. 31 00:01:02,940 --> 00:01:04,520 ‫So, I'll give you an example. 32 00:01:04,520 --> 00:01:07,230 ‫A Load Balancer configuration that is re-used, for example, 33 00:01:07,230 --> 00:01:09,740 ‫or a Security Group configuration that is re-used, 34 00:01:09,740 --> 00:01:12,830 ‫and so nested stacks are considered best practices 35 00:01:12,830 --> 00:01:15,500 ‫and to update a nested stack, the first thing to do 36 00:01:15,500 --> 00:01:17,460 ‫is to update the parent. 37 00:01:17,460 --> 00:01:19,420 ‫So, now you may be asking me, 38 00:01:19,420 --> 00:01:20,790 ‫what is the difference between 39 00:01:20,790 --> 00:01:23,660 ‫a cross stack and a nested stack? 40 00:01:23,660 --> 00:01:25,380 ‫So a cross stack is helpful when stacks 41 00:01:25,380 --> 00:01:26,690 ‫have different life cycles. 42 00:01:26,690 --> 00:01:29,820 ‫For example, we want to have a VPC stack and another stack 43 00:01:29,820 --> 00:01:31,500 ‫that references it, and they both have 44 00:01:31,500 --> 00:01:32,690 ‫different life cycles. 45 00:01:32,690 --> 00:01:36,520 ‫So in this case, we use Output Exports and the FnImportValue 46 00:01:36,520 --> 00:01:38,060 ‫for the interesting function, 47 00:01:38,060 --> 00:01:39,330 ‫and then this is when you need 48 00:01:39,330 --> 00:01:41,470 ‫to pass export values to many stacks. 49 00:01:41,470 --> 00:01:44,630 ‫So in this example, the VPC stack is gonna be reused 50 00:01:44,630 --> 00:01:46,960 ‫across many different stacks, and the values needs to be 51 00:01:46,960 --> 00:01:50,090 ‫exported and imported, so that makes a lot of sense. 52 00:01:50,090 --> 00:01:52,490 ‫But nested stack, this is helpful when components 53 00:01:52,490 --> 00:01:54,730 ‫must be reused and recreated. 54 00:01:54,730 --> 00:01:57,190 ‫For example, say we want to properly configure 55 00:01:57,190 --> 00:01:58,630 ‫an Application Load Balancer, 56 00:01:58,630 --> 00:02:01,020 ‫we could isolate it as a nested stack. 57 00:02:01,020 --> 00:02:04,310 ‫And so this is only important when the nested stack 58 00:02:04,310 --> 00:02:08,040 ‫is just mattering for the higher-level stack. 59 00:02:08,040 --> 00:02:09,900 ‫It's not shared across stacks. 60 00:02:09,900 --> 00:02:11,713 ‫So the second example, we have an application stack. 61 00:02:11,713 --> 00:02:15,900 ‫We have an RDS nested stack, an ASG nested stack, 62 00:02:15,900 --> 00:02:18,150 ‫and the ELB nested stack, and we create 63 00:02:18,150 --> 00:02:19,540 ‫a second application stack 64 00:02:19,540 --> 00:02:22,280 ‫again that will have all the other's nested stacks. 65 00:02:22,280 --> 00:02:24,372 ‫So hopefully through these diagrams, it is very clear 66 00:02:24,372 --> 00:02:25,840 ‫what is the difference between 67 00:02:25,840 --> 00:02:28,740 ‫a cross stack and a nested stacks. 68 00:02:28,740 --> 00:02:30,670 ‫This is very hard to say, I'm sorry. 69 00:02:30,670 --> 00:02:33,860 ‫Finally, there is StackSets, which is to create, update, 70 00:02:33,860 --> 00:02:36,880 ‫or delete stack across multiple accounts and regions 71 00:02:36,880 --> 00:02:40,100 ‫with a single operation, so this is gonna apply a stack 72 00:02:40,100 --> 00:02:42,770 ‫all around different accounts and different regions. 73 00:02:42,770 --> 00:02:45,480 ‫Administrator's accounts can create StackSets, 74 00:02:45,480 --> 00:02:48,910 ‫and then the trusted accounts can create, update, 75 00:02:48,910 --> 00:02:51,200 ‫or delete stack instances from the Stacksets. 76 00:02:51,200 --> 00:02:53,530 ‫And so the cool thing about StackSets is that 77 00:02:53,530 --> 00:02:57,290 ‫if you update a StackSet, all the associated stack instances 78 00:02:57,290 --> 00:03:00,200 ‫in all the regions and all the other accounts 79 00:03:00,200 --> 00:03:01,750 ‫will be updated as well. 80 00:03:01,750 --> 00:03:03,930 ‫So the idea is that in the administrator accounts, 81 00:03:03,930 --> 00:03:06,210 ‫you create the StackSets, and it gets applied 82 00:03:06,210 --> 00:03:09,890 ‫to account A, region one, account A, region two, 83 00:03:09,890 --> 00:03:11,730 ‫and account B, region three. 84 00:03:11,730 --> 00:03:13,740 ‫And that's the beautiful thing about Stacksets, 85 00:03:13,740 --> 00:03:15,990 ‫so any time you see in the exam anything about 86 00:03:15,990 --> 00:03:18,380 ‫updating a CloudFormation stack into multiple accounts 87 00:03:18,380 --> 00:03:20,780 ‫and multiple region, think StackSets. 88 00:03:20,780 --> 00:03:23,090 ‫So that's it for this very short theory lecture. 89 00:03:23,090 --> 00:03:23,970 ‫I hope that was helpful, 90 00:03:23,970 --> 00:03:25,920 ‫and I will see you in the next lecture.