Create new S3 bucket and access from existing ec2 instance

HI Team,

I am new to terraform, here is my question.

I want to create new s3 bucket and access it from existing ec2 instance via terraform.

You will need to create an S3 bucket resource as well as IAM resources (e.g. policy, attached profile, etc.). If you don’t want to managed the existing EC2 instance via Terraform you’d then attach the policy to the instance, otherwise you’d also write code for the instance and import it into your Terraform state.