博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AWS Credentials 使用
阅读量:4934 次
发布时间:2019-06-11

本文共 3219 字,大约阅读时间需要 10 分钟。

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:

  • When using an EC2 instance, create an IAM role and then give your EC2 instance access to that role as shown in .
  • Set up AWS credentials within Eclipse using the . See  in the for more information.

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:\Users\USERNAME\.aws\credentials on Windows

    This file should contain lines in the following format:

    [default]aws_access_key_id = your_access_key_idaws_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_idexport AWS_SECRET_ACCESS_KEY=your_secret_access_key

    To set these variables on Windows, use set:

    set AWS_ACCESS_KEY_ID=your_access_key_idset 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  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 .

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:\Users\USERNAME\.aws\config 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.

    来源: 

转载于:https://www.cnblogs.com/tilv37/p/6564787.html

你可能感兴趣的文章
mysql建用户和修改密码和忘记密码的解决办法
查看>>
Provisioning Services 7.6 入门到精通系列之五:PVS控制台安装
查看>>
老字号“张小泉”上线小程序与酷客多达成战略合作!
查看>>
6个技巧精准捕获百度知道问题
查看>>
FSMT:文件服务器从03迁移到08R2实战演练
查看>>
Windows Server 2008 更改计算机的MAC地址
查看>>
寻找Cydia里面软件安装包deb文件的真实下载地址
查看>>
将Windows8或WindowsServer2012装在VHD上
查看>>
Windows server 2003域控直接迁移到2012[史上最详细]
查看>>
Microsoft Azure WebSite创建网站
查看>>
《从零开始学Swift》学习笔记(Day 23)——尾随闭包
查看>>
复盘良品铺子爆款逻辑: “一代佳仁”如何站在风口?
查看>>
订单需求
查看>>
分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(4月16日-4月22日)
查看>>
软件编译安装小结
查看>>
《统一沟通-微软-实战》-7-配置-3-响应组
查看>>
db2move 导入导出数据库
查看>>
Photoshop制作一只可爱的卡通小鸟
查看>>
EMC产品分析介绍(三):备份领域的引领者DataDomain (2)
查看>>
烂泥:学习ssh之ssh密钥随身携带
查看>>