I am trying to access the Cloudfront Cache Statistics programmatically. Via the UI you can see the Statistics via clicking on "CloudFront" and then on the left side under "Reports & analytics" the link "Cache Statistics".
I am using the Java SDK 1.11. However the structure is similar in all sdk bindings. I already tried:
AmazonCloudFront cloudFront = AmazonCloudFrontClientBuilder.defaultClient();
GetDistributionRequest request = new GetDistributionRequest();
request.setId("E3C1N6KKRS04QE");
GetDistributionResult result = cloudFront.getDistribution(request);
System.out.println(result);
However, that seems to get my the information shown on the "Distribution"-Tab in the UI. Any help would be appreciated!
Related
Looking for help on how to have a appery.io ionic 5 app upload images, files, videos etc. to aws S3. I am using aws DynamoDB thru API Express successfully and can get a presigned S3 URL thru API Express as well. My problem is using the presigned URL to upload a image/file. Tried fetch, httpClient etc. Some Guidence would be greatly appreciated.
Thank you
To work with binary data in API Express you can do the following:
Create new service of Custom REST API type
In START node select POST method and Binary for request body
With that you should be able to select Binary request as parameter value in SQL node
The second part of the question is how can you get the binary data if you have fileUrl.
Import API Express service created on a previous step into your project with Create New > API Express service
On Code tab create a variable named buffer of type Any
On Data tab add datasource for the imported API Express service. In Before send mapping connect buffer with body.data
Drop the button on Screen1
Add event with TypeScript code to it:
fetch(fileUrl).then(res => res.arrayBuffer()).then(arrayBuffer => {
this.buffer = arrayBuffer;
this.Apperyio.execDataService(this, "myAexService");
});
Following this article, I'm trying to serve my website's static content from multiple regions.
The lambda function in that article is trying to modify the property of an object within this path:
event.Records[0].cf.request.origin.s3
This is in the case that my lambda function is not receiving such a property. Instead, I'm getting:
event.Records[0].cf.request.origin.custom
Apparently, this means that I'm receiving a CustomOriginConfig while the article is expecting an S3OriginConfig. I'm not sure what these two mean but the UI depicted in the article for the "Edit Origin" page is totally different from mine.
The article shows this:
And I've got this:
Can someone please help me find why I'm receiving a CustomOriginConfig instead of an S3OriginConfig?
CloudFront only considers the origin to be an S3 Origin if the Origin Domain Name is the REST endpoint for the bucket -- e.g. ${bucketname}.s3.amazonaws.com. This is the configuration that supports authentication of requests on the back-side of CloudFront using an Origin Access Identity.
If you are using S3's web site hosting features (index and error documents, and/or redirects) then you use the web site hosting endpoint for the bucket, e.g. ${bucketname}.s3-website.${region}.amazonaws.com. CloudFront actually treats this configuration as a Custom Origin, the same as if you are using any (non-S3) web service as the origin server. Origin Access Identity and S3 website endpoints are not compatible with each other.
The console options change depending on whether the console sees that you're creating an S3 or Custom Origin (based on the hostname).
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html
I have an API source I am using on a report. It works fine on my Desktop, and I added the URL and Basic Login credentials to my Gateway. I get an error that my source is unable to update, but I don't know why. When I test the connection in my Gateway it says it connects fine. For some reason my published data set doesn't recognize the report's source as the same one as the one in my gateway.
Is there any additional step required in publishing a Web Data Source in order to make it use the gateway's web source?
This is the Error I get:
This is the Gateway's connection to the API:
This is the (Much Truncated) version of the Query I am using to retrieve the data:
let
Url = "https://rest.avatax.com/api/v2/companies/XXXX/transactions/",
RawData = Web.Contents(Url),
Json = Json.Document(RawData)
in
Json
This an incredibly annoying "feature", but the Power BI service does a different code analysis than Power BI Desktop. The way to overcome it is to present a static URL like this:
let
Source = Json.Document(Web.Contents("https://rest.avatax.com/api/v2/companies/XXXX/transactions/"))
in
Source
Chris Webb described this in more detail (along with hacks to make the URL dynamic) in this blog post:
https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/
I'm using AWS Cloudfront to service audio files to user. Recently several user reported that they are unable to play my audio file. A browser refresh is required to make it work if the audio is stuck.
In the Google Chrome console, it outputs
Failed to load resource:
net::ERR_CACHE_OPERATION_NOT_SUPPORTED
I already have a cache settings in my Cloudfront Behavior settings,
Only default settings is on the origin s3 bucket.
CF cache settings
Any suggestion?
I faced the same issue with a cloudfront video failing to load due to this error. I was able to resolve it using javascript like this:
var videoLink = videoControl1.children[0].src; // videoControl1 is the HTML5 video element, should work similarly for audio.
if (!videoControl1.readyState){
videoControl1.children[0].src = videoLink + "?v=" + Math.random();
videoControl1.load();
}
I followed the suggestion from here: https://github.com/igvteam/igv.js/issues/424#issuecomment-336336788
If you are going to change audio/video source dynamically and play that video/audio, you need to load with load() JS function first that resource before playing.
I'm trying to set a Content-Security-Policy header for an html file I'm serving via s3/cloudfront. I'm using the web-based AWS console. Whenever I try to add the header:
it doesn't seem to respect it. What can I do to make sure this header is served?
I'm having the same problem (using S3/CloudFront) and it appears there is currently no way to set this up easily.
S3 has a whitelist of the headers permitted, and Content-Security-Policy is not on it. Whilst it is true you can use the prefixed x-amz-meta-Content-Security-Policy, this is unhelpful as there is no browser support for it.
There are two options I can see.
1) you can serve the html content from a webserver on an EC2 instance and set that up as another CloudFront origin. Not really a great solution.
2) include the CSP as a meta tag within your html document:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src http://*.foobar.com 'self'">
...
This option is not as widely supported by browsers, but it appears to work with both Webkit and Firefox, so the current Chrome, Firefox, Safari (and IOS 7 Safari) seem to support it.
I chose 2 as it was the simpler/cheaper/faster solution and I hope AWS will add the CSP header in the future.
S3/CloudFront takes any headers that the origin set and forward those to the client, but you can't set custom headers on you response directly.
You can use Lambda#Edge function that can inject security headers through CloudFront.
Here is how the process works: (reference aws blog)
Viewer navigates to website.
Before CloudFront serves content from the cache it will trigger any
Lambda function associated with the Viewer Request trigger for that
behavior.
CloudFront serves content from the cache if available, otherwise it
goes to step 4.
Only after CloudFront cache ‘Miss’, Origin Request trigger is fired
for that behavior.
S3 Origin returns content.
After content is returned from S3 but before being cached in
CloudFront, Origin Response trigger is fired.
After content is cached in CloudFront, Viewer Response trigger is
fired and is the final step before viewer receives content.
Viewer receives content.
Below is the blog from aws on how to do this step by step.
https://aws.amazon.com/blogs/networking-and-content-delivery/adding-http-security-headers-using-lambdaedge-and-amazon-cloudfront/
If you are testing through CloudFront, have you made sure you have invalidated the cached objects? Can you try to upload a completely new file and then try accessing it via CF and see if the header is still not there?
Update
Seems like custom metadata will not work as expected as per DOC. Any metadata other than the ones supported by S3 (the ones displayed in the dropdown) will have to be prefixed with x-amz-meta-