元数据获取 本节介绍了元数据获取的操作场景、使用须知、弹性云主机元数据类别支持列表、前提条件、Metadata(OpenStack元数据API)、User data(OpenStack元数据API)等内容。 操作场景 弹性云主机元数据包含了弹性云主机在云平台的基本信息,例如云服务ID、主机名、网络信息等。弹性云主机元数据支持两种风格,可以分别通过兼容Openstack和兼容EC2的API获取,如表 61所示。对于支持的元数据类型,本节详细介绍了其URI和使用方法。 使用须知 如果元数据中包含了敏感数据,您应当采取适当的措施来保护敏感数据,比如限制访问范围、加密等。 防火墙配置示例如下所示: Windows 如果您不希望管理员之外的用户访问自定义用户数据,请以管理员身份开启防火墙后,在PowerShell 中执行下面的命令,阻止非管理员用户访问自定义用户数据: PS C:>$RejectPrincipal NewObject TypeName System.Security.Principal.NTAccount ("Everyone") PS C:>$RejectPrincipalSID $RejectPrincipal.Translate([System.Security.Principal.SecurityIdentifier]).Value PS C:>$ExceptPrincipal NewObject TypeName System.Security.Principal.NTAccount ("Administrator") PS C:>$ExceptPrincipalSID $ExceptPrincipal.Translate([System.Security.Principal.SecurityIdentifier]).Value PS C:>$PrincipalSDDL "O:LSD:(D;;CC;;;$ExceptPrincipalSID)(A;;CC;;;$RejectPrincipalSID)" PS C:>NewNetFirewallRule DisplayName "Reject metadata service for $($RejectPrincipal.Value), exception: $($ExceptPrincipal.Value)" Action block Direction out Protocol TCP RemoteAddress 169.254.169.254 LocalUser $PrincipalSDDL Linux 如果您不希望root之外的用户访问自定义用户数据,请以root用户权限执行下面的命令,阻止非root用户访问自定义用户数据: iptables append OUTPUT proto tcp destination 169.254.169.254 match owner ! uidowner root jump REJECT