Home > OS >  sam build from Github actions suddenly failing from today
sam build from Github actions suddenly failing from today

Time:01-03

Till yesterday, my sam build was working with below Github actions and today suddenly started failing with an error : "AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'"

The SAM template doesn't have any error which i have validated, any others facing this issue? please add your inputs if anyone has already fixed this issue.

name: SAM deploy
on:
  push:
    branches:
      - main
jobs:
  build-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
      - uses: aws-actions/setup-sam@v2
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.MY_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.MY_AWS_SECRET_ACCESS_KEY }}
          aws-region: us-west-2
      - name: SAM Build
        run: sam build --use-container --template-file source/deploy-template.yml
      - name: SAM Deploy
        run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name my-stack --resolve-s3 --capabilities CAPABILITY_IAM --region us-west-2 --parameter-overrides Environment=npd

Gthub actions error details for sam build

        Traceback (most recent call last):
    496
    File "/home/runner/work/_temp/setup-sam-PFBc7r/bin/sam", line 8, in <module>
    497
        sys.exit(cli())
    498
                ^^^^^
    499
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    500
        return self.main(*args, **kwargs)
    501
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
    502
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1055, in main
    503
        rv = self.invoke(ctx)
    504
            ^^^^^^^^^^^^^^^^
    505
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1651, in invoke
    506
        cmd_name, cmd, args = self.resolve_command(ctx, args)
    507
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    508
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1698, in resolve_command
    509
        cmd = self.get_command(ctx, cmd_name)
    510
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    511
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/cli/command.py", line 133, in get_command
    512
        mod = importlib.import_module(pkg_name)
    513
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    514
    File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/importlib/__init__.py", line 126, in import_module
    515
        return _bootstrap._gcd_import(name[level:], package, level)
    516
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    517
    File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
    518
    File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
    519
    File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
    520
    File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
    521
    File "<frozen importlib._bootstrap_external>", line 940, in exec_module
    522
    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    523
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/build/__init__.py", line 6, in <module>
    524
        from .command import cli  # noqa
    505
        ^^^^^^^^^^^^^^^^^^^^^^^^
    506
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/build/command.py", line 12, in <module>
    507
        from samcli.commands._utils.options import (
    508
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/_utils/options.py", line 21, in <module>
    509
        from samcli.commands._utils.template import get_template_data, TemplateNotFoundException
    510
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/_utils/template.py", line 10, in <module>
    511
        from botocore.utils import set_value_from_jmespath
    512
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    513
        import botocore.httpsession
    514
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/botocore/httpsession.py", line 46, in <module>
    515
        from urllib3.contrib.pyopenssl import (
    516
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 50, in <module>
    517
        import OpenSSL.crypto
    518
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/OpenSSL/__init__.py", line 8, in <module>
    519
        from OpenSSL import crypto, SSL
    520
    File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/OpenSSL/crypto.py", line 3268, in <module>
    521
        _lib.OpenSSL_add_all_algorithms()
    522
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    523
    AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
    524
    Error: Process completed with exit code 1.

Validated SAM template Tried sudo apt install python3-openssl in the Github actions but didn't worked

CodePudding user response:

you can try this (work for me):

pip install pyopenssl --upgrade

CodePudding user response:

Worked after downgrading version of aws-actions/setup-sam@v2. The issue is with cryptography version 39.0.0 which was released 13hrs ago and latest sam uses this version and during the sam build we are noticing an error.

Refer pypi release history : https://pypi.org/project/cryptography/38.0.4/#history

So whoever using aws-actions/setup-sam@v2 should point back the sam version to 1.59.0 which could be a temporary fix

    name: SAM deploy
    on:
    push:
      branches:
        - main
    jobs:
      build-deploy:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v3
        - uses: actions/setup-python@v3
        - uses: aws-actions/setup-sam@v2
          with:
            version: 1.59.0
        - uses: aws-actions/configure-aws-credentials@v1
            with:
            aws-access-key-id: ${{ secrets.MY_AWS_ACCESS_KEY_ID }}
            aws-secret-access-key: ${{ secrets.MY_AWS_SECRET_ACCESS_KEY }}
            aws-region: us-west-2
        - name: SAM Build
            run: sam build --use-container --template-file source/deploy-template.yml
        - name: SAM Deploy
            run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name my-stack --resolve-s3 --capabilities CAPABILITY_IAM --region us-west-2 --parameter-overrides Environment=npd
  • Related