DEV Community

Cover image for Open Unclickable Instagram Post Description Links with AWS Lambda and iOS Shortcuts

Open Unclickable Instagram Post Description Links with AWS Lambda and iOS Shortcuts

Extracting Links from Instagram Posts Made Easy with AWS Lambda

Have you ever tried to just copy a link from an Instagram post caption, only to realize Instagram doesn't allow clickable links in the caption? For most users, this limitation is more than just annoying, especially when you want to quickly open a link someone shared in a post, while don't want to get distracted too much.

Instagram’s design forces users to go through several steps just to extract a link — if it's even possible at all. But don’t worry! I’m going to show you how to simplify this process using AWS Lambda and iOS Shortcuts. Best of all, you can set this up yourself with just a few steps, and it won’t cost you much, thanks to the efficiency and low cost of AWS’s Serverless services.

The Problem with Instagram Links

Instagram doesn’t allow clickable links in post captions, which means you can’t simply click and go. People online mentioned this might be due to avoidance of spam links or phishers, which is legit, but again, annoying.

"Open Link in Bio"

One of the most common ways is to add a link in the bio, and then add a caption like "Link in bio".

However, this is not ideal as it requires the user to click on the profile, and then click on the link in the bio - that's significant distraction already. Users could have been enjoying other contents in the feed, but now they are distracted by the "Link in bio" caption as they are forced to click on the profile to find the link. Also, this must be done by the content creator - as a user, this is helpless as you cannot guarantee every Instagram content creator follows this strictly.

Instead, users are forced to find a way to extract and open the link.

Straightforward but Hard Way

Memorize a long link from an Instagram post description - because the content creator did care about your user experience

First way, which I would not recommend - is to memorize the link into your brain, then type it manually in the browser.

You might have to go back to the Instagram App a few times if you are not confident with your short term memory.

The other Usual Painful Process:

For most users, extracting a link looks something like this:

  1. Copy the post link (from the post’s share options).
  2. Paste the link in a browser (Instagram opens in a browser).
  3. Drag and highlight the link (this can be tricky because you need to avoid missing any characters).
  4. Copy the link (if you managed to highlight it correctly).
  5. Paste the copied link into a new browser tab (finally!).

This whole process can be very frustrating and time-consuming, especially if you do it often.

Step by step way to extract a link in an Instagram post description

The Live Text Alternative (for iOS Users)

If you’re using iOS 15 or later, you might try to use the Live Text feature. This allows you to take a screenshot of the Instagram post and then copy the text (including the link) from the image. However, even this method is far from perfect:

  • It is not very reliable.
  • You still need to manually select the link from the image, which can easily result in errors.

Using Live Text to extract a link in an Instagram post description

The Fast and Easy Way: Use an iOS Shortcut!

To simplify things, I’ve developed a more efficient method using an iOS Shortcut combined with an AWS Lambda function. This approach allows you to extract links from Instagram posts in just a few seconds, with minimal effort—and it’s highly reliable.

Using Shortcuts with a AWS SAM backend to extract a link in an Instagram post description

What is does under the hood:

  1. Accepts the shared post URL from Instagram App
  2. Makes a POST request to the AWS API Gateway endpoint to retrieve the list of extracted Instagram post links (Python Script Here)
  3. Let's the user pick one of the extracted (if any) links
  4. Open an extracted link in browser

Now, you no longer have to either get distracted away from the original post, nor have to get anxious about highlighting the entire URL portion in the post.

Key Benefits of This Shortcut:

  • Speed: Extracts links in about 5 seconds.
  • Reliability: The shortcut directly accesses the raw HTML meta tag of the Instagram post, ensuring you get the correct link every time.
  • Convenience: No need to manually highlight or copy links anymore, or forced to navigate to the content creator's bio link.

Here’s how the three methods compare:

Method Speed Reliability Description
Short Term Memory 30s Medium (Depends) Perfect if you love memorizing things and do more manual typing.
Step by Step 20s High Requires manually copying the post link, opening it in a browser, then dragging to highlight the link—tedious and error-prone.
Live Text 10s Low Uses iOS Live Text to copy the link from a screenshot—unreliable and still requires manual effort.
This Shortcut 5s High Automatically extracts the link via an AWS API Gateway API endpoint, with no need for manual copying or highlighting—fast and reliable.

How It Works

The shortcut works by sending the Instagram post URL to an AWS Lambda function, which extracts the link from the post and returns it. AWS Lambda is ideal for this task because it only runs when triggered, making it cost-effective as you only pay for what you use.

How to Deploy Your Own Instagram Link Extractor

Although I’ve bundled the shortcut with my own deployed endpoint, I’ve set rate limits to prevent overuse. To avoid these limits and run it as much as you like, I recommend deploying your own version, which is easy and inexpensive.

Here’s how you can deploy it yourself using AWS CloudShell.

Step 0: Get into AWS Console

Step 1: Open AWS CloudShell

AWS CloudShell is a browser-based shell that allows you to interact with AWS services without needing to install anything locally. You can open CloudShell by visiting AWS CloudShell.

Step 2: Clone the GitHub Repository

In CloudShell, run the following commands to clone the repository and navigate into the project directory:

git clone https://github.com/gabrielkoo/insta-post-link-extractor.git
cd insta-post-link-extractor
Enter fullscreen mode Exit fullscreen mode

Step 3: Build and Deploy the Lambda Function

Next, use the AWS SAM CLI to build and deploy the Lambda function. This will create the necessary resources in AWS, including the Lambda function and the API Gateway.

# Build the application
sam build -x InstaPostLinkExtractorFunction

# Deploy the application
sam deploy --stack-name InstaPostLinkExtractor --guided

# Follow the prompts to configure your deployment.
Enter fullscreen mode Exit fullscreen mode

Once the deployment is complete, AWS will output the API Gateway URL and API Key that you'll use in the shortcut.

Step 4: Retrieve API Details

After deployment, you will see the API Gateway URL and API Key in the deployment output. These are essential for configuring the iOS Shortcut.

CloudFormation outputs from deployed stack
-----------------------------------------------------------------------------------------------------------------
Outputs
-----------------------------------------------------------------------------------------------------------------
Key                 InstaPostLinkExtractorApiApiKeyConsoleUrl
Description         API Gateway API Key Console URL for InstaPostLinkExtractorApi
Value               https://us-east-1.console.aws.amazon.com/apigateway/main/api-keys/[API_KEY_ID_HERE]?region=us-east-1

Key                 InstaPostLinkExtractorApi
Description         API Gateway endpoint URL for Prod stage for InstaPostLinkExtractorApi
Value               https://[APIGW_ID_HERE].execute-api.us-east-1.amazonaws.com/prod/insta-post-link-extractor/
------------------------------------------------------------------------------------------------------------------
Enter fullscreen mode Exit fullscreen mode

Step 5: Test API with curl

To test the API, use the following curl command. Replace the placeholder values with the API Gateway URL and API Key from the previous step.

export ENDPOINT_URL='https://[APIGW_ID_HERE].execute-api.us-east-1.amazonaws.com/prod/insta-post-link-extractor/'
export API_KEY='[YOUR_API_KEY]'

# Test the API
curl $ENDPOINT_URL \
    -X POST \
    -H "x-api-key: $API_KEY" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d '{"url": "https://www.instagram.com/p/DB5QbNzTQxY/"}' | jq
Enter fullscreen mode Exit fullscreen mode

If everything is working, the API will return the extracted links in JSON format.

{
  "links": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "https://www.youtube.com/watch?v=nsCIeklgp1M"
  ]
}
Enter fullscreen mode Exit fullscreen mode

Step 6: Install the iOS Shortcut

Now that the API is working, you can set up the iOS Shortcut. Install the pre-bundled shortcut from this link: Extract IG Post Links Shortcut.

Install the Shortcut

Replace the values in the

Once installed, enter the API_KEY and ENDPOINT_URL values from your AWS deployment into the shortcut settings, namely the Get contents of step. Now, you can extract Instagram links with just a tap!

Why AWS Lambda?

Using AWS Lambda for this task makes it cheap and efficient. Lambda runs your code on demand, so you only pay for the computing time you actually use, which makes it a perfect solution for lightweight tasks like this one.

Conclusion

With this simple setup, you can eliminate the frustration of manually extracting links from Instagram posts. By deploying your own Instagram Post Link Extractor, you’ll be able to quickly pull links from posts with just a few taps, saving you time and hassle.

Try it out for yourself by following the steps above, and start enjoying a faster, easier way of extracting Instagram links!

Lastly, feel free to modify it so that it can handle more cases - like extracting useful emails, phone numbers, or addresses from post descriptions!

For more details, check out the full project on GitHub: gabrielkoo/insta-post-link-extractor.


Note:

  • The iOS Shortcut I provided already includes my own deployed endpoint as well as the API key, but due to very restrictive rate limits, I recommend deploying your own version for unlimited use.
  • All images, except the screen recordings, have been generated by Amazon Titan Image Generator G1 V2.

Top comments (0)