Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement canary file generation functionality from contract test inp… #1069

Merged
merged 2 commits into from
May 30, 2024

Conversation

rajdnp
Copy link
Contributor

@rajdnp rajdnp commented May 21, 2024

Description of changes:
Implement canary file generation functionality from contract test inputs.
The 'cfn init' command will add canarySettings to enable canary generation.
Based on the canarySettings, the 'cfn generate' command will generate canary files for contract test inputs.

Testing :
Scenarios :

  1. Validated if current resources are not affected by the change
  2. Validated if this is enabled by default for new resources.
  3. Validate if canary files are not generated when setting is manually turned off
  4. Validate if all the input files are generated
  5. Validate if canaries are generated, only the valid input files.
Positive case: 

"canarySettings": {
        "file_generation_enabled": false,
        "contract_test_file_names": [
            "inputs_1.json","inputs_3.json"
        ]
    }
cfn generate 

(env) ➜  testcfncli cd canary-bundle/canary 
(env) ➜  canary ls -lrt
total 16
-rw-r--r--  1 xxx  staff  513 May 21 09:48 canary1_001.yaml
-rw-r--r--  1 xxx  staff  425 May 21 09:48 canary2_001.yaml
(env) ➜  canary cat canary2_001.yaml
Description: Canary template for AWS::Route53::RecordSet
Resources:
  RecordSetCanary:
    Properties:
      GeoLocation:
        ContinentCode: NA
      HostedZoneId:
        Fn::ImportValue: awsroute53recordsetcto1
      Name: 3-8921be3b-3a99-4015-a8c3-ae7545aacd7a.ct.test
      ResourceRecords:
      - 192.0.2.98
      SetIdentifier: geolocationrecordset
      TTL: '900'
      Type: A
    Type: AWS::Route53::RecordSet
(env) ➜  canary cd ../                 
(env) ➜  canary-bundle ls     
bootstrap.yaml canary

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@joshuadeanhall
Copy link

Should canary generation be part of the main CLI or be a new plugin?

@rajdnp
Copy link
Contributor Author

rajdnp commented May 22, 2024

Should canary generation be part of the main CLI or be a new plugin?
Idea is to generate canary files for 3P resources as well. As there is no canary framework for 3p, Service team can use these files manually if required.
It is a two-way door. If we see issues, we can easily restrict the file generation only to AWS/AMZN prefix.

src/rpdk/core/generate_canary.py Outdated Show resolved Hide resolved
src/rpdk/core/generate_canary.py Outdated Show resolved Hide resolved
src/rpdk/core/generate_stack_templates.py Outdated Show resolved Hide resolved
src/rpdk/core/generate_stack_templates.py Outdated Show resolved Hide resolved
src/rpdk/core/generate_stack_templates.py Outdated Show resolved Hide resolved
src/rpdk/core/generate_stack_templates.py Outdated Show resolved Hide resolved
@rajdnp rajdnp requested a review from ammokhov May 29, 2024 22:00
@ammokhov ammokhov added enhancement New feature or request codegen It's like magic! cli experience labels May 30, 2024
@ammokhov ammokhov merged commit f1a165e into aws-cloudformation:master May 30, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli experience codegen It's like magic! enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants