- Newest
- Most votes
- Most comments
Hello
The directory /etc/yum/vars defines the custom yum variables. The directory must include the variables awsdomain and awsregion. You can able to get these values mapped to these variables from the path "cat /etc/dnf/vars/awsregion" and "cat /etc/dnf/vars/awsdomain"
$ cat /etc/yum/vars/awsregion us-east-1
$ cat /etc/yum/vars/awsdomain amazonaws.com
you can refer this article: https://repost.aws/knowledge-center/ec2-troubleshoot-yum-errors-al1-al2
Please check the following links
https://repost.aws/knowledge-center/ec2-troubleshoot-yum-errors-al1-al2 https://stackoverflow.com/questions/31331788/using-aws-cli-what-is-best-way-to-determine-the-current-region https://stackoverflow.com/questions/53473321/where-to-find-domain-name-to-existing-ec2-instance
as a summary
To get the AWS region, you can use one of the following commands:
aws configure get region
If you are using a profile, then type
aws configure get region --profile $PROFILE_NAME
You can get the current availability zone via an instance metadata and extract the region part from it using this command
curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1'
You can also use this AWS CLI command which gives the region actually used by the CLI regardless of whether environment variables are or are not set:
aws ec2 describe-availability-zones --output text --query 'AvailabilityZones[0].[RegionName]'
To get the AWS domain is more complex as it is not typically stored as a variable within the system. It could be related to the DNS service used and the specific AWS services (like load balancers) associated with the instance. In AWS, it's often linked to Route53, the AWS managed DNS service. You could find the domain associated with an instance by checking the Route53 service in AWS console3. But usually, the domain part for AWS Linux repository URLs tends to be amazonaws.com.
My question is more about how yum knows the correct repo location from
/etc/yum.repos.d/amazonlinux.repo, if the link to the repohttps://al2023-repos-$awsregion-de612dc2.s3.dualstack.$awsregion.$awsdomaincontains variables, which can not resolved by yum it self?
Relevant content
- asked a year ago

/etc/yum/is no such file or directory. And the result ofcat /etc/dnf/vars/awsdomainis empty. Same forcat /etc/dnf/vars/awsregion.