aws-cloudfront | Amazon CloudFront Management Tool | AWS library
kandi X-RAY | aws-cloudfront Summary
kandi X-RAY | aws-cloudfront Summary
Amazon CloudFront Management Tool
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aws-cloudfront
aws-cloudfront Key Features
aws-cloudfront Examples and Code Snippets
Community Discussions
Trending Discussions on aws-cloudfront
QUESTION
I'm trying to use CDK and CodePipeline to build and deploy a React application to S3. After the CodePipeline
phase, in my own stack, I defined the S3 bucket like this:
ANSWER
Answered 2022-Jan-28 at 07:51For the first question:
And if I change to Source.asset("./build") I get the error: ... Why is it searching for the build directory on my machine?
This is happening when you run cdk synth
locally. Remember, cdk synth
will always reference the file system where this command is run. Locally it will be your machine, in the pipeline it will be in the container or environment that is being used by AWS CodePipeline.
Dig a little deeper into BucketDeployment
But also, there is some interesting things that happen here that could be helpful. BucketDeployment
doesn't just pull from the source you reference in BucketDeployment.sources
and upload it to the bucket you specify in BucketDeployment.destinationBucket
. According to the BucketDeployment docs the assets are uploaded to an intermediary bucket and then later merged to your bucket. This matters because it will explain your error received Error: Cannot find asset at C:\Users\pupeno\Code\ww3fe\build
because when you run cdk synth
it will expect the dir ./build
as stated in Source.asset("./build")
to exist.
This gets really interesting when trying to use a CodePipeline
to build and deploy a single page app like React in your case. By default, CodePipeline will execute a Source
step, followed a Synth
step, then any of the waves or stages you add after. Adding a wave that builds your react app won't work right away because we now see that the output directory of building you react app is needed during the Synth
step because of how BucketDeployment
works. We need to be able to have the order be Source -> Build -> Synth -> Deploy. As found in this question, we can control the order of the steps by using inputs and outputs. CodePipeline will order the steps to ensure input/output dependencies are met. So we need the have our Synth step use the Build's output as its input.
Concerns with the currently defined pipeline
I believe that your current pipeline is missing a CodeBuildStep
that would bundle your react app and output it to the directory that you specified in BucketDeployment.sources
. We also need to set the inputs to order these actions correctly. Below are some updates to the pipeline definition, though some changes may need to be made to have the correct file paths. Also, set BucketDeployment.sources
to the dir where your app bundle is written to.
QUESTION
I've an Angular project on a Bitbucket repository. I created this pipeline that deploys the application on AWS S3 and invalidate the CloudFront distribution. Everything works fine. I would like to add the build number to the published version in order to know not just the version of the application but also the build that generated it.
...ANSWER
Answered 2022-Feb-08 at 11:15The Bitbucket Pipelines yml file is just running Bash/shell commands on a Linux Docker machine. So you can use the normal Bash commands, like sed and perl, to do a "find and replace" inside a JSON text file.
1. Generate the correct Regular ExpressionWe need to write an expression that will search the text in a file for "version": "dd.dd.dd"
and replace it with "version": "dd.dd.ddb123"
, where "d"
is a digit from 0-9
.
Use https://regex101.com to write and test a regex that does this. Here's a working expression and demo and an explanation: https://regex101.com/r/sRviUF/2
- Regular Expression:
("version".*:.*"\d.*(?="))
- Substitution:
${1}b123
Explanation:
(
and)
= Capture the found text as group 1, to use it as a substitution/replacement later"version".*:.*"
= Look for the string"version":"
with 0 or more spaces allowed before and after the colon:
\d.*(?=")
= Look for a single digit0-9
, then any characters. Then use a Positive Lookahead(?=")
to stop the capture before the next speech mark character"
${1}b123
= Replace with the captured group 1, then add a"b"
then add the numbers123
.
Test and practice on a Linux or MacOS Terminal, or use the Linux Bash Shell on Windows 10, or use an online Linux Terminal.
You will discover that the sed command cannot handle regexes with positive lookahead or negative lookahead, so we have to use perl
instead. We also need to simulate the BITBUCKET_BUILD_NUMBER
environment variable that is available on the Docker machine when the Pipeline is running.
QUESTION
I've been trying to read a properties file and want it to be dynamic, I'm doing this in aws-cdk.
My project layout:
- Main Project
- resources
- config.properties
- src
- main/java/com/myorg
- xxxstage.java
- main/java/com/myorg
- resources
The class xxxstage.java has following code:
...ANSWER
Answered 2022-Jan-19 at 02:24I found an answer here and it worked for me. The location of properties file matters.
QUESTION
I have deployed my website here:
...ANSWER
Answered 2022-Jan-17 at 09:09Your website doesn't feel like 100% (client side) static website. By that I mean every HTML page is pre-generated and everything is static on client side. If that's the case then /work/1
should not load any html page as it's not a html resource. For it to be HTML resource it should be like /work/1.html
With that being said, it looks like you're using React or some other technology which translates the routing when previous page is known. /
-> /work/1
As you have CloudFront already in your stack. Just set the error pages to redirect back to home page and then it should work fine. Attaching the solution for my react app hosted on S3+CloudFront.
QUESTION
Case:
I have a few S3 buckets that store my media files. I wanted to map all these s3 buckets to a single CF distribution. (their files should be accessed from different paths).
I have made a CF distribution and added 2 buckets. For the behaviour, the first bucket is on Default(*) and the second bucket is on path nature/*.
Issues:
- I am able to access the primary bucket (one with default behaviour) but not able to access the secondary bucket (with path nature/*). The error on accessing the secondary bucket is "Access Denied".
Additional details:
- Both my buckets are not available to global access and CF is accessing them from OAI.
References:
...ANSWER
Answered 2022-Jan-03 at 08:34Your files in the second bucket must start with a top level prefix nature/
or else the won't resolve. CF doesn't remove the path matched when routing, it is still there. If you can't move the objects in the second bucket into a nature/
prefix, then you need a CF Function to remove this part of the path from the object key before forwarding the request to the S3 origin.
QUESTION
When I run terraspace bundle
I see the following error message:
ANSWER
Answered 2021-Sep-11 at 22:34I decided to try rm -rf /private/tmp/terraspace/bundler/cache/
on each of the failing modules.
After I did so the modules installed correctly:
QUESTION
I'm using AWS CDK to construct a CloudFront Ingress for various other microservices. It seems super inconsistent in when it works, normally only the first request, then it completely fails.
I'm making sure to invalidate the entire distribution and making sure everything has updated before I test any changes, but I'm having no luck.
My goal is:
/graphql
-> API Gateway/app/*
-> S3 Website Bucket (App Static SPA)* (Default)
-> S3 Website Bucket (Website Static SPA)
I'm using a CloudFront Function to rewrite requests for the non-default origins to remove the prefix:
...ANSWER
Answered 2021-Sep-11 at 10:19Turns out, the response headers from S3 & API Gateway needed to be changed to account for Cache-Control
- using a Lambda@Edge to modify them to not be cached, as well as the ttl
configuration, solved the issue.
QUESTION
I have my main CDK stack in eu-west-1
, but an EdgeFunction
is created in us-east-1
.
I have noticed two weird things with EdgeFunction
:
- Even if declared in a
NestedStack
they appear incdk ls
asedge-lambda-stack-nnnnnnnnn
(unless given an explicit name). - When removing the main stack, let's call it
primary
, it does not remove the lambda stack. Probably because (1) above tells me it's not a part of theNestedStack
.
I have tried putting the EdgeFunction
in a separate stack created in us-east-1
explicitly and then cross-referencing it from primary
but that fails with "Cannot use resource in a cross-environment fashion" (amongst others).
- Why doesn't
cloudfront.experimental.EdgeFunction
respect theNestedStack
boundary? - Can I somehow build a
Stack
that exists inus-east-1
and cross-reference the lambda into my main stack ineu-west-1
? - Can I at least make it so that deleting the
primary
stack also automatically deletes the lambda stack.
The reason I'm asking is because I have a number of environments and a number of lambdas and the combinatorial explosion of stacks makes things a bit unwieldly.
ExampleCDK version 1.116
...ANSWER
Answered 2021-Aug-24 at 21:02I talked to AWS premium support and the answer is that it doesn't seem like CDK can handle this by using nested stacks.
Instead, create a separate stack for the EdgeLambdas in us-east-1
and then export the ARNs of the lambdas to SSM.
In the other stack, import the ARNs from SSM and use those.
This will result in the minimum amount of stacks to handle. You will still need to deploy the two stacks separately.
The code I ended up using looks like this:
QUESTION
I have an existing CDK setup in which a CloudFormation distribution is configured using the deprecated CloudFrontWebDistribution API, now I need to configure a OriginRequestPolicy, so after some Googling, switched to the Distribution API (https://docs.aws.amazon.com/cdk/api/latest/docs/aws-cloudfront-readme.html) and reused the same "id" -
Distribution distribution = Distribution.Builder.create(this, "CFDistribution")
When I synth the stack I already see in the yaml that the ID - e.g. CloudFrontCFDistribution12345689 - is a different one than the one before.
When trying to deploy it will fail, since the HTTP Origin CNAMEs are already associated with the existing distribution. ("Invalid request provided: One or more of the CNAMEs you provided are already associated with a different resource. (Service: CloudFront, Status Code: 409, Request ID: 123457657, Extended Request ID: null)"
Is there a way to either add the OriginRequestPolicy (I just want to transfer an additional header) to the CloudFrontWebDistribution or a way to use the new Distribution API while maintaining the existing distribution instead of creating a new one? (The same operation takes around 3 clicks in the AWS Console).
...ANSWER
Answered 2021-Aug-12 at 20:56You could use the following trick to assign the logical ID yourself instead of relying on the autogenerated logical ID. The other option is to execute it in two steps, first update it without the additional CNAME and then do a second update with the additional CNAME.
QUESTION
Code:
...ANSWER
Answered 2021-Aug-04 at 08:36LambdaFunctionAssociations should take in: lambdaFunction
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aws-cloudfront
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page