How to copy a file to ec2 instance before userdata?

As part of build process, we are creating an rpm file.

This file is available in artifacts.

In the next stage, we are creating an ec2 instance using terraform and installing this rpm file(an s3 link at present, manually uploaded).

Need to directly access this link or any other option like copying to the ec2 machine from the artifacts, so that it can be installed with user-data of ec2 during launch.

Present, when I kept file provision, it is not working.