“Dodaj mój adres IP do AWS Security Group CLI” Kod odpowiedzi

Dodaj IP do grupy bezpieczeństwa AWS CLI

FromPort=integer,IpProtocol=string,IpRanges=[{CidrIp=string,Description=string},{CidrIp=string,Description=string}],Ipv6Ranges=[{CidrIpv6=string,Description=string},{CidrIpv6=string,Description=string}],PrefixListIds=[{Description=string,PrefixListId=string},{Description=string,PrefixListId=string}],ToPort=integer,UserIdGroupPairs=[{Description=string,GroupId=string,GroupName=string,PeeringStatus=string,UserId=string,VpcId=string,VpcPeeringConnectionId=string},{Description=string,GroupId=string,GroupName=string,PeeringStatus=string,UserId=string,VpcId=string,VpcPeeringConnectionId=string}]
FanieltheFan

Dodaj mój adres IP do AWS Security Group CLI

# Retrieve current IP address
$IP=Invoke-WebRequest -UseBasicParsing http://whatismyip.akamai.com/
$sg="sg-00001"
$old_file_path = 'old_ip.txt'

if(Test-Path -Path $old_file_path){
    $OldIp=Get-Content -Path $old_file_path
    aws ec2 revoke-security-group-ingress --group-id "$sg" --protocol tcp --port 8443 --cidr "$OldIp/32"
}

aws ec2 authorize-security-group-ingress --group-id "$sg" --protocol tcp --port 8443 --cidr "$IP/32"

Set-Content -Path $old_file_path -Value $IP
FanieltheFan

Odpowiedzi podobne do “Dodaj mój adres IP do AWS Security Group CLI”

Pytania podobne do “Dodaj mój adres IP do AWS Security Group CLI”

Więcej pokrewnych odpowiedzi na “Dodaj mój adres IP do AWS Security Group CLI” w Shell/Bash

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu