Conditionally Add Postgres Extension
When working with AWS Aurora, you might want to qualify if an extension is available. In this instance, we are checking if the extension is available from the catalog of extensions.
DO $$
BEGIN
IF EXISTS (
SELECT
FROM pg_available_extensions
WHERE name = 'aws_s3') THEN
CREATE EXTENSION IF NOT EXISTS aws_s3 CASCADE;
END IF;
END
$$;