| 1 |
--- |
| 2 |
# ============================================================ |
| 3 |
- name: 'Setup AWS Module Defaults' |
| 4 |
module_defaults: |
| 5 |
group/aws: |
| 6 |
access_key: '{{ aws_access_key }}' |
| 7 |
secret_key: '{{ aws_secret_key }}' |
| 8 |
session_token: '{{ security_token | default(omit) }}' |
| 9 |
region: '{{ aws_region }}' |
| 10 |
kinesis_stream: |
| 11 |
# Number of shards is mandatory when state=present |
| 12 |
shards: 1 |
| 13 |
|
| 14 |
block: |
| 15 |
# ============================================================ |
| 16 |
# Set up some additional resources for later user |
| 17 |
|
| 18 |
- name: 'KMS test preperation - only run when explicitly enabled' |
| 19 |
when: |
| 20 |
- run_kms_tests | default(False) | bool |
| 21 |
block: |
| 22 |
# KMS Keys |
| 23 |
# Note: Because we're not a producer / consumer we don't actually need |
| 24 |
# access to the keys |
| 25 |
- name: 'Create KMS key 1' |
| 26 |
kms_key: |
| 27 |
alias: '{{ kms_cmk_alias_1 }}' |
| 28 |
state: present |
| 29 |
enabled: yes |
| 30 |
register: create_kms_1 |
| 31 |
- name: 'Create KMS key 2' |
| 32 |
kms_key: |
| 33 |
alias: '{{ kms_cmk_alias_2 }}' |
| 34 |
state: present |
| 35 |
enabled: yes |
| 36 |
register: create_kms_2 |
| 37 |
- name: 'Assert that we sucessfully created our keys' |
| 38 |
assert: |
| 39 |
that: |
| 40 |
- create_kms_1 is success |
| 41 |
- create_kms_2 is success |
| 42 |
- name: 'Store the Key IDs for later' |
| 43 |
set_fact: |
| 44 |
kms_cmk_id_1: '{{ create_kms_1.key_id }}' |
| 45 |
kms_cmk_arn_1: '{{ create_kms_1.key_arn }}' |
| 46 |
kms_cmk_id_2: '{{ create_kms_2.key_id }}' |
| 47 |
kms_cmk_arn_2: '{{ create_kms_2.key_arn }}' |
| 48 |
# All of the valid ways to describe the CMK |
| 49 |
kms_cmk_1: |
| 50 |
- '{{ create_kms_1.key_id }}' |
| 51 |
- 'alias/{{ kms_cmk_alias_1 }}' |
| 52 |
- '{{ create_kms_1.key_arn }}' |
| 53 |
kms_cmk_2: |
| 54 |
- '{{ create_kms_2.key_id }}' |
| 55 |
- 'alias/{{ kms_cmk_alias_2 }}' |
| 56 |
- '{{ create_kms_2.key_arn }}' |
| 57 |
|
| 58 |
# ============================================================ |
| 59 |
# Basic creation |
| 60 |
- name: 'Create a basic Kinesis stream (CHECK_MODE)' |
| 61 |
check_mode: yes |
| 62 |
kinesis_stream: |
| 63 |
name: '{{ kinesis_stream_name }}' |
| 64 |
register: result |
| 65 |
- name: 'Assert state is changed when first creating a stream (CHECK_MODE)' |
| 66 |
assert: |
| 67 |
that: |
| 68 |
- result is success |
| 69 |
- result is changed |
| 70 |
|
| 71 |
- name: 'Create a basic Kinesis stream' |
| 72 |
kinesis_stream: |
| 73 |
name: '{{ kinesis_stream_name }}' |
| 74 |
register: result |
| 75 |
- name: 'Assert state is changed when first creating a stream' |
| 76 |
assert: |
| 77 |
that: |
| 78 |
- result is success |
| 79 |
- result is changed |
| 80 |
- result.encryption_type == 'NONE' |
| 81 |
- result.open_shards_count == 1 |
| 82 |
- result.retention_period_hours == 24 |
| 83 |
- result.stream_arn.startswith('arn:aws:kinesis:') |
| 84 |
- result.stream_arn.endswith(':stream/' + kinesis_stream_name) |
| 85 |
- result.stream_name == kinesis_stream_name |
| 86 |
- result.stream_status == 'ACTIVE' |
| 87 |
- result.tags == {} |
| 88 |
|
| 89 |
# We've run tests that the ARN matches the pattern we expect, we can just test |
| 90 |
# it doesn't change. |
| 91 |
- name: 'Save Stream ARN for later comparison' |
| 92 |
set_fact: |
| 93 |
kinesis_stream_arn: '{{ result.stream_arn }}' |
| 94 |
|
| 95 |
- name: 'Create a basic Kinesis stream - Idempotency (CHECK_MODE)' |
| 96 |
check_mode: yes |
| 97 |
kinesis_stream: |
| 98 |
name: '{{ kinesis_stream_name }}' |
| 99 |
register: result |
| 100 |
- name: 'Assert state is not changed when re-running the create (CHECK_MODE)' |
| 101 |
assert: |
| 102 |
that: |
| 103 |
- result is success |
| 104 |
- result is not changed |
| 105 |
|
| 106 |
- name: 'Create a basic Kinesis stream - Idempotency' |
| 107 |
kinesis_stream: |
| 108 |
name: '{{ kinesis_stream_name }}' |
| 109 |
register: result |
| 110 |
- name: 'Assert state is not changed when re-running the create' |
| 111 |
assert: |
| 112 |
that: |
| 113 |
- result is success |
| 114 |
- result is not changed |
| 115 |
- result.encryption_type == 'NONE' |
| 116 |
- result.open_shards_count == 1 |
| 117 |
- result.retention_period_hours == 24 |
| 118 |
- result.stream_arn == kinesis_stream_arn |
| 119 |
- result.stream_name == kinesis_stream_name |
| 120 |
- result.stream_status == 'ACTIVE' |
| 121 |
- result.tags == {} |
| 122 |
|
| 123 |
# ============================================================ |
| 124 |
# Retention Period |
| 125 |
# |
| 126 |
- name: 'Increase the retention period (CHECK_MODE)' |
| 127 |
check_mode: yes |
| 128 |
kinesis_stream: |
| 129 |
name: '{{ kinesis_stream_name }}' |
| 130 |
retention_period: 72 |
| 131 |
register: result |
| 132 |
- name: 'Assert state is changed when changing the retention period (CHECK_MODE)' |
| 133 |
assert: |
| 134 |
that: |
| 135 |
- result is success |
| 136 |
- result is changed |
| 137 |
|
| 138 |
- name: 'Increase the retention period' |
| 139 |
kinesis_stream: |
| 140 |
name: '{{ kinesis_stream_name }}' |
| 141 |
retention_period: 72 |
| 142 |
register: result |
| 143 |
- name: 'Assert state is changed when changing the retention period' |
| 144 |
assert: |
| 145 |
that: |
| 146 |
- result is success |
| 147 |
- result is changed |
| 148 |
- result.encryption_type == 'NONE' |
| 149 |
- result.open_shards_count == 1 |
| 150 |
- result.retention_period_hours == 72 |
| 151 |
- result.stream_arn == kinesis_stream_arn |
| 152 |
- result.stream_name == kinesis_stream_name |
| 153 |
- result.stream_status == 'ACTIVE' |
| 154 |
- result.tags == {} |
| 155 |
|
| 156 |
- name: 'Increase the retention period - Idempotency (CHECK_MODE)' |
| 157 |
check_mode: yes |
| 158 |
kinesis_stream: |
| 159 |
name: '{{ kinesis_stream_name }}' |
| 160 |
retention_period: 72 |
| 161 |
register: result |
| 162 |
- name: 'Assert state is not changed when not changing the retention period (CHECK_MODE)' |
| 163 |
assert: |
| 164 |
that: |
| 165 |
- result is success |
| 166 |
- result is not changed |
| 167 |
|
| 168 |
- name: 'Increase the retention period - Idempotency' |
| 169 |
kinesis_stream: |
| 170 |
name: '{{ kinesis_stream_name }}' |
| 171 |
retention_period: 72 |
| 172 |
register: result |
| 173 |
- name: 'Assert state is not changed when not changing the retention period' |
| 174 |
assert: |
| 175 |
that: |
| 176 |
- result is success |
| 177 |
- result is not changed |
| 178 |
- result.encryption_type == 'NONE' |
| 179 |
- result.open_shards_count == 1 |
| 180 |
- result.retention_period_hours == 72 |
| 181 |
- result.stream_arn == kinesis_stream_arn |
| 182 |
- result.stream_name == kinesis_stream_name |
| 183 |
- result.stream_status == 'ACTIVE' |
| 184 |
- result.tags == {} |
| 185 |
|
| 186 |
- name: 'Decrease the retention period (CHECK_MODE)' |
| 187 |
check_mode: yes |
| 188 |
kinesis_stream: |
| 189 |
name: '{{ kinesis_stream_name }}' |
| 190 |
retention_period: 48 |
| 191 |
register: result |
| 192 |
- name: 'Assert state is changed when changing the retention period (CHECK_MODE)' |
| 193 |
assert: |
| 194 |
that: |
| 195 |
- result is success |
| 196 |
- result is changed |
| 197 |
|
| 198 |
- name: 'Decrease the retention period' |
| 199 |
kinesis_stream: |
| 200 |
name: '{{ kinesis_stream_name }}' |
| 201 |
retention_period: 48 |
| 202 |
register: result |
| 203 |
- name: 'Assert state is changed when changing the retention period' |
| 204 |
assert: |
| 205 |
that: |
| 206 |
- result is success |
| 207 |
- result is changed |
| 208 |
- result.encryption_type == 'NONE' |
| 209 |
- result.open_shards_count == 1 |
| 210 |
- result.retention_period_hours == 48 |
| 211 |
- result.stream_arn == kinesis_stream_arn |
| 212 |
- result.stream_name == kinesis_stream_name |
| 213 |
- result.stream_status == 'ACTIVE' |
| 214 |
- result.tags == {} |
| 215 |
|
| 216 |
- name: 'Decrease the retention period - Idempotency (CHECK_MODE)' |
| 217 |
check_mode: yes |
| 218 |
kinesis_stream: |
| 219 |
name: '{{ kinesis_stream_name }}' |
| 220 |
retention_period: 48 |
| 221 |
register: result |
| 222 |
- name: 'Assert state is not changed when not changing the retention period (CHECK_MODE)' |
| 223 |
assert: |
| 224 |
that: |
| 225 |
- result is success |
| 226 |
- result is not changed |
| 227 |
|
| 228 |
- name: 'Decrease the retention period - Idempotency' |
| 229 |
kinesis_stream: |
| 230 |
name: '{{ kinesis_stream_name }}' |
| 231 |
retention_period: 48 |
| 232 |
register: result |
| 233 |
- name: 'Assert state is not changed when not changing the retention period' |
| 234 |
assert: |
| 235 |
that: |
| 236 |
- result is success |
| 237 |
- result is not changed |
| 238 |
- result.encryption_type == 'NONE' |
| 239 |
- result.open_shards_count == 1 |
| 240 |
- result.retention_period_hours == 48 |
| 241 |
|
| 242 |
# ============================================================ |
| 243 |
# Basic tagging |
| 244 |
|
| 245 |
- name: 'Set some tags (CHECK_MODE)' |
| 246 |
check_mode: yes |
| 247 |
kinesis_stream: |
| 248 |
name: '{{ kinesis_stream_name }}' |
| 249 |
tags: '{{ kinesis_stream_tags_1 }}' |
| 250 |
register: result |
| 251 |
- name: 'Assert state is changed when adding tags (CHECK_MODE)' |
| 252 |
assert: |
| 253 |
that: |
| 254 |
- result is success |
| 255 |
- result is changed |
| 256 |
|
| 257 |
- name: 'Set some tags' |
| 258 |
kinesis_stream: |
| 259 |
name: '{{ kinesis_stream_name }}' |
| 260 |
tags: '{{ kinesis_stream_tags_1 }}' |
| 261 |
register: result |
| 262 |
- name: 'Assert state is changed when adding tags' |
| 263 |
assert: |
| 264 |
that: |
| 265 |
- result is success |
| 266 |
- result.encryption_type == 'NONE' |
| 267 |
- result.open_shards_count == 1 |
| 268 |
- result.retention_period_hours == 48 |
| 269 |
- result.stream_arn == kinesis_stream_arn |
| 270 |
- result.stream_name == kinesis_stream_name |
| 271 |
- result.stream_status == 'ACTIVE' |
| 272 |
- name: 'Assert tags return as expected' |
| 273 |
assert: |
| 274 |
that: |
| 275 |
- result is changed |
| 276 |
- result.tags == kinesis_stream_tags_1 |
| 277 |
|
| 278 |
- name: 'Set some tags - Idempotency (CHECK_MODE)' |
| 279 |
check_mode: yes |
| 280 |
kinesis_stream: |
| 281 |
name: '{{ kinesis_stream_name }}' |
| 282 |
tags: '{{ kinesis_stream_tags_1 }}' |
| 283 |
register: result |
| 284 |
- name: 'Assert state is not changed when not changing the tags (CHECK_MODE)' |
| 285 |
assert: |
| 286 |
that: |
| 287 |
- result is success |
| 288 |
- result is not changed |
| 289 |
|
| 290 |
- name: 'Set some tags - Idempotency' |
| 291 |
kinesis_stream: |
| 292 |
name: '{{ kinesis_stream_name }}' |
| 293 |
tags: '{{ kinesis_stream_tags_1 }}' |
| 294 |
register: result |
| 295 |
- name: 'Assert state is not changed when not changing the tags' |
| 296 |
assert: |
| 297 |
that: |
| 298 |
- result is success |
| 299 |
- result is not changed |
| 300 |
- result.encryption_type == 'NONE' |
| 301 |
- result.open_shards_count == 1 |
| 302 |
- result.retention_period_hours == 48 |
| 303 |
- result.stream_arn == kinesis_stream_arn |
| 304 |
- result.stream_name == kinesis_stream_name |
| 305 |
- result.stream_status == 'ACTIVE' |
| 306 |
# Merge this into the main assertion when the return values are no longer |
| 307 |
# snake_cased |
| 308 |
- name: 'Assert tags return as expected' |
| 309 |
assert: |
| 310 |
that: |
| 311 |
- result.tags == kinesis_stream_tags_1 |
| 312 |
# XXX BUG (Tag_snake) |
| 313 |
ignore_errors: yes |
| 314 |
|
| 315 |
- name: 'Change some tags (CHECK_MODE)' |
| 316 |
check_mode: yes |
| 317 |
kinesis_stream: |
| 318 |
name: '{{ kinesis_stream_name }}' |
| 319 |
tags: '{{ kinesis_stream_tags_2 }}' |
| 320 |
register: result |
| 321 |
- name: 'Assert state is changed when changing tags (CHECK_MODE)' |
| 322 |
assert: |
| 323 |
that: |
| 324 |
- result is success |
| 325 |
- result is changed |
| 326 |
|
| 327 |
- name: 'Change some tags' |
| 328 |
kinesis_stream: |
| 329 |
name: '{{ kinesis_stream_name }}' |
| 330 |
tags: '{{ kinesis_stream_tags_2 }}' |
| 331 |
register: result |
| 332 |
- name: 'Assert state is changed when changing tags' |
| 333 |
assert: |
| 334 |
that: |
| 335 |
- result is success |
| 336 |
- result.encryption_type == 'NONE' |
| 337 |
- result.open_shards_count == 1 |
| 338 |
- result.retention_period_hours == 48 |
| 339 |
- result.stream_arn == kinesis_stream_arn |
| 340 |
- result.stream_name == kinesis_stream_name |
| 341 |
- result.stream_status == 'ACTIVE' |
| 342 |
# Merge this into the main assertion when the return values are no longer |
| 343 |
# snake_cased |
| 344 |
- name: 'Assert tags return as expected (tags2)' |
| 345 |
assert: |
| 346 |
that: |
| 347 |
- result is changed |
| 348 |
- result.tags == kinesis_stream_tags_2 |
| 349 |
# XXX BUG (Tag_changed) (Tag_snake) |
| 350 |
ignore_errors: yes |
| 351 |
|
| 352 |
- name: 'Change some tags - Idempotency (CHECK_MODE)' |
| 353 |
check_mode: yes |
| 354 |
kinesis_stream: |
| 355 |
name: '{{ kinesis_stream_name }}' |
| 356 |
tags: '{{ kinesis_stream_tags_2 }}' |
| 357 |
register: result |
| 358 |
- name: 'Assert state is not changed when not changing the tags (CHECK_MODE)' |
| 359 |
assert: |
| 360 |
that: |
| 361 |
- result is success |
| 362 |
- result is not changed |
| 363 |
|
| 364 |
- name: 'Change some tags - Idempotency' |
| 365 |
kinesis_stream: |
| 366 |
name: '{{ kinesis_stream_name }}' |
| 367 |
tags: '{{ kinesis_stream_tags_2 }}' |
| 368 |
register: result |
| 369 |
- name: 'Assert state is not changed when not changing the tags' |
| 370 |
assert: |
| 371 |
that: |
| 372 |
- result is success |
| 373 |
- result is not changed |
| 374 |
- result.encryption_type == 'NONE' |
| 375 |
- result.open_shards_count == 1 |
| 376 |
- result.retention_period_hours == 48 |
| 377 |
- result.stream_arn == kinesis_stream_arn |
| 378 |
- result.stream_name == kinesis_stream_name |
| 379 |
- result.stream_status == 'ACTIVE' |
| 380 |
# Merge this into the main assertion when the return values are no longer |
| 381 |
# snake_cased |
| 382 |
- name: 'Assert tags return as expected (tags2)' |
| 383 |
assert: |
| 384 |
that: |
| 385 |
- result.tags == kinesis_stream_tags_2 |
| 386 |
# XXX BUG (Tag_snake) |
| 387 |
ignore_errors: yes |
| 388 |
|
| 389 |
# ============================================================ |
| 390 |
# Number of shards |
| 391 |
# |
| 392 |
- name: 'Change the number of shards (CHECK_MODE)' |
| 393 |
check_mode: yes |
| 394 |
kinesis_stream: |
| 395 |
name: '{{ kinesis_stream_name }}' |
| 396 |
shards: 2 |
| 397 |
register: result |
| 398 |
- name: 'Assert state is changed when changing the number of shards (CHECK_MODE)' |
| 399 |
assert: |
| 400 |
that: |
| 401 |
- result is success |
| 402 |
- result is changed |
| 403 |
|
| 404 |
- name: 'Change the number of shards' |
| 405 |
kinesis_stream: |
| 406 |
name: '{{ kinesis_stream_name }}' |
| 407 |
shards: 2 |
| 408 |
register: result |
| 409 |
- name: 'Assert state is changed when changing the number of shards' |
| 410 |
assert: |
| 411 |
that: |
| 412 |
- result is success |
| 413 |
- result is changed |
| 414 |
- result.encryption_type == 'NONE' |
| 415 |
- result.open_shards_count == 2 |
| 416 |
- result.retention_period_hours == 48 |
| 417 |
- result.stream_arn == kinesis_stream_arn |
| 418 |
- result.stream_name == kinesis_stream_name |
| 419 |
- result.stream_status == 'ACTIVE' |
| 420 |
#- result.tags == kinesis_stream_tags_2 |
| 421 |
# Merge this into the main assertion when the tag keys are no longer |
| 422 |
# snake_cased |
| 423 |
- name: 'Assert tags return as expected (tags2)' |
| 424 |
assert: |
| 425 |
that: |
| 426 |
- result.tags == kinesis_stream_tags_2 |
| 427 |
# XXX BUG (Tag_snake) |
| 428 |
ignore_errors: yes |
| 429 |
|
| 430 |
- name: 'Change the number of shards - Idempotency (CHECK_MODE)' |
| 431 |
check_mode: yes |
| 432 |
kinesis_stream: |
| 433 |
name: '{{ kinesis_stream_name }}' |
| 434 |
shards: 2 |
| 435 |
register: result |
| 436 |
- name: 'Assert state is not changed when not changing the number of shards (CHECK_MODE)' |
| 437 |
assert: |
| 438 |
that: |
| 439 |
- result is success |
| 440 |
- result is not changed |
| 441 |
|
| 442 |
- name: 'Change the number of shards - Idempotency' |
| 443 |
kinesis_stream: |
| 444 |
name: '{{ kinesis_stream_name }}' |
| 445 |
shards: 2 |
| 446 |
register: result |
| 447 |
- name: 'Assert state is not changed when not changing the number of shards' |
| 448 |
assert: |
| 449 |
that: |
| 450 |
- result is success |
| 451 |
- result is not changed |
| 452 |
- result.encryption_type == 'NONE' |
| 453 |
- result.open_shards_count == 2 |
| 454 |
- result.retention_period_hours == 48 |
| 455 |
- result.stream_arn == kinesis_stream_arn |
| 456 |
- result.stream_name == kinesis_stream_name |
| 457 |
- result.stream_status == 'ACTIVE' |
| 458 |
#- result.tags == kinesis_stream_tags_2 |
| 459 |
# Merge this into the main assertion when the tag keys are no longer |
| 460 |
# snake_cased |
| 461 |
- name: 'Assert tags return as expected (tags2)' |
| 462 |
assert: |
| 463 |
that: |
| 464 |
- result.tags == kinesis_stream_tags_2 |
| 465 |
# XXX BUG (Tag_snake) |
| 466 |
ignore_errors: yes |
| 467 |
|
| 468 |
# ============================================================ |
| 469 |
# Shards has to be passed we can't test that it's not updated when we're not |
| 470 |
# setting it. Let's reset it to the value we set in the module_defaults |
| 471 |
|
| 472 |
- name: 'Reset the number of shards' |
| 473 |
kinesis_stream: |
| 474 |
name: '{{ kinesis_stream_name }}' |
| 475 |
register: result |
| 476 |
- name: 'Assert the change was successful' |
| 477 |
assert: |
| 478 |
that: |
| 479 |
- result is success |
| 480 |
- result is changed |
| 481 |
- result.open_shards_count == 1 |
| 482 |
|
| 483 |
# DISABLED BY DEFAULT - KMS key creation/deletion not supported in CI at this time |
| 484 |
- name: 'KMS tests - only run when explicitly enabled' |
| 485 |
when: |
| 486 |
- run_kms_tests | default(False) | bool |
| 487 |
block: |
| 488 |
# ============================================================ |
| 489 |
# Encryption |
| 490 |
- name: 'Test encryption' |
| 491 |
vars: |
| 492 |
key_type: '{{ item.type }}' |
| 493 |
kinesis_key: '{{ item.key }}' |
| 494 |
kinesis_key_id: '{{ kms_cmk_id_1 }}' |
| 495 |
kinesis_key_alias: 'alias/{{ kms_cmk_alias_1 }}' |
| 496 |
kinesis_key_arn: '{{ kms_cmk_arn_1 }}' |
| 497 |
include_tasks: 'test_encryption.yml' |
| 498 |
# Loop through and test the management and idempotency when using the |
| 499 |
# various combinations of ID, alias and ARN of a CMK |
| 500 |
loop: |
| 501 |
- type: 'ID' |
| 502 |
key: '{{ kms_cmk_id_1 }}' |
| 503 |
- type: 'Alias' |
| 504 |
key: 'alias/{{ kms_cmk_alias_1 }}' |
| 505 |
- type: 'ARN' |
| 506 |
key: '{{ kms_cmk_arn_1 }}' |
| 507 |
|
| 508 |
- name: 'Disable encryption - Idempotency (CHECK_MODE)' |
| 509 |
kinesis_stream: |
| 510 |
name: '{{ kinesis_stream_name }}' |
| 511 |
encryption_state: 'disabled' |
| 512 |
register: result |
| 513 |
- name: 'Assert state is not changed when encryption_state not changed (CHECK_MODE)' |
| 514 |
ignore_errors: yes |
| 515 |
assert: |
| 516 |
that: |
| 517 |
- result is success |
| 518 |
- result is not changed |
| 519 |
# XXX BUG (Enc_idemp) |
| 520 |
|
| 521 |
- name: 'Disable encryption - Idempotency' |
| 522 |
kinesis_stream: |
| 523 |
name: '{{ kinesis_stream_name }}' |
| 524 |
encryption_state: 'disabled' |
| 525 |
register: result |
| 526 |
- name: 'Assert state is not changed when encryption_state not changed (CHECK_MODE)' |
| 527 |
assert: |
| 528 |
that: |
| 529 |
- result is success |
| 530 |
- result is not changed |
| 531 |
# Merge this into the main assertion when the main return keys are |
| 532 |
# snake_cased |
| 533 |
- name: 'Assert expected return values' |
| 534 |
assert: |
| 535 |
that: |
| 536 |
- result.encryption_type == 'NONE' |
| 537 |
- result.open_shards_count == 1 |
| 538 |
- result.retention_period_hours == 48 |
| 539 |
- result.stream_arn == kinesis_stream_arn |
| 540 |
- result.stream_name == kinesis_stream_name |
| 541 |
- result.stream_status == 'ACTIVE' |
| 542 |
#- result.tags == kinesis_stream_tags_2 |
| 543 |
# XXX BUG (Enc_snake) |
| 544 |
ignore_errors: yes |
| 545 |
# Merge this into the main assertion when the tag keys are no longer |
| 546 |
# snake_cased |
| 547 |
- name: 'Assert tags return as expected (tags2)' |
| 548 |
assert: |
| 549 |
that: |
| 550 |
- result.tags == kinesis_stream_tags_2 |
| 551 |
# XXX BUG (Tag_snake) |
| 552 |
ignore_errors: yes |
| 553 |
|
| 554 |
- name: 'Enable encryption' |
| 555 |
kinesis_stream: |
| 556 |
name: '{{ kinesis_stream_name }}' |
| 557 |
encryption_state: 'enabled' |
| 558 |
encryption_type: 'KMS' |
| 559 |
key_id: '{{ kms_cmk_id_1 }}' |
| 560 |
register: result |
| 561 |
- name: 'Assert that state is changed when enabling encryption' |
| 562 |
assert: |
| 563 |
that: |
| 564 |
- result is success |
| 565 |
- result is changed |
| 566 |
|
| 567 |
- name: 'Test encryption changed state when updating key (CHECK_MODE)' |
| 568 |
check_mode: yes |
| 569 |
kinesis_stream: |
| 570 |
name: '{{ kinesis_stream_name }}' |
| 571 |
encryption_state: 'enabled' |
| 572 |
encryption_type: 'KMS' |
| 573 |
key_id: '{{ kms_cmk_id_2 }}' |
| 574 |
register: result |
| 575 |
- name: 'Assert state is changed when stream encryption key is changed (CHECK_MODE)' |
| 576 |
assert: |
| 577 |
that: |
| 578 |
- result is success |
| 579 |
- result is changed |
| 580 |
|
| 581 |
- name: 'Test encryption changed state when updating key' |
| 582 |
kinesis_stream: |
| 583 |
name: '{{ kinesis_stream_name }}' |
| 584 |
encryption_state: 'enabled' |
| 585 |
encryption_type: 'KMS' |
| 586 |
key_id: '{{ kms_cmk_id_2 }}' |
| 587 |
register: result |
| 588 |
- name: 'Assert state is changed when stream encryption key is changed' |
| 589 |
assert: |
| 590 |
that: |
| 591 |
- result is success |
| 592 |
- result is changed |
| 593 |
# Merge this into the main assertion when the main return keys are |
| 594 |
# snake_cased |
| 595 |
- name: 'Assert expected return values' |
| 596 |
assert: |
| 597 |
that: |
| 598 |
- result.encryption_type == 'KMS' |
| 599 |
- result.key_id in kms_cmk_2 |
| 600 |
- result.open_shards_count == 1 |
| 601 |
- result.retention_period_hours == 48 |
| 602 |
- result.stream_arn == kinesis_stream_arn |
| 603 |
- result.stream_name == kinesis_stream_name |
| 604 |
- result.stream_status == 'ACTIVE' |
| 605 |
#- result.tags == kinesis_stream_tags_2 |
| 606 |
# XXX BUG (Enc_snake) |
| 607 |
ignore_errors: yes |
| 608 |
# Merge this into the main assertion when the tag keys are no longer |
| 609 |
# snake_cased |
| 610 |
- name: 'Assert tags return as expected (tags2)' |
| 611 |
assert: |
| 612 |
that: |
| 613 |
- result.tags == kinesis_stream_tags_2 |
| 614 |
# XXX BUG (Tag_snake) |
| 615 |
ignore_errors: yes |
| 616 |
|
| 617 |
# ============================================================ |
| 618 |
|
| 619 |
- name: 'Delete stream (CHECK_MODE)' |
| 620 |
check_mode: yes |
| 621 |
module_defaults: { kinesis_stream: {} } |
| 622 |
kinesis_stream: |
| 623 |
name: '{{ kinesis_stream_name }}' |
| 624 |
state: absent |
| 625 |
register: result |
| 626 |
- name: 'Assert state is changed when deleting a stream (CHECK_MODE)' |
| 627 |
assert: |
| 628 |
that: |
| 629 |
- result is success |
| 630 |
- result is changed |
| 631 |
|
| 632 |
- name: 'Delete stream' |
| 633 |
module_defaults: { kinesis_stream: {} } |
| 634 |
kinesis_stream: |
| 635 |
name: '{{ kinesis_stream_name }}' |
| 636 |
state: absent |
| 637 |
register: result |
| 638 |
- name: 'Assert state is changed when deleting a stream' |
| 639 |
assert: |
| 640 |
that: |
| 641 |
- result is success |
| 642 |
- result is changed |
| 643 |
|
| 644 |
- name: 'Delete stream - Idempotency (CHECK_MODE)' |
| 645 |
check_mode: yes |
| 646 |
module_defaults: { kinesis_stream: {} } |
| 647 |
kinesis_stream: |
| 648 |
name: '{{ kinesis_stream_name }}' |
| 649 |
state: absent |
| 650 |
register: result |
| 651 |
- name: 'Assert state is not changed when deleting a stream that was previously deleted (CHECK_MODE)' |
| 652 |
assert: |
| 653 |
that: |
| 654 |
- result is success |
| 655 |
- result is not changed |
| 656 |
|
| 657 |
- name: 'Delete stream - Idempotency' |
| 658 |
module_defaults: { kinesis_stream: {} } |
| 659 |
kinesis_stream: |
| 660 |
name: '{{ kinesis_stream_name }}' |
| 661 |
state: absent |
| 662 |
register: result |
| 663 |
- name: 'Assert state is not changed when deleting a stream that was previously deleted' |
| 664 |
assert: |
| 665 |
that: |
| 666 |
- result is success |
| 667 |
- result is not changed |
| 668 |
|
| 669 |
always: |
| 670 |
# ============================================================ |
| 671 |
- name: 'Ensure Kinesis stream is gone' |
| 672 |
ignore_errors: yes |
| 673 |
kinesis_stream: |
| 674 |
name: '{{ kinesis_stream_name }}' |
| 675 |
state: absent |
| 676 |
|
| 677 |
- name: 'KMS test preperation - only run when explicitly enabled' |
| 678 |
when: |
| 679 |
- run_kms_tests | default(False) | bool |
| 680 |
block: |
| 681 |
- name: 'Delete the KMS keys' |
| 682 |
ignore_errors: yes |
| 683 |
kms_key: |
| 684 |
state: absent |
| 685 |
alias: '{{ item }}' |
| 686 |
loop: |
| 687 |
- '{{ kms_cmk_alias_1 }}' |
| 688 |
- '{{ kms_cmk_alias_2 }}' |