Aws sg and instance creation

You should not use a data source to refer to a resource in the same config. It’s a chicken and egg thing, you can’t refer to something before it exists.