Frontent build error in Amplify when calling external data

Hello. I am getting a build error for the frontend when deploying my website in AWS Amplify. The issue only comes up when using a GetRemote function. The issue does NOT come up, when testing my website in Cloud9 via $ hugo deploy --port 8080 or $ hugo. Only in Amplify, the issue comes up. In Amplify, I have granted my execution role Admin rights for a test. This did not resolve the issue. I am using Live package updates for hugo.

This is the function I am calling in one of my posts:

{{ $data := "" }}
{{ $url := "https://pegel-konstanz-for-website.s3.eu-central-1.amazonaws.com/json/demo.json" }}
{{ with resources.GetRemote $url }}
  {{ with .Err }}
    {{ errorf "%s" . }}
  {{ else }}
    {{ $data = . | transform.Unmarshal }}
  {{ end }}
{{ else }}
  {{ errorf "Unable to get remote resource %q" $url }}
{{ end }}

{{ with $data }}
 The current level of Lake Constance (Bodensee) is at {{ .current_level }} cm ( {{.change_vs_yesterday }} cm compared to the previous day).
{{ end }}

This is the error I get for the Frontend during the Build phase:


2024-01-22T07:56:42.686Z [INFO]: Start building sites …
                                 hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154 linux/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=gohugoio
2024-01-22T07:56:42.781Z [INFO]: ERROR failed to fetch remote resource: Forbidden
2024-01-22T07:56:42.881Z [INFO]: Total in 245 ms
                                 Error: error building site: logged 1 error(s)
2024-01-22T07:56:42.884Z [ERROR]: !!! Build failed
2024-01-22T07:56:42.884Z [ERROR]: !!! Non-Zero Exit Code detected

Any input appreciated. I am very irritated right now.

This isn’t a Hugo problem. Check your bucket permissions, and test by opening the URL in a browser.

Thank you for your response. Agreed. This is not a Hugo problem. This is an AWS setup issue related to Hugo.
I transitioned the discussion to the Amplify Discord channel:

Happy to close and or delete this Topic here.

This is what I see when visiting the URL in a browser:

Thank you! Spot on. My mistake.
The bucket is public. The policy was right. But I had provided the wrong URL in my function.

I am very sorry for bugging you with an unnecessary question here.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.