8000 Update README.md · dirk39/aws-lambda-ddns-function@00cbe1c · GitHub
[go: up one dir, main page]

Skip to content

Commit 00cbe1c

Browse files
committed
Update README.md
1 parent 023cbce commit 00cbe1c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,19 @@ aws iam attach-role-policy --role-name ddns-lambda-role --policy-arn <enter-your
120120

121121
The Lambda function uses modules included in the Python 2.7 Standard Library and the AWS SDK for Python module (boto3), which is preinstalled as part of the Lambda service. As such, you do not need to create a deployment package for this function.
122122

123-
- The function first checks if the “DDNS” table exists in DynamoDB and creates the table if it does not. The table is used to keep a record of instances that have been created, along with their attributes. This is necessary because once an EC2 instance is terminated, its attributes are no longer available to be queried. Instead, they must be fetched from the table.
123+
The function code performs the following:
124124

125-
- The function then queries the event data to determine the instance's state. If the state is “running”, the function queries the EC2 API for the data it will need to update DNS. If the state is anything else, e.g. "stopped" or "terminated", it will retrieve the necessary information from the “DDNS” DynamoDB table.
125+
- Checks to see whether the “DDNS” table exists in DynamoDB and creates the table if it does not. This table is used to keep a record of instances that have been created along with their attributes. It’s necessary to persist the instance attributes in a table because once an EC2 instance is terminated, its attributes are no longer available to be queried via the EC2 API. Instead, they must be fetched from the table.
126126

127-
The function also checks whether “DNS resolution” and “DNS hostnames” are enabled since both are required in order to use Route 53 for private name resolution. It then checks to see whether a private hosted zone for the instance exists. If it does, it will proceed to check whether a private hosted zone is associated with the instance's VPC. If no such association exists, the function will create the association. Like DNS resolution and DNS hostname, this VPC/private-hosted-zone association is necessary in order for the VPC to Route 53 for DNS resolution.
127+
- Queries the event data to determine the instance's state. If the state is “running”, the function queries the EC2 API for the data it will need to update DNS. If the state is anything else, e.g. "stopped" or "terminated", it will retrieve the necessary information from the “DDNS” DynamoDB table.
128128

129-
- Next, the function checks the EC2 instance’s tags for the CNAME and ZONE tags. If the ZONE tag is found, the function creates A and PTR records in the specified zone. If the CNAME tag is found, the function creates a CNAME record in the specified zone.
129+
- Verifies that “DNS resolution” and “DNS hostnames” are enabled for the VPC, as these are required in order to use Route 53 for private name resolution. The function then checks whether a reverse lookup zone for the instance already exists. If it does, it checks to see whether the reverse lookup zone is associated with the instance's VPC. If it isn't, it creates the association. This association is necessary in order for the VPC to use Route 53 zone for private name resolution.
130130

131-
Next, the function checks to see whether there's a DHCP option set assigned to the VPC. If there is, it uses the value of the domain name to create resource records in the appropriate Route 53 private hosted zone. The function also checks to see whether there's an association between the instance's VPC and the private hosted zone for reverse lookups. If there isn't, it creates it.
131+
- Checks the EC2 instance’s tags for the CNAME and ZONE tags. If the ZONE tag is found, the function creates A and PTR records in the specified zone. If the CNAME tag is found, the function creates a CNAME record in the specified zone.
132132

133-
- The function deletes the required DNS resource records if the state of the EC2 instance changes to “shutting down” or “stopped”.
133+
- Verifies whether there's a DHCP option set assigned to the VPC. If there is, it uses the value of the domain name to create resource records in the appropriate Route 53 private hosted zone. The function also checks to see whether there's an association between the instance's VPC and the private hosted zone. If there isn't, it creates it.
134+
135+
- Deletes the required DNS resource records if the state of the EC2 instance changes to “shutting down” or “stopped”.
134136

135137
Use the AWS CLI to create the Lambda function:
136138

0 commit comments

Comments
 (0)
0