hubverse-org / hubverse-infrastructure

MIT License
0 stars 0 forks source link

Formatting fixes and first pass at a test suite for Pulumi code #33

Closed bsweger closed 5 months ago

bsweger commented 5 months ago

Resolves Infectious-Disease-Modeling-Hubs/hubverse-cloud#69

There is more detail in the individual commit messages, but this is an (anemic) first pass at getting a test harness into our infrastructure code base.

Aside from that, most of the diff is some additional updates from the ruff linter.

github-actions[bot] commented 5 months ago

:tropical_drink: preview on hubverse-aws/bsweger/hubverse-aws/hubverse

Pulumi report ``` Previewing update (hubverse) View Live: https://app.pulumi.com/bsweger/hubverse-aws/hubverse/previews/dee42fe3-b369-4a0c-9a73-c76f5c759548 @ Previewing update......... @ Previewing update..... pulumi:pulumi:Stack hubverse-aws-hubverse running @ Previewing update.... aws:s3:Bucket hubverse-infrastructure-test aws:s3:BucketPublicAccessBlock hubverse-infrastructure-test-public-access-block aws:s3:BucketPolicy hubverse-infrastructure-test-read-bucket-policy aws:iam:Role hubverse-infrastructure-test aws:iam:Policy hubverse-infrastructure-test-write-bucket-policy aws:s3:Bucket hubverse-cloud aws:iam:RolePolicyAttachment hubverse-infrastructure-test aws:s3:BucketPublicAccessBlock hubverse-cloud-public-access-block aws:s3:BucketPolicy hubverse-cloud-read-bucket-policy aws:iam:Role hubverse-cloud aws:iam:Policy hubverse-cloud-write-bucket-policy aws:iam:RolePolicyAttachment hubverse-cloud pulumi:pulumi:Stack hubverse-aws-hubverse Resources: 13 unchanged ```
bsweger commented 5 months ago

Approving this PR, with the caveat that I didn't feel like I understood what was being tested in test_s3.py or whether this constituted a complete/thorough test. (I'm assuming based on the word "anemic" in the PR description that you're just planning on filling this out more later 😂 )

This sole test is checking that the S3 bucket being created by Pulumi contains the expected AWS tag. Which is good, but not as important as testing things like: does our function create buckets with the appropriate permissions policies?

Which, as it turns out, aren't easily testable out-of-the-box via the unit test mocking tools that Pulumi provides.

In the end, it might be more fruitful to unit test resources like buckets and lambdas and use a policy or integration test framwork (for example) to test our permissions.