万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    zappa initで勝手に選ばれる

    zappa init 
    
    ███████╗ █████╗ ██████╗ ██████╗  █████╗
    ╚══███╔╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗
      ███╔╝ ███████║██████╔╝██████╔╝███████║
     ███╔╝  ██╔══██║██╔═══╝ ██╔═══╝ ██╔══██║
    ███████╗██║  ██║██║     ██║     ██║  ██║
    ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝     ╚═╝  ╚═╝
    
    Welcome to Zappa!
    
    Zappa is a system for running server-less Python web applications on AWS Lambda and AWS API Gateway.
    This `init` command will help you create and configure your new Zappa deployment.
    Let's get started!
    
    Your Zappa configuration can support multiple production stages, like 'dev', 'staging', and 'production'.
    What do you want to call this environment (default 'dev'): 
    
    AWS Lambda and API Gateway are only available in certain regions. Let's check to make sure you have a profile set up in one that will work.
    Okay, using profile serverless-blog!
    
    Your Zappa deployments will need to be uploaded to a private S3 bucket.
    If you don't have a bucket yet, we'll create one for you too.
    Okay, using profile serverless-blog!

    って勝手にAWSプロファイルが選択された

    AWSのポリシーの変なエラー

    「The policy failed legacy parsingっ」てエラー ポリシー作るときに出てきた。

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "iam:AttachRolePolicy",
                    "iam:GetRole",
                    "iam:CreateRole",
                    "iam:PutRolePolicy",
                    "apigateway:*",
                    "cloudformation:*",
                    "events:*",
                    "lambda:*",
                    "logs:*"
                ],
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": "iam:PassRole",
                "Resource": "arn:aws:iam::[myaccountid]:role/*-ZappaLambdaExecutionRole"
            },
            {
                "Effect": "Allow",
                "Action": "s3:*",
                "Resource": "arn:aws:s3:::zappa-*"
            }
        ]
    }

    [myaccountid][123456789]みたいに書いてしまってたが、 []のせい

    「動かして学ぶ!Pythonサーバレスアプリ開発入門」 サンプルコード

    P150で SESSION_TYPE = dynamodbコメントアウトしないとき

    python manage.py init_db                                                     
    Traceback (most recent call last):
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 548, in get_meta_table
        data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 329, in dispatch
        data = self._make_api_call(operation_name, operation_kwargs, settings)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 378, in _make_api_call
        prepared_request = self._create_prepared_request(request_dict, settings)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 306, in _create_prepared_request
        self._sign_request(request)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 298, in _sign_request
        auth.add_auth(request)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/botocore/auth.py", line 373, in add_auth
        raise NoCredentialsError()
    botocore.exceptions.NoCredentialsError: Unable to locate credentials
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "manage.py", line 9, in <module>
        manager.run()
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/flask_script/__init__.py", line 417, in run
        result = self.handle(argv[0], argv[1:])
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/flask_script/__init__.py", line 386, in handle
        res = handle(*args, **config)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/flask_script/commands.py", line 216, in __call__
        return self.run(*args, **kwargs)
      File "/Users/shinriyo/development/python_apps/application/flask_blog/scripts/db.py", line 9, in run
        if not Entry.exists():
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/models.py", line 753, in exists
        cls._get_connection().describe_table()
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/table.py", line 290, in describe_table
        return self.connection.describe_table(self.table_name)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 748, in describe_table
        tbl = self.get_meta_table(table_name, refresh=True)
      File "/Users/shinriyo/.local/share/virtualenvs/application-jAa1F8aU/lib/python3.8/site-packages/pynamodb/connection/base.py", line 551, in get_meta_table
        raise TableError("Unable to describe table: {}".format(e), e)
    pynamodb.exceptions.TableError: Unable to describe table: Unable to locate credentials

    pipenvがFishシェルで動かない

    pipenvコマンドを打つと

    Install http://docs.pipenv.org/en/latest/ to use this package.

    のエラー?が出る。

    https://github.com/sentriz/fish-pipenv

    M1のMacBook Airのせいかと思ってた。

    そこのREADMEを見ると原因が書いてあるけど

    fisher install sentriz/fish-pipenv

    で解決する。

    まぁ、今はpipenvの後発で代替になる?Poetryの方がいいかもしれない。

    https://qiita.com/ryoppippi/items/5fc1f96332b578e7c18a