


This article introduces how to use the instance RAM role through the API after activating the RAM service, and focuses on the operation steps.
Using the instance RAM role through the API
Usage restrictions
##The use of the instance RAM role has the following restrictions:Only ECS instances of the private network (VPC) network type can use the instance RAM role. An ECS instance can only be granted the RAM role to one instance at a time. When you have granted the instance RAM role to an ECS instance and want to access the API of the cloud product in an application deployed within the ECS instance, you need to obtain the temporary authorization token of the instance RAM role through the instance metadata. . See 5. (Optional) Obtain temporary authorization token. If you use the RAM user sub-account to use the instance RAM role, you need to authorize the RAM user to use the instance RAM role through the cloud account 6. (Optional).Prerequisite
You have already activated the RAM service. Please refer to the RAM document for activation methods to activate the RAM service.1. Create an instance RAM role
Call the interface CreateRole to create an instance RAM role. Set the RoleName parameter, such as setting its value to EcsRamRoleDocumentTesting. Set the AssumeRolePolicyDocument according to the following policy:{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "ecs.aliyuncs.com" ] } } ], "Version": "1" }
2. Authorize the instance RAM role
Call the interface CreatePolicy to create a new authorization policy. Set the RoleName parameter, such as setting its value to EcsRamRoleDocumentTestingPolicy. Set PolicyDocument according to the following policy:{ "Statement": [ { "Action": [ "oss:Get*", "oss:List*" ], "Effect": "Allow", "Resource": "*" } ], "Version": "1" }Call the interface AttachPolicyToRole authorization role policy. Set the PolicyType parameter to Custom. Set the PolicyName parameter, such as EcsRamRoleDocumentTestingPolicy. Set the RoleName parameter, such as EcsRamRoleDocumentTesting.
3. Grant the RAM role to the instance
Call the interface AttachInstanceRamRole to grant the RAM role to the instance. Set the RegionId and InstanceIds parameters to specify an ECS instance. Set the RamRoleName parameter, such as EcsRamRoleDocumentTesting.4. (Optional) Reclaim the instance RAM role
Call the interface DetachInstanceRamRole to reclaim the instance RAM role. Set the RegionId and InstanceIds parameters to specify an ECS instance. Set the RamRoleName parameter, such as EcsRamRoleDocumentTesting.5. (Optional) Obtain a temporary authorization token
You can obtain a temporary authorization token for the instance RAM role. This temporary authorization token can Execute the permissions and resources of the instance RAM role, and the temporary authorization token is automatically updated periodically. Example: Retrieve the temporary authorization token of the instance RAM role named EcsRamRoleDocumentTesting: Linux instance: Execute the command curl http://100.100.100.200/latest/meta-data/Ram/security -credentials/EcsRamRoleDocumentTesting. Windows instances: See the documentation for instance metadata. Obtain temporary authorization Token. The returned example is as follows:{ "AccessKeyId" : "XXXXXXXXX", "AccessKeySecret" : "XXXXXXXXX", "Expiration" : "2017-11-01T05:20:01Z", "SecurityToken" : "XXXXXXXXX", "LastUpdated" : "2017-10-31T23:20:01Z", "Code" : "Success" }
6. (Optional) Authorize the RAM user to use the instance RAM role
DescriptionWhen When you authorize a RAM user to use an instance RAM role, you must grant the RAM user PassRole permissions for the instance RAM role. Among them, PassRole determines whether the RAM user can directly execute the permissions granted by the role policy. Log in to the RAM console and refer to the document to authorize the RAM user to complete the authorization as follows:{ "Version": "2016-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecs: [ECS RAM Action]", "ecs: CreateInstance", "ecs: AttachInstanceRamRole", "ecs: DetachInstanceRAMRole" ], "Resource": "*" }, { "Effect": "Allow", "Action": "ram:PassRole", "Resource": "*" } ] }
The above is the detailed content of How to use instance RAM role through API after activating RAM service. For more information, please follow other related articles on the PHP Chinese website!

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment