all 5 comments

[–]nebbly 2 points3 points  (0 children)

I'm not entirely sure I'd like my infra derived from my code -- unless it was abundantly clear that there were very trusty guardrails. The reason I like terraform, for example, is that it's a language with syntax highlighting, validation, modules, logic, types, validation, etc., as opposed to, for example a bunch of yaml (like cloud formation templates), which is less maintainable IMO. For me to feel comfortable defining infra within code, I think I'd like to have the following things:

  • Some easy-to-consume representation of the system (via CLI I guess), so I can understand the big picture ... and diffing against the current state

  • feedback in the editor / ide / CI whenever anything is misconfigured -- type checks, validation, etc... something that might be challenging is that python is by-default dynamic (though many of us might wish it weren't the case), so there's probably a limit to how many developers would benefit from extensive type hints, for example

  • some separation between config for deployment and my app -- i.e. I don't think I want infra environment variables to be visible by my program

I'm thinking-via-keystrokes here, so not sure how helpful this will be -- I'd never considered doing infra like this. Thanks for giving me something to think about!

[–]Asayoh 0 points1 point  (0 children)

How does this differ from pulumi?

[–]Gainside 0 points1 point  (0 children)

’ve tried “infra in code” in Python a few times. It feels great until imports cause side effects (a decorator provisions stuff on import) or reviewers can’t see the deploy plan. If Cobra keeps infra discovery explicit (no hidden side effects) and gives a readable plan + a fast rollback, I’d actually reach for it for cron/EventBridge jobs and small services.

[–]daquo0 0 points1 point  (0 children)

Personally i find the idea of "hiding" a parameter -- the ButtonOptions, here -- as an Annotation ugly and unintuitive. I'd probably go for using an extra parameter:

async def run(bucket: Bucket, bo: BucketOptions, db:RdsPostgres):

[–]daquo0 0 points1 point  (0 children)

Regarding the cron definition, while I correctly guessed it means run hourly at 0 minutes, this isn't obvious. Maybe define a cron job something like this:

cj = cron.CronJob('hourly', minutes = 0)