Thank you both so much! I think I finally got it to work using a mixture of both of your code, plus guidance from this post:
https://gis.stackexchange.com/questions/187798/create-polygons-of-the-extents-of-a-given-raster-in-r
Here is what I did:
#extracted extent from my raster
e <- extent(raster1)
#turned extent into SpatialPolygons object to create the overall 'study space' polygon
p <- as(e, 'SpatialPolygons')
#got a polygon that surrounds cells in raster that are not NA to create the 'water' polygon
#first made a raster containing only the water cells (excluded land cells, which were NAs)
r <- raster1 > -Inf
#then converted water raster to polygons (you need to have package 'rgeos' installed for this to work)
pp <- rasterToPolygons(r, dissolve = T)
#plot study space polygon
plot(p, lwd=5, border='red')

#plot water polygon on top of it
plot(pp, lwd=3, border='blue')
#create mesh, with pp (the water polygon) on the left because it is inside the study space polygon, p
mesh1 <- inla.mesh.2d(boundary=list(list(pp, p)), max.edge=c(1000,2000), cutoff=200)
#plot mesh
plot(mesh1)
I do have a few additional questions: each pixel in my original raster was 100m by 100m and I have covariate data for each pixel that I want to use in an R inla bayesian spatial regression model. Does that mean that there should be a triangle for each pixel? If yes, should I change the max edge to 100?
Also, what determines the amount of land the mesh stretches over in the Haakon Bakka model? Is the short correlation range dictated by the cutoff being 1/5 of the max edge?
Is this mesh only used to help the model decide where to predict the results spatially, or does the extent of the mesh need to match the data points perfectly?
Thank you again!!