@@ -1725,6 +1725,143 @@ describe('cluster', () => {
17251725
17261726 } ) ;
17271727
1728+ testDeprecated ( 'updatePolicy set when passed without updateType' , ( ) => {
1729+ // GIVEN
1730+ const app = new cdk . App ( ) ;
1731+ const stack = new cdk . Stack ( app , 'test' ) ;
1732+
1733+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' ) ;
1734+ cluster . addCapacity ( 'bottlerocket-asg' , {
1735+ instanceType : new ec2 . InstanceType ( 'c5.large' ) ,
1736+ machineImage : new ecs . BottleRocketImage ( ) ,
1737+ updatePolicy : autoscaling . UpdatePolicy . replacingUpdate ( ) ,
1738+ } ) ;
1739+
1740+ // THEN
1741+ Template . fromStack ( stack ) . hasResource ( 'AWS::AutoScaling::AutoScalingGroup' , {
1742+ UpdatePolicy : {
1743+ AutoScalingReplacingUpdate : {
1744+ WillReplace : true ,
1745+ } ,
1746+ } ,
1747+ } ) ;
1748+ } ) ;
1749+
1750+ testDeprecated ( 'undefined updateType & updatePolicy replaced by default updatePolicy' , ( ) => {
1751+ // GIVEN
1752+ const app = new cdk . App ( ) ;
1753+ const stack = new cdk . Stack ( app , 'test' ) ;
1754+
1755+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' ) ;
1756+ cluster . addCapacity ( 'bottlerocket-asg' , {
1757+ instanceType : new ec2 . InstanceType ( 'c5.large' ) ,
1758+ machineImage : new ecs . BottleRocketImage ( ) ,
1759+ } ) ;
1760+
1761+ // THEN
1762+ Template . fromStack ( stack ) . hasResource ( 'AWS::AutoScaling::AutoScalingGroup' , {
1763+ UpdatePolicy : {
1764+ AutoScalingReplacingUpdate : {
1765+ WillReplace : true ,
1766+ } ,
1767+ } ,
1768+ } ) ;
1769+ } ) ;
1770+
1771+ testDeprecated ( 'updateType.NONE replaced by updatePolicy equivalent' , ( ) => {
1772+ // GIVEN
1773+ const app = new cdk . App ( ) ;
1774+ const stack = new cdk . Stack ( app , 'test' ) ;
1775+
1776+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' ) ;
1777+ cluster . addCapacity ( 'bottlerocket-asg' , {
1778+ instanceType : new ec2 . InstanceType ( 'c5.large' ) ,
1779+ machineImage : new ecs . BottleRocketImage ( ) ,
1780+ updateType : autoscaling . UpdateType . NONE ,
1781+ } ) ;
1782+
1783+ // THEN
1784+ Template . fromStack ( stack ) . hasResource ( 'AWS::AutoScaling::AutoScalingGroup' , {
1785+ UpdatePolicy : {
1786+ AutoScalingScheduledAction : {
1787+ IgnoreUnmodifiedGroupSizeProperties : true ,
1788+ } ,
1789+ } ,
1790+ } ) ;
1791+ } ) ;
1792+
1793+ testDeprecated ( 'updateType.REPLACING_UPDATE replaced by updatePolicy equivalent' , ( ) => {
1794+ // GIVEN
1795+ const app = new cdk . App ( ) ;
1796+ const stack = new cdk . Stack ( app , 'test' ) ;
1797+
1798+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' ) ;
1799+ cluster . addCapacity ( 'bottlerocket-asg' , {
1800+ instanceType : new ec2 . InstanceType ( 'c5.large' ) ,
1801+ machineImage : new ecs . BottleRocketImage ( ) ,
1802+ updateType : autoscaling . UpdateType . REPLACING_UPDATE ,
1803+ } ) ;
1804+
1805+ // THEN
1806+ Template . fromStack ( stack ) . hasResource ( 'AWS::AutoScaling::AutoScalingGroup' , {
1807+ UpdatePolicy : {
1808+ AutoScalingReplacingUpdate : {
1809+ WillReplace : true ,
1810+ } ,
1811+ } ,
1812+ } ) ;
1813+ } ) ;
1814+
1815+ testDeprecated ( 'updateType.ROLLING_UPDATE replaced by updatePolicy equivalent' , ( ) => {
1816+ // GIVEN
1817+ const app = new cdk . App ( ) ;
1818+ const stack = new cdk . Stack ( app , 'test' ) ;
1819+
1820+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' ) ;
1821+ cluster . addCapacity ( 'bottlerocket-asg' , {
1822+ instanceType : new ec2 . InstanceType ( 'c5.large' ) ,
1823+ machineImage : new ecs . BottleRocketImage ( ) ,
1824+ updateType : autoscaling . UpdateType . ROLLING_UPDATE ,
1825+ } ) ;
1826+
1827+ // THEN
1828+ Template . fromStack ( stack ) . hasResource ( 'AWS::AutoScaling::AutoScalingGroup' , {
1829+ UpdatePolicy : {
1830+ AutoScalingRollingUpdate : {
1831+ WaitOnResourceSignals : false ,
1832+ PauseTime : 'PT0S' ,
1833+ SuspendProcesses : [
1834+ 'HealthCheck' ,
1835+ 'ReplaceUnhealthy' ,
1836+ 'AZRebalance' ,
1837+ 'AlarmNotification' ,
1838+ 'ScheduledActions' ,
1839+ ] ,
1840+ } ,
1841+ AutoScalingScheduledAction : {
1842+ IgnoreUnmodifiedGroupSizeProperties : true ,
1843+ } ,
1844+ } ,
1845+ } ) ;
1846+ } ) ;
1847+
1848+ testDeprecated ( 'throws when updatePolicy and updateType both specified' , ( ) => {
1849+ // GIVEN
1850+ const app = new cdk . App ( ) ;
1851+ const stack = new cdk . Stack ( app , 'test' ) ;
1852+
1853+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' ) ;
1854+
1855+ expect ( ( ) => {
1856+ cluster . addCapacity ( 'bottlerocket-asg' , {
1857+ instanceType : new ec2 . InstanceType ( 'c5.large' ) ,
1858+ machineImage : new ecs . BottleRocketImage ( ) ,
1859+ updatePolicy : autoscaling . UpdatePolicy . replacingUpdate ( ) ,
1860+ updateType : autoscaling . UpdateType . REPLACING_UPDATE ,
1861+ } ) ;
1862+ } ) . toThrow ( "Cannot set 'signals'/'updatePolicy' and 'updateType' together. Prefer 'signals'/'updatePolicy'" ) ;
1863+ } ) ;
1864+
17281865 testDeprecated ( 'allows specifying capacityProviders (deprecated)' , ( ) => {
17291866 // GIVEN
17301867 const app = new cdk . App ( ) ;
0 commit comments