AWS Logo
Menu
Q-Bits: Creating S3 Buckets Using CDK and Amazon Q Developer

Q-Bits: Creating S3 Buckets Using CDK and Amazon Q Developer

Tips and tricks for creating and managing Amazon S3 Buckets with Amazon Q Developer

Mirabela Dan
Amazon Employee
Published Feb 19, 2025
Last Modified Feb 20, 2025
Welcome to another installment of Q-Bits, our regular series showcasing cool ways Amazon employees are leveraging Amazon Q Developer. Today, we're diving into how Q Developer and the Cloud Development Kit can assist with creating and managing S3 buckets.
Amazon Q Developer is available where you do your work. In this blog post, I will showcase three different ways of making use of Amazon Q to learn about S3 buckets and their properties and then leverage Q Developer to write the CDK code for making use of S3 buckets.
Q Developer in the console
q developer in the console showcase

You can use Amazon Q Developer in the AWS Management console to ask questions about AWS. It’s available by pressing the “Q” button in the top right corner of the management console. We will use this to ask it some questions about S3 Buckets, starting with a basic question.
asking q dev console a simple question
It told me I can use S3 buckets to host static websites - that gave me an amazing idea for later!
For now, let me continue testing the functionality of Q Developer in the console. Besides asking it questions about AWS and best practices, I can actually also use this service to ask questions about my AWS resources and costs, contact Support directly, and diagnose common console errors.
Let me ask a more targeted question:
asking q developer to list my s3 buckets
Nice! I can see a list of all my actually existing buckets (I added a layer to protect the exact names for privacy). Amazon Q Developer also gave me a small insight - that most of my buckets are associated with AWS Amplify Projects. In the previous question I asked it did tell me I can use buckets for static website hosting, let’s find out more:
asking q developer in the console about using s3 buckets for hosting websitess

q dev console talking about cdk

I see this answers mentions bucket policies, I want to find out more about what this means:
q developer in the console talking about bucket policies
I’ve learned a lot about S3 buckets and even about my own account’s buckets by interacting with Q Developer in the console. I want to use the CDK to define my S3 bucket that I shall use for static web hosting. First, let me get some assistance from Q Developer in the CLI to get the CDK set up.
Q Developer in the CLI
I can use Q Developer to “translate” text to Shell commands by using the q translate command, just like in the screenshot below:
q dev cli - q translate functionality
I will then use another functionality of Q Developer in the CLI, Q chat, to give me further instructions about how i can create my first CDK app. I can interact with Q Chat by typing the q chat command in my terminal and then ask it my AWS questions. Here is the chat I had with Q in my terminal:
I will now execute this and I’m ready to proceed to the IDE to generate my S3 bucket CDK code.
Q Developer in the IDE
Q Developer is available as a plugin or extension in a variety of IDEs. For a full list, check out this documentation.
There are different ways to interact with Q Developer in the IDE - via chat (including agents), via comments or via inline code completion. I will use the chat to help me come up with the construct for an S3 bucket that I will use for static web hosting.
I have asked Q Developer to help me using the following prompt in the chat: Hello! I am looking to use the CDK to create an S3 bucket for static web hosting, can you guide me?
Here is the example answer provided:
I will choose to insert this code into a new file that I have created. When I insert, I note an alert from Q Developer!
q developer security alert

Q Developer can perform proactive scans of your code, including IaC code, as you go through it. Learn more here. Using this, you can review your codebase for security vulnerabilities and code quality issues to improve the posture of your applications throughout the development cycle.
Once i am happy with my template, I can cdk synth and cdk deploy my stack and keep building!
Amazon Q Developer uses generative AI. You may need to verify responses. Feel free to modify the prompt to your needs and liking as well. Please note that even if you use the same prompts noted in this article, you may have different outputs due to the non-deterministic nature of generative AI.
Conclusion
This is just the beginning of using Q Developer to create and manage S3 buckets. In this article, we have covered three different ways to interact with Amazon Q Developer to learn about S3 buckets and how to create them using CDK:
  • Q Developer in the console to ask questions about AWS, S3 and our S3 resources
  • Q Developer in the CLI to help us with the CDK commands needed to install and get started with the CDK
  • Q Developer in the IDE to actually write the CDK code for the S3 bucket that I am to use as a static hosting website
In terms of next steps, I could:
  • Use Q Developer in the console to dive deeper into information about S3 and learn more about best practices
  • Use Q Developer in the CLI to ask it about git commands that I can use to check in the infrastructure code i’ve just written
  • Use Q Developer in the IDE to write further CDK code to add a Cloudfront distribution to my S3 bucket for website hosting or write the actual application code
See you in the next Q-Bits blog post where we will showcase further tips and tricks with Q Developer on AWS!
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments