You need the bash resource inside your loop:
instances.each do |instance|
bash "create_link-#{instance}" do
code <<-EOH
echo "ln -fs #{source} #{instance}"
EOH
end
end
BTW, this is not idiomatic chef. You should simply use the link
resource like this:
instances.each do |instance|
link instance do
to source
end
end
An advantage of this approach is that it makes your recipe cross-platform. It's also a lot more readable.