zoukankan      html  css  js  c++  java
  • AWS Credentials 使用

    AWS的文档系统真是烂到家了!!!!!


    To connect to any of the supported services with the AWS SDK for Java, you must provide AWS credentials. The AWS SDKs and CLIs use provider chains to look for AWS credentials in a number of different places, including system/user environment variables and local AWS configuration files.

    This topic provides basic information about setting up your AWS credentials for local application development using the AWS SDK for Java. If you need to set up credentials for use within an EC2 instance or if you're using the Eclipse IDE for development, refer to the following topics instead:

    Setting AWS Credentials#

    Setting your credentials for use by the AWS SDK for Java can be done in a number of ways, but here are the recommended approaches:

    • Set credentials in the AWS credentials profile file on your local system, located at:

      • ~/.aws/credentials on Linux, macOS, or Unix
      • C:UsersUSERNAME.awscredentials on Windows

      This file should contain lines in the following format:

      [default]
      aws_access_key_id = your_access_key_id
      aws_secret_access_key = your_secret_access_key
      

      Substitute your own AWS credentials values for the values your_access_key_id andyour_secret_access_key.

    • Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

      To set these variables on Linux, macOS, or Unix, use export:

      export AWS_ACCESS_KEY_ID=your_access_key_id
      export AWS_SECRET_ACCESS_KEY=your_secret_access_key
      

      To set these variables on Windows, use set:

      set AWS_ACCESS_KEY_ID=your_access_key_id
      set AWS_SECRET_ACCESS_KEY=your_secret_access_key
      
    • For an EC2 instance, specify an IAM role and then give your EC2 instance access to that role. See IAM Roles for Amazon EC2 in the Amazon EC2 User Guide for Linux Instances for a detailed discussion about how this works.

    Once you have set your AWS credentials using one of these methods, they will be loaded automatically by the AWS SDK for Java by using the default credential provider chain. For further information about working with AWS credentials in your Java applications, see Working with AWS Credentials.

    Setting the AWS Region#

    You should set a default AWS Region that will be used for accessing AWS services with the AWS SDK for Java. For the best network performance, you should choose a region that's geographically close to you (or to your customers).

    Note

    If you don't select a region, then us-east-1 will be used by default.

    You can use similar techniques to setting credentials to set your default AWS region:

    • Set the AWS region in the AWS config file on your local system, located at:

      • ~/.aws/config on Linux, macOS, or Unix
      • C:UsersUSERNAME.awsconfig on Windows

      This file should contain lines in the following format:

      [default]
      region = your_aws_region
      

      Substitute your desired AWS region (for example, "us-west-2") for your_aws_region.

    • Set the AWS_REGION environment variable.

      On Linux, macOS, or Unix, use export:

      export AWS_REGION=your_aws_region
      

      On Windows, use set:

      set AWS_REGION=your_aws_region
      

      Where your_aws_region is the desired AWS region name.





  • 相关阅读:
    centos7环境下编译安装apache2.4.41匹配php-fpm模式
    centos7系统下elasticsearch7.5.1集群安装elasticsearch-jieba-plugin 7.4.2 和analysis-kuromoji 日语分词器
    解决pureftp目录无法显示的问题
    在django中使用celery异步任务和定时任务
    Django创建站点的基本步骤
    使用windows定时任务运行python脚本
    python对邮件的常用操作收邮件发邮件
    python操作拷贝excel到另外一个excel中
    centos7环境通过rpm包安装mysql8.0.19
    centos7环境编译安装python3.7.7和pipenv的简单使用
  • 原文地址:https://www.cnblogs.com/tilv37/p/6564787.html
Copyright © 2011-2022 走看看