Hadron / carthage-aws

AWS Plugin for Carthage
Other
2 stars 2 forks source link

Deploy raises with readonly=DryRun despite being set explicitly as readonly=False #32

Open srak289 opened 7 months ago

srak289 commented 7 months ago

On attempting to create an AwsSubnet with the following model code:

    class network_test_vpc(AwsVirtualPrivateCloud):
        name = f"network-test-vpc"
        region_name = "us-east-1"
        vpc_cidr = "172.31.0.0/16"
        # readonly = True

    class network_test_subnet(NetworkModel):
        name = f"network-test-subnet"
        readonly = False
        v4_config = V4Config(
            network = "172.31.0.0/24",
            gateway = "172.31.0.1",
            dhcp=True
        )

This error was raised:

PYTHONPATH=/root/project/blueteam_layout/../carthage: /root/project/blueteam_layout/../carthage/bin/carthage-runner --no-tmux --tasks-verbose . deploy
Loading cached SSO token for default
Task construct for vpc:network-test-vpc determined complete by check_completed_func(); no timestamp provided
Task construct never run for AwsSubnet:network-test-subnet (172.31.0.0/24)
Running construct task for AwsSubnet:network-test-subnet (172.31.0.0/24)
Error running construct for AwsSubnet:network-test-subnet (172.31.0.0/24):
Traceback (most recent call last):
  File "/root/project/blueteam_layout/../carthage/carthage/setup_tasks.py", line 510, in run_setup_tasks
    await ainjector(t, self)
  File "/root/project/blueteam_layout/../carthage/carthage/dependency_injection/base.py", line 1296, in __call__
    return await res
           ^^^^^^^^^
  File "/root/project/blueteam_layout/../carthage/carthage/dependency_injection/base.py", line 756, in _handle_async
    res = await p
          ^^^^^^^
  File "/root/.carthage/checkout/carthage_aws/carthage_aws/connection.py", line 409, in find_or_create
    raise LookupError(f'unable to find AWS resource for {self} and creation was not enabled')
LookupError: unable to find AWS resource for AwsSubnet:network-test-subnet (172.31.0.0/24) and creation was not enabled
Error resolving dependency for Instantiating InjectionKey(AwsSubnet) using <Injector claimed by <carthage.carthage_plugins.blueteam_layout.layout.layout.network_test_subnet object at 0x7f1d1b347410>>

This task executed successfully when run with --generate --start rather than deploy.

Perhaps the network model attribute readonly is not transferred to the object.

hartmans commented 6 months ago

It's definitely the case that readonly will not cascade from NetworkModel into AwsSubnet. But I don't really see how readonly is getting set to True in your AwsSubnet.

I'd expect that readonly would get set to DryRun if you run deploy without --force, but all the DryRuns should get turned into False by the time deploy runs for real. What does your full deployment report look like? Or does it not get as far as asking you if you want a deployment and printing a report?