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

Issue 1819 cloudfront distribution origin s3 domain #1821

Conversation

gsimon75
Copy link
Contributor

SUMMARY

Fixes #1819

As per Origin Domain Name spec now the S3 domain names are in the form {name}.s3.{region}.amazonaws.com, so the string fragment .s3.amazonaws.com no longer occurs in them, and therefore they aren't recognised as S3 origin domains.

Consequentially, the origin is treated as a custom one, so a custom_origin_config member is generated into it, which collides with the s3_origin_config and produces an error:

botocore.errorfactory.InvalidOrigin: An error occurred (InvalidOrigin) when calling the CreateDistribution operation: You must specify either a CustomOrigin or an S3Origin. You cannot specify both.

The backward-compatible way is to recognise both {name}.s3.amazonaws.com and {name}.s3.{domain}.amazonaws.com, but for this a regular expression is the most effective solution.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

cloudfront_distribution

ADDITIONAL INFORMATION

The breakdown of the regex I used: \.s3(?:\.[^.]+)?\.amazonaws\.com$

  • \.s3 matches ".s3"
  • \.[^.]+ would match a dot followed by at least one, possibly more non-dot characters
  • (\.[^]+) would match the same, just grouped, so we could treat it as an atom
  • (?:\.[^]+) would match the same, just grouped in a non-capturing fashion (we don't want to extract the matched characters)
  • (?:\.[^]+)? matches the same, occuring 0 or 1 times
  • \.amazonaws\.com matches ".amazonaws.com"
  • $ matches the end of the input string

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/dd6b149b30d94bf394ed7061485100d6

✔️ ansible-galaxy-importer SUCCESS in 3m 42s
✔️ build-ansible-collection SUCCESS in 12m 40s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 17s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 9m 03s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 9m 37s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 9m 19s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 11m 03s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 5m 45s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 12m 34s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 24s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 5m 51s
✔️ ansible-test-changelog SUCCESS in 4m 22s
✔️ ansible-test-splitter SUCCESS in 5m 03s
✔️ integration-community.aws-1 SUCCESS in 22m 42s
Skipped 21 jobs

@alinabuzachis alinabuzachis added this to the 6.1.0 milestone May 25, 2023
@markuman
Copy link
Member

A test (integration or unit) would be nice. But not a blocker for me.
Not sure if the permissions are sufficient for such region checks? any thoughts about it @alinabuzachis

@markuman markuman added backport-6 PR should be backported to the stable-6 branch backport-5 PR should be backported to the stable-5 branch labels May 26, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/b310a00071844a9eb40f967b285acf6c

ansible-galaxy-importer FAILURE in 4m 31s
✔️ build-ansible-collection SUCCESS in 13m 03s
✔️ ansible-test-sanity-docker-devel SUCCESS in 9m 29s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 12m 59s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 18m 42s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 18m 15s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 24m 29s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 49s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 45s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 5m 40s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 5m 44s
✔️ ansible-test-changelog SUCCESS in 4m 52s
✔️ ansible-test-splitter SUCCESS in 5m 31s
✔️ integration-community.aws-1 SUCCESS in 21m 08s
Skipped 21 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/9b134efe2a5a49748d699598a9c10341

ansible-galaxy-importer FAILURE in 4m 11s
✔️ build-ansible-collection SUCCESS in 12m 46s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 47s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 55s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 16m 24s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 11m 48s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 10m 18s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 11s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 01s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 02s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 6m 48s
✔️ ansible-test-changelog SUCCESS in 4m 34s
✔️ ansible-test-splitter SUCCESS in 5m 00s
✔️ integration-community.aws-1 SUCCESS in 23m 22s
Skipped 21 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/f15ddc8e5d204bbf841741aa23b323f9

✔️ ansible-galaxy-importer SUCCESS in 3m 48s
✔️ build-ansible-collection SUCCESS in 12m 50s
✔️ ansible-test-sanity-docker-devel SUCCESS in 11m 40s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 8m 59s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 11m 21s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 11m 18s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 8m 53s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 56s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 33s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 5m 36s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 8m 08s
✔️ ansible-test-changelog SUCCESS in 4m 38s
✔️ ansible-test-splitter SUCCESS in 4m 49s
✔️ integration-community.aws-1 SUCCESS in 24m 37s
Skipped 21 jobs

@markuman markuman requested a review from alinabuzachis June 1, 2023 04:15
@alinabuzachis alinabuzachis added the mergeit Merge the PR (SoftwareFactory) label Jun 1, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/34cc71694ac9476b959d031ca1e2aef4

ansible-galaxy-importer FAILURE in 3m 59s
✔️ build-ansible-collection SUCCESS in 12m 59s
✔️ ansible-test-sanity-docker-devel SUCCESS in 12m 32s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 42s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 12m 44s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 33s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 13m 11s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 5m 48s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 20s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 8m 05s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 7m 42s
✔️ ansible-test-changelog SUCCESS in 4m 36s
✔️ ansible-test-splitter SUCCESS in 5m 07s
✔️ integration-community.aws-1 SUCCESS in 18m 50s
Skipped 21 jobs

@alinabuzachis
Copy link
Contributor

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/5f105260520c471d8db89b9dfae1e808

ansible-galaxy-importer FAILURE in 3m 53s
✔️ build-ansible-collection SUCCESS in 14m 05s
ansible-test-sanity-docker-devel FAILURE in 11m 41s (non-voting)
ansible-test-sanity-docker-milestone POST_FAILURE in 12m 19s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 47s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 12m 48s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 12m 48s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 27s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 59s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 7m 33s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 6m 51s
✔️ ansible-test-changelog SUCCESS in 4m 32s
✔️ ansible-test-splitter SUCCESS in 4m 56s
✔️ integration-community.aws-1 SUCCESS in 19m 13s
Skipped 21 jobs

@alinabuzachis
Copy link
Contributor

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/e68ba967fdc544ffacac6b842ecfd994

ansible-galaxy-importer FAILURE in 3m 51s
✔️ build-ansible-collection SUCCESS in 12m 52s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 28s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 11m 20s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 11m 01s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 54s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 10m 50s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 32s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 8m 52s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 00s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 9m 08s
✔️ ansible-test-changelog SUCCESS in 4m 55s
✔️ ansible-test-splitter SUCCESS in 5m 00s
integration-community.aws-1 RETRY_LIMIT in 1m 33s
Skipped 21 jobs

@alinabuzachis
Copy link
Contributor

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/53e611b795a24935ae59b20d777edd21

ansible-galaxy-importer FAILURE in 4m 00s
✔️ build-ansible-collection SUCCESS in 14m 57s
✔️ ansible-test-sanity-docker-devel SUCCESS in 11m 33s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 11m 53s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 14m 31s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 15m 15s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 10m 18s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 21s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 03s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 04s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 9m 35s
✔️ ansible-test-changelog SUCCESS in 4m 29s
✔️ ansible-test-splitter SUCCESS in 5m 19s
✔️ integration-community.aws-1 SUCCESS in 22m 40s
Skipped 21 jobs

@alinabuzachis
Copy link
Contributor

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/850e53a4d419465eaea032313be43eb1

ansible-galaxy-importer FAILURE in 4m 59s
✔️ build-ansible-collection SUCCESS in 12m 48s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 58s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 17s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 49s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 36s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 12m 38s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 22s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 7m 46s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 7m 01s
ansible-test-units-amazon-aws-python310 FAILURE in 5m 52s (non-voting)
✔️ ansible-test-changelog SUCCESS in 4m 32s
✔️ ansible-test-splitter SUCCESS in 4m 52s
integration-community.aws-1 RETRY_LIMIT in 3m 14s
Skipped 21 jobs

@markuman
Copy link
Member

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/1cc1dda025d2447aa3dba8dbb25d74c8

ansible-galaxy-importer FAILURE in 3m 51s
✔️ build-ansible-collection SUCCESS in 14m 29s
✔️ ansible-test-sanity-docker-devel SUCCESS in 11m 17s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 12m 01s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 32s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 27s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 10m 06s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 27s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 59s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 30s
ansible-test-units-amazon-aws-python310 FAILURE in 6m 06s (non-voting)
✔️ ansible-test-changelog SUCCESS in 4m 38s
✔️ ansible-test-splitter SUCCESS in 4m 56s
✔️ integration-community.aws-1 SUCCESS in 23m 35s
Skipped 21 jobs

@alinabuzachis
Copy link
Contributor

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/343e25381d2e4680b2a10399fc99994e

ansible-galaxy-importer FAILURE in 3m 56s
✔️ build-ansible-collection SUCCESS in 15m 10s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 11s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 40s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 11m 25s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 11m 19s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 10m 20s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 21s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 56s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 10s
ansible-test-units-amazon-aws-python310 FAILURE in 6m 21s (non-voting)
✔️ ansible-test-changelog SUCCESS in 4m 22s
✔️ ansible-test-splitter SUCCESS in 4m 43s
✔️ integration-community.aws-1 SUCCESS in 24m 17s
Skipped 21 jobs

@markuman
Copy link
Member

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/44efe5f03562493992c483d71eefc86a

ansible-galaxy-importer FAILURE in 4m 29s
✔️ build-ansible-collection SUCCESS in 13m 00s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 44s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 59s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 13m 19s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 12m 54s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 10m 54s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 47s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 15s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 07s
ansible-test-units-amazon-aws-python310 FAILURE in 5m 53s (non-voting)
✔️ ansible-test-changelog SUCCESS in 4m 39s
✔️ ansible-test-splitter SUCCESS in 5m 08s
✔️ integration-community.aws-1 SUCCESS in 20m 19s
Skipped 21 jobs

@markuman
Copy link
Member

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/912db8011d224829877cd57f5417ade3

✔️ ansible-galaxy-importer SUCCESS in 4m 09s
✔️ build-ansible-collection SUCCESS in 13m 37s
✔️ ansible-test-splitter SUCCESS in 6m 18s
✔️ integration-community.aws-1 SUCCESS in 20m 22s
Skipped 21 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).
https://ansible.softwarefactory-project.io/zuul/buildset/41c033e86b074952bef92a97132e8dce

✔️ ansible-galaxy-importer SUCCESS in 4m 33s
✔️ build-ansible-collection SUCCESS in 12m 29s
✔️ ansible-test-splitter SUCCESS in 6m 07s
✔️ integration-community.aws-1 SUCCESS in 20m 40s
Skipped 21 jobs

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 509ccad into ansible-collections:main Jun 22, 2023
@patchback
Copy link

patchback bot commented Jun 22, 2023

Backport to stable-5: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 509ccad on top of patchback/backports/stable-5/509ccad9fdf8961d2c1e7fde672f45979de6f1eb/pr-1821

Backporting merged PR #1821 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.aws.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-5/509ccad9fdf8961d2c1e7fde672f45979de6f1eb/pr-1821 upstream/stable-5
  4. Now, cherry-pick PR Issue 1819 cloudfront distribution origin s3 domain #1821 contents into that branch:
    $ git cherry-pick -x 509ccad9fdf8961d2c1e7fde672f45979de6f1eb
    If it'll yell at you with something like fatal: Commit 509ccad9fdf8961d2c1e7fde672f45979de6f1eb is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 509ccad9fdf8961d2c1e7fde672f45979de6f1eb
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Issue 1819 cloudfront distribution origin s3 domain #1821 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-5/509ccad9fdf8961d2c1e7fde672f45979de6f1eb/pr-1821
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link

patchback bot commented Jun 22, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/509ccad9fdf8961d2c1e7fde672f45979de6f1eb/pr-1821

Backported as #1849

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jun 22, 2023
Issue 1819 cloudfront distribution origin s3 domain

SUMMARY
Fixes #1819
As per Origin Domain Name spec now the S3 domain names are in the form {name}.s3.{region}.amazonaws.com, so the string fragment .s3.amazonaws.com no longer occurs in them, and therefore they aren't recognised as S3 origin domains.
Consequentially, the origin is treated as a custom one, so a custom_origin_config member is generated into it, which collides with the s3_origin_config and produces an error:

botocore.errorfactory.InvalidOrigin: An error occurred (InvalidOrigin) when calling the CreateDistribution operation: You must specify either a CustomOrigin or an S3Origin. You cannot specify both.

The backward-compatible way is to recognise both {name}.s3.amazonaws.com and {name}.s3.{domain}.amazonaws.com, but for this a regular expression is the most effective solution.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
cloudfront_distribution
ADDITIONAL INFORMATION
The breakdown of the regex I used: \.s3(?:\.[^.]+)?\.amazonaws\.com$

\.s3 matches ".s3"
\.[^.]+ would match a dot followed by at least one, possibly more non-dot characters
(\.[^]+) would match the same, just grouped, so we could treat it as an atom
(?:\.[^]+) would match the same, just grouped in a non-capturing fashion (we don't want to extract the matched characters)
(?:\.[^]+)? matches the same, occuring 0 or 1 times
\.amazonaws\.com matches ".amazonaws.com"
$ matches the end of the input string

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis
(cherry picked from commit 509ccad)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jun 26, 2023
lint - cloudfront_distribution - apply black formatting

SUMMARY
#1821 introduced some bad formatting
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
cloudfront_distribution
ADDITIONAL INFORMATION
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jul 2, 2023
…tion origin s3 domain (#1849)

[PR #1821/509ccad9 backport][stable-6] Issue 1819 cloudfront distribution origin s3 domain

This is a backport of PR #1821 as merged into main (509ccad).
SUMMARY
Fixes #1819
As per Origin Domain Name spec now the S3 domain names are in the form {name}.s3.{region}.amazonaws.com, so the string fragment .s3.amazonaws.com no longer occurs in them, and therefore they aren't recognised as S3 origin domains.
Consequentially, the origin is treated as a custom one, so a custom_origin_config member is generated into it, which collides with the s3_origin_config and produces an error:

botocore.errorfactory.InvalidOrigin: An error occurred (InvalidOrigin) when calling the CreateDistribution operation: You must specify either a CustomOrigin or an S3Origin. You cannot specify both.

The backward-compatible way is to recognise both {name}.s3.amazonaws.com and {name}.s3.{domain}.amazonaws.com, but for this a regular expression is the most effective solution.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
cloudfront_distribution
ADDITIONAL INFORMATION
The breakdown of the regex I used: \.s3(?:\.[^.]+)?\.amazonaws\.com$

\.s3 matches ".s3"
\.[^.]+ would match a dot followed by at least one, possibly more non-dot characters
(\.[^]+) would match the same, just grouped, so we could treat it as an atom
(?:\.[^]+) would match the same, just grouped in a non-capturing fashion (we don't want to extract the matched characters)
(?:\.[^]+)? matches the same, occuring 0 or 1 times
\.amazonaws\.com matches ".amazonaws.com"
$ matches the end of the input string

Reviewed-by: Mark Chappell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-5 PR should be backported to the stable-5 branch backport-6 PR should be backported to the stable-6 branch mergeit Merge the PR (SoftwareFactory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cloudfront_distribution doesn't recognise S3 origin
3 participants