GithubHelp home page GithubHelp logo

Comments (3)

ottokruse avatar ottokruse commented on August 19, 2024

Deploy successfully for first time using using SAM CLI (Option 2 in README) straight from this git repo witout any changes

Always great to hear that all works straight out of the box!

About your issue. I had to peak at the SAM template and I think I can explain what is going on and what you can do.

Looking at the ReactApp in the template, none of it's properties will change, if you update the React app code. Therefore, CloudFormation will not update this resource.

A trick to force update, is to add a dummy parameter, eg "Version". Even though that parameter is not used by the handler, CloudFormation does not know that, and will issue the update because it sees an input property has changed:

ReactApp:
  Type: Custom::ReactApp
  Condition: CreateCloudFrontDistributionSpaMode
  Properties:
    ServiceToken: !GetAtt ReactAppHandler.Arn
    BucketName: !Ref S3Bucket
    UserPoolArn: !If
      - CreateUserPoolAndClient
      - !GetAtt UserPool.Arn
      - !Ref UserPoolArn
    ClientId: !If
      - CreateUserPoolAndClient
      - !Ref UserPoolClient
      - !Ref UserPoolClientId
    CognitoAuthDomain: !Ref UserPoolDomainLookup
    RedirectPathSignIn: !Ref RedirectPathSignIn
    RedirectPathSignOut: !Ref RedirectPathSignOut
    OAuthScopes: !Join
      - ","
      - !Ref OAuthScopes
    SignOutUrl: !Ref SignOutUrl
    Version: 1  # Dummy field, change this to force CloudFormation to deploy this resource if none of the other properties change

(There is a similar field for the Lambda functions already, where this same issue occurs during development.)

Let me know if that works for you.

Now to the question, how is this supposed to work? Well I guess we did not suppose people would use the provided React app deployment mechanism to deploy updates too. Instead we figured they would just upload to the S3 bucket directly (using a utility such as s3-spa-upload).

This could use some better instructions in the docs! (For which PR's are appreciated by the way)

from cloudfront-authorization-at-edge.

tonybranfort avatar tonybranfort commented on August 19, 2024

Both of those options definitely work for me. That was really my question - how should this work? I suspected that the change wasn't getting triggered in the CloudFormation template but wanted to make sure I wasn't missing something.

Thanks for the full working example here and fast response to my question. I submitted a PR to update the README.

from cloudfront-authorization-at-edge.

tonybranfort avatar tonybranfort commented on August 19, 2024

And just to confirm that it worked - adding the dummy parameter Version to template.yaml ReactApp resource works. Running build and deploy steps after updating the react-app code and updating the value of the Version (subsequent deploys) did deploy the react-app code fully (to the s3 bucket).

Thanks again for your work and help.

from cloudfront-authorization-at-edge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.