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

Robust fix needed for non-interactive cloudfront-auth #4

Open
plaurent opened this issue May 7, 2021 · 2 comments
Open

Robust fix needed for non-interactive cloudfront-auth #4

plaurent opened this issue May 7, 2021 · 2 comments

Comments

@plaurent
Copy link
Contributor

plaurent commented May 7, 2021

The main issue is that the cloudfront-auth repo code is interactive only, doesn't support non-interactive CLI usage or loading all settings from a preconfigured file.

The tool we are using to build the CloudFront authentication lambda (https://github.com/Widen/cloudfront-auth) - Connect to preview only supports interactive mode. Even with a saved out configuration file, it continues to interactively prompt — it just uses the saved configuration for the prompt defaults. This does not lend itself to automation.
However, I was able to add a single line of code to enable command line-based automation for our use case. That's how this action is currently working -- it is patching in that line prior to run. But we're going to need something more robust/less hackish.

Options:

  • PR to Widen/cloudfront-auth ?
  • Fork Widen/cloudfront-auth ?

I noticed there's already a PR dated Mar 1 in Widen/cloudfront-auth to address our use case and more (Widen/cloudfront-auth#84). But it's much more than a one-line change. If that gets merged that will resolve our issues. Just not sure when that'll happen.

Rob has suggested either:

  • I suggest fork and apply the pull request(84), and then track and revert to main when fixed.
  • Also fine with leaving with your patch for now, if arkadiy reviews.
@plaurent
Copy link
Contributor Author

plaurent commented May 7, 2021

The hack in question is currently found at https://github.com/DMGT-TECH/authenticated-cloud-docs/blob/main/.github/workflows/deploy-static-site.yaml#L44:

    - name: Patch cloudfront-auth to allow non-interative (CLI) use
      run: |
        cd ./deployment/cloudfront-auth
        sed -i"" "s/^prompt.start/prompt.override=require('minimist')(process.argv.slice(2), opts={boolean:true, string:['method', 'AUTHZ']});prompt.start/" build/build.js

@plaurent
Copy link
Contributor Author

plaurent commented May 7, 2021

Sidenote: the above hack depends on minimist being available, which I'm not explicitly adding as a requirement to package.json (it is however a sub-dependency).

@plaurent plaurent changed the title Robust needed for non-interactive cloudfront-auth Robust fix needed for non-interactive cloudfront-auth May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant