セキュリティグループに 1 つ以上のアウトバウンドルールを追加します。この操作を使用して、セキュリティグループのアウトバウンドアクセス権限を指定し、セキュリティグループ内のインスタンスから他のデバイスへのアウトバウンドトラフィックを許可または拒否することで、きめ細かなネットワークアクセスの制御を実現できます。
操作説明
始める前に
数量制限: 単一のネットワークインターフェース(NIC)に関連付けられたすべてのセキュリティグループのルール総数(インバウンドルールとアウトバウンドルールの両方を含む)は 1,000 を超えることはできません。詳細については、セキュリティグループの使用制限を参照してください。
優先度の設定: アウトバウンドセキュリティグループルールの優先度(Priority)の有効値は 1 から 100 です。数値が小さいほど優先度が高くなります。2 つのセキュリティグループルールの優先度が同じ場合、拒否(drop)ルールが優先されます。
注意事項
指定されたセキュリティグループルールが既に存在する場合、呼び出しは成功しますがルールは追加されません。
ルールの判定方法
アウトバウンドルールを判定するには、以下のパラメーターが必須です:
送信先のセット: 次のいずれかを指定します: DestCidrIp(IPv4 アドレス)、Ipv6DestCidrIp(IPv6 アドレス)、DestPrefixListId(プレフィックスリスト ID)、または DestGroupId(送信先セキュリティグループ)。
宛先ポート範囲: PortRange。
プロトコルの種類: IpProtocol。
アクセスポリシー: Policy。
高度なセキュリティグループは、他のセキュリティグループへのアクセス権限付与をサポートしていません。カスタムセキュリティグループは、最大 20 個の権限付与されたセキュリティグループをサポートします。
リクエスト例
以下の例は、中国(杭州)リージョンのセキュリティグループに異なる送信先のアウトバウンドルールを追加する方法を示しています:
-
指定された IP アドレス範囲のアクセス権限を追加します。
"RegionId":"ap-southeast-1", // リージョンを指定します。 "SecurityGroupId":"sg-bp17vs63txqxbds9***", // セキュリティグループを指定します。 "Permissions":[ { "DestCidrIp":"10.0.0.0/8", // 送信先 IPv4 アドレスを指定します。 "PortRange":"-1/-1", // ポート範囲を指定します。 "IpProtocol":"ICMP", // プロトコルの種類を指定します。 "Policy":"Accept" // アクセスポリシーを指定します。 } ] -
別のセキュリティグループとプレフィックスリストのアクセス権限を追加します。
"RegionId":"ap-southeast-1", "SecurityGroupId":"sg-bp17vs63txqxbds9***", "Permissions":[ { "DestGroupId":"sg-bp67acfmxazb4pi***", // 送信先セキュリティグループを指定します。 "PortRange":"22/22", "IpProtocol":"TCP", "Policy":"Drop" },{ "DestPrefixListId":"pl-x1j1k5ykzqlixdcy****", // 送信先プレフィックスリストを指定します。 "PortRange":"22/22", "IpProtocol":"TCP", "Policy":"Drop" } ]
今すぐお試しください
テスト
RAM 認証
|
アクション |
アクセスレベル |
リソースタイプ |
条件キー |
依存アクション |
|
ecs:AuthorizeSecurityGroupEgress |
create |
*All Resource
|
|
なし |
リクエストパラメーター
|
パラメーター |
型 |
必須 / 任意 |
説明 |
例 |
| RegionId |
string |
必須 |
ソースセキュリティグループのリージョン ID。 DescribeRegions を呼び出して、最新のリージョンリストをクエリできます。 |
cn-hangzhou |
| RegionId |
string |
必須 |
ソースセキュリティグループのリージョン ID。 DescribeRegions を呼び出して、最新のリージョンリストをクエリできます。 |
cn-hangzhou |
| RegionId |
string |
必須 |
ソースセキュリティグループのリージョン ID。 DescribeRegions を呼び出して、最新のリージョンリストをクエリできます。 |
cn-hangzhou |
| ClientToken |
string |
任意 |
リクエストのべき等性を確保するために使用されるクライアントトークン。クライアントを使用してトークンを生成できますが、異なるリクエスト間でトークンが一意であることを確認してください。ClientToken の値には ASCII 文字のみを含めることができ、64 文字を超えることはできません。詳細については、べき等性の確保方法を参照してください。 |
123e4567-e89b-12d3-a456-426655440000 |
| ClientToken |
string |
任意 |
リクエストのべき等性を確保するために使用されるクライアントトークン。クライアントを使用してトークンを生成できますが、異なるリクエスト間でトークンが一意であることを確認してください。ClientToken の値には ASCII 文字のみを含めることができ、64 文字を超えることはできません。詳細については、べき等性の確保方法を参照してください。 |
123e4567-e89b-12d3-a456-426655440000 |
| SecurityGroupId |
string |
必須 |
セキュリティグループ ID。 |
sg-bp67acfmxazb4p**** |
| SecurityGroupId |
string |
必須 |
セキュリティグループ ID。 |
sg-bp67acfmxazb4p**** |
| Permissions |
array<object> |
任意 |
セキュリティグループルール。配列の長さ: 1~100。 |
|
|
object |
任意 |
セキュリティグループの権限ルール。 |
||
| Policy |
string |
任意 |
アクセス権限のセット。有効な値:
デフォルト値: accept。 |
accept |
| Priority |
string |
任意 |
セキュリティグループルールの優先度。値が小さいほど優先度が高くなります。有効な値: 1~100。 デフォルト値: 1。 |
1 |
| IpProtocol |
string |
任意 |
ネットワーク層またはトランスポートレイヤーのプロトコル。2 種類の値がサポートされています:
|
ALL |
| DestCidrIp |
string |
任意 |
アクセス権限をセットする送信先 IPv4 CIDR ブロック。CIDR 初期化と IPv4 初期化のアドレス範囲の両方がサポートされています。 |
10.0.0.0/8 |
| Ipv6DestCidrIp |
string |
任意 |
アクセス権限をセットする送信先 IPv6 CIDR ブロック。CIDR 初期化と IPv6 初期化のアドレス範囲の両方がサポートされています。 説明
このパラメーターは、IPv6 をサポートする VPC タイプの ECS インスタンスにのみ有効です。このパラメーターと |
2001:db8:1233:1a00::*** |
| DestGroupId |
string |
任意 |
アクセス権限を設定する送信先セキュリティグループの ID。
|
sg-bp67acfmxazb4p**** |
| DestPrefixListId |
string |
任意 |
アクセス権限をセットする送信先プレフィックスリストの ID。 DescribePrefixLists を呼び出して、使用可能なプレフィックスリスト ID をクエリできます。 注意事項:
詳細については、セキュリティグループの使用制限を参照してください。 |
pl-x1j1k5ykzqlixdcy**** |
| PortRange |
string |
任意 |
セキュリティグループのプロトコルに対応する宛先ポート範囲。有効な値:
|
80/80 |
| SourceCidrIp |
string |
任意 |
ソース IPv4 CIDR ブロック。CIDR 初期化と IPv4 初期化のアドレス範囲の両方がサポートされています。 このパラメーターは 5 タプルルールをサポートするために使用されます。詳細については、セキュリティグループの 5 タプルルールを参照してください。 |
10.0.0.0/8 |
| Ipv6SourceCidrIp |
string |
任意 |
ソース IPv6 CIDR ブロック。CIDR 初期化と IPv6 初期化のアドレス範囲の両方がサポートされています。 このパラメーターは 5 タプルルールをサポートするために使用されます。詳細については、セキュリティグループの 5 タプルルールを参照してください。 説明
このパラメーターは、IPv6 をサポートする VPC タイプの ECS インスタンスにのみ有効です。このパラメーターと |
2001:db8:1234:1a00::*** |
| SourcePortRange |
string |
任意 |
セキュリティグループのプロトコルに対応する送信元ポート範囲。有効な値:
このパラメーターは 5 タプルルールをサポートするために使用されます。詳細については、セキュリティグループの 5 タプルルールを参照してください。 |
80/80 |
| DestGroupOwnerAccount |
string |
任意 |
クロスアカウントセキュリティグループルールを設定する際に、送信先セキュリティグループを管理する Alibaba Cloud アカウント。
|
Test@aliyun.com |
| DestGroupOwnerId |
integer |
任意 |
クロスアカウントセキュリティグループルールを設定する際に、送信先セキュリティグループを管理する Alibaba Cloud アカウントの ID。
|
12345678910 |
| NicType |
string |
任意 |
クラシックネットワークセキュリティグループルールのネットワークインターフェース(NIC)タイプのセット。有効な値:
デフォルト値: internet。 |
intranet |
| Description |
string |
任意 |
セキュリティグループルールの説明。説明は 1~512 文字である必要があります。 |
This is description. |
| PortRangeListId |
string |
任意 |
ポートリスト ID。
|
prl-2ze9743**** |
Policy
deprecated
|
string |
任意 |
非推奨。 |
accept |
Priority
deprecated
|
string |
任意 |
非推奨。 |
1 |
IpProtocol
deprecated
|
string |
任意 |
非推奨。 |
ALL |
DestCidrIp
deprecated
|
string |
任意 |
非推奨。 |
10.0.0.0/8 |
Ipv6DestCidrIp
deprecated
|
string |
任意 |
非推奨。 |
2001:db8:1233:1a00::*** |
DestGroupId
deprecated
|
string |
任意 |
非推奨。 |
sg-bp67acfmxazb4p**** |
DestPrefixListId
deprecated
|
string |
任意 |
非推奨。 |
pl-x1j1k5ykzqlixdcy**** |
PortRange
deprecated
|
string |
任意 |
非推奨。 |
80/80 |
SourceCidrIp
deprecated
|
string |
任意 |
非推奨。 |
10.0.0.0/8 |
Ipv6SourceCidrIp
deprecated
|
string |
任意 |
非推奨。 |
2001:db8:1234:1a00::*** |
SourcePortRange
deprecated
|
string |
任意 |
非推奨。 |
80/80 |
DestGroupOwnerAccount
deprecated
|
string |
任意 |
非推奨。 |
Test@aliyun.com |
DestGroupOwnerId
deprecated
|
integer |
任意 |
非推奨。 |
12345678910 |
NicType
deprecated
|
string |
任意 |
非推奨。 |
intranet |
Description
deprecated
|
string |
任意 |
非推奨。 |
This is description. |
レスポンスフィールド
|
フィールド |
型 |
説明 |
例 |
|
object |
|||
| RequestId |
string |
リクエスト ID |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
例
成功レスポンス
JSONJSON
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
エラーコード
|
HTTP ステータスコード |
エラーコード |
エラーメッセージ |
説明 |
|---|---|---|---|
| 400 | OperationDenied | The specified IpProtocol does not exist or IpProtocol and PortRange do not match. | |
| 400 | InvalidIpProtocol.Malformed | The specified parameter PortRange is not valid. | |
| 400 | InvalidDestCidrIp.Malformed | The specified parameter DestCidrIp is not valid. | |
| 400 | InvalidPolicy.Malformed | The specified parameter Policy is not valid. | |
| 400 | InvalidNicType.ValueNotSupported | The specified NicType does not exist. | |
| 400 | InvalidNicType.Mismatch | The specified NicType conflicts with the authorization record. | |
| 400 | InvalidDestGroupId.Mismatch | Specified security group and destination group are not in the same VPC. | |
| 400 | InvalidDestGroup.NotFound | Specified destination security group does not exist. | |
| 400 | InvalidPriority.Malformed | The parameter Priority is invalid. | |
| 400 | InvalidPriority.ValueNotSupported | The specified parameter %s is invalid. | |
| 400 | InvalidSecurityGroupDiscription.Malformed | The specified security group rule description parameter %s is not valid. | |
| 400 | InvalidSecurityGroup.InvalidNetworkType | The specified security group network type is not support this operation, please check the security group network types. For VPC security groups, ClassicLink must be enabled. | |
| 400 | MissingParameter.Dest | One of the parameters DestCidrIp, Ipv6DestCidrIp, DestGroupId or DestPrefixListId in %s must be specified. | |
| 400 | InvalidParam.PortRange | The specified parameter %s is not valid. It should be two integers less than 65535 in ?/? format. | |
| 400 | InvalidIpProtocol.ValueNotSupported | The parameter %s must be specified with case insensitive TCP, UDP, ICMP, GRE or All. | |
| 400 | InvalidSecurityGroupId.Malformed | The specified parameter SecurityGroupId is not valid. | |
| 400 | InvalidParamter.Conflict | The specified SourceCidrIp should be different from the DestCidrIp. | |
| 400 | InvalidSourcePortRange.Malformed | The specified parameter SourcePortRange is not valid. | |
| 400 | InvalidPortRange.Malformed | The specified parameter PortRange must set. | |
| 400 | InvalidParam.SourceIp | The Parameters SourceCidrIp and Ipv6SourceCidrIp in %s cannot be set at the same time. | |
| 400 | InvalidParam.DestIp | The Parameters DestCidrIp and Ipv6DestCidrIp in %s cannot be set at the same time. | |
| 400 | InvalidParam.Ipv6DestCidrIp | The specified parameter %s is not valid. | |
| 400 | InvalidParam.Ipv6SourceCidrIp | The specified parameter %s is not valid. | |
| 400 | InvalidParam.Ipv4ProtocolConflictWithIpv6Address | IPv6 address cannot be specified for IPv4-specific protocol. | |
| 400 | InvalidParam.Ipv6ProtocolConflictWithIpv4Address | IPv4 address cannot be specified for IPv6-specific protocol. | |
| 400 | InvalidParameter.Ipv6CidrIp | The specified Ipv6CidrIp is not valid. | |
| 400 | InvalidGroupAuthParameter.OperationDenied | The security group can not authorize to enterprise level security group. | |
| 400 | InvalidParameter.Conflict | IPv6 and IPv4 addresses cannot exist at the same time. | |
| 400 | InvalidParam.PrefixListAddressFamilyMismatch | The address family of the specified prefix list does not match the specified CidrIp. | |
| 400 | NotSupported.ClassicNetworkPrefixList | The prefix list is not supported when the network type of security group is classic. | |
| 400 | AuthorizedGroupRule.LimitExceed | You have reached the limit on the number of group authorization rules that you can add to a security group.When authorization object of rule is security group, the limit is 20. | |
| 400 | InvalidParam.DestCidrIp | The specified parameter %s is not valid. | |
| 400 | InvalidParam.SourceCidrIp | The specified param SourceCidrIp is not valid. | |
| 400 | InvalidParam.Permissions | The specified parameter Permissions cannot coexist with other parameters. | |
| 400 | InvalidParam.DuplicatePermissions | There are duplicate permissions in the specified parameter Permissions. | |
| 400 | InvalidGroupParameter.OperationDenied | The attributes Policy, SourceGroupId, DestGroupId of enterprise level security groups are not allowed to be set or modified. | |
| 400 | InvalidParam.ProtocolNotSupportPortRangeList | The specified protocol does not support the port range list. | |
| 400 | InvalidPortRangeListId.NotFound | The specified port range list was not found. | |
| 401 | InvalidOperation.SecurityGroupNotAuthorized | The specified security group is not authorized to operate. | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | InvalidDestGroupId.Mismatch | NicType is required or NicType expects intranet. | |
| 403 | MissingParameter | The input parameter DestGroupId or DestCidrIp cannot be both blank. | |
| 403 | AuthorizationLimitExceed | The limit of authorization records in the security group reaches. | |
| 403 | InvalidParamter.Conflict | The specified SecurityGroupId should be different from the SourceGroupId. | |
| 403 | InvalidNetworkType.Conflict | The specified SecurityGroup network type should be same with SourceGroup network type (vpc or classic). | |
| 403 | InvalidSecurityGroup.IsSame | The authorized SecurityGroupId should be different from the DestGroupId. | |
| 403 | InvalidOperation.ResourceManagedByCloudProduct | %s | |
| 403 | LimitExceed.PrefixListAssociationResource | The number of resources associated with the prefix list exceeds the limit. | |
| 404 | InvalidSecurityGroupId.NotFound | The specified SecurityGroupId does not exist. | |
| 404 | InvalidDestGroupId.NotFound | The DestGroupId provided does not exist in our records. | |
| 404 | InvalidPrefixListId.NotFound | The specified prefix list was not found. |
完全なリストについては、「エラーコード」をご参照ください。
変更履歴
完全なリストについては、「変更履歴」をご参照ください。