|
2 | 2 | let(:cf) { instance_double(Aws::CloudFormation::Client) } |
3 | 3 | let(:config) { instance_double(StackMaster::Config) } |
4 | 4 | let(:options) { Commander::Command::Options.new } |
5 | | - let(:stack_definition) { instance_double(StackMaster::StackDefinition, stack_name: 'myapp', region: 'us-east-1') } |
| 5 | + let(:ignore_resource_types) { [] } |
| 6 | + let(:stack_definition) { instance_double(StackMaster::StackDefinition, stack_name: 'myapp', region: 'us-east-1', ignore_resource_types: ignore_resource_types) } |
6 | 7 |
|
7 | 8 | subject(:drift) { described_class.new(config, stack_definition, options) } |
8 | 9 | let(:stack_drift_detection_id) { 123 } |
|
118 | 119 | end |
119 | 120 | end |
120 | 121 |
|
| 122 | + context 'when all drifted resources are in the ignore list' do |
| 123 | + let(:stack_drift_status) { 'DRIFTED' } |
| 124 | + let(:ignore_resource_types) { ['AWS::ElastiCache::ParameterGroup'] } |
| 125 | + let(:stack_resource_drifts) do |
| 126 | + [ |
| 127 | + Aws::CloudFormation::Types::StackResourceDrift.new( |
| 128 | + stack_resource_drift_status: 'MODIFIED', |
| 129 | + resource_type: 'AWS::ElastiCache::ParameterGroup', |
| 130 | + logical_resource_id: 'CacheParams', |
| 131 | + physical_resource_id: 'params-1', |
| 132 | + property_differences: [] |
| 133 | + ) |
| 134 | + ] |
| 135 | + end |
| 136 | + |
| 137 | + it 'exits with success' do |
| 138 | + drift.perform |
| 139 | + expect(drift).to be_success |
| 140 | + end |
| 141 | + |
| 142 | + it 'still displays the drift for visibility' do |
| 143 | + expect { drift.perform }.to output(/MODIFIED AWS::ElastiCache::ParameterGroup CacheParams params-1/).to_stdout |
| 144 | + end |
| 145 | + end |
| 146 | + |
| 147 | + context 'when only some drifted resources are in the ignore list' do |
| 148 | + let(:stack_drift_status) { 'DRIFTED' } |
| 149 | + let(:ignore_resource_types) { ['AWS::ElastiCache::ParameterGroup'] } |
| 150 | + let(:stack_resource_drifts) do |
| 151 | + [ |
| 152 | + Aws::CloudFormation::Types::StackResourceDrift.new( |
| 153 | + stack_resource_drift_status: 'MODIFIED', |
| 154 | + resource_type: 'AWS::ElastiCache::ParameterGroup', |
| 155 | + logical_resource_id: 'CacheParams', |
| 156 | + physical_resource_id: 'params-1', |
| 157 | + property_differences: [] |
| 158 | + ), |
| 159 | + Aws::CloudFormation::Types::StackResourceDrift.new( |
| 160 | + stack_resource_drift_status: 'MODIFIED', |
| 161 | + resource_type: 'AWS::EC2::SecurityGroup', |
| 162 | + logical_resource_id: 'SecurityGroup', |
| 163 | + physical_resource_id: 'sg-123456', |
| 164 | + property_differences: [property_difference] |
| 165 | + ) |
| 166 | + ] |
| 167 | + end |
| 168 | + |
| 169 | + it 'exits with failure' do |
| 170 | + drift.perform |
| 171 | + expect(drift).not_to be_success |
| 172 | + end |
| 173 | + end |
| 174 | + |
121 | 175 | context "when stack drift detection doesn't complete" do |
122 | 176 | before do |
123 | 177 | describe_stack_drift_detection_status_response.detection_status = 'UNKNOWN' |
|
0 commit comments