Open bruno-espino opened 1 month ago
Build the site or deploy it? Also can I see what's in backend
?
Build, since when the site builds, it need to query the backend. Here is the backend file which creates the backend instance: // Get AL2023 AMI const amazon_ami = aws.ec2.getAmi({});
// EC2 IAM Role const backend_role = new aws.iam.Role("BackendRole", {});
// DB IAM Role const db_role = new aws.iam.Role("DbRole", {});
// EC2 Instance Profile const backend_profile = new aws.iam.InstanceProfile("BackendProfile", {});
// DB Instance Profile const db_profile = new aws.iam.InstanceProfile("DbProfile", {});
// EC2 Security Group export const backend_security_group = new aws.ec2.SecurityGroup("BackendSecurityGroup", {});
// DB Security Group const db_security_group = new aws.ec2.SecurityGroup("DbSecurityGroup", {});
// Redis Security Group const redis_security_group = new aws.ec2.SecurityGroup("RedisSecurityGroup", {});
// Redis Cache export const redis = new aws.elasticache.Cluster("Redis", {});
// DB Instance const db = new aws.rds.Instance("Db", {});
// Generate random strings for secrets const jwtSecret = new random.RandomPassword("JwtSecret", {}); const cookieSecret = new random.RandomPassword("CookieSecret", {});
// EC2 Instance export const backend = new aws.ec2.Instance("Backend", {});
// EC2 EIP const backend_eip = new aws.ec2.Eip("Eip", {});
// Cloudflare backend record const zone = cloudflare.getZoneOutput({});
new cloudflare.Record("BackendRecord", {});
@bruno-espino from the code u shared, sst.aws.Nextjs
should be created after aws.ec2.Instance
gets created. Are you seeing that Nextjs
is being created before the Instance
is created?
Yes, it's actually the first thing that the deployment does, building the site. I assume there is kind of a priority for SST components vs pulumi resources or something like that?
@bruno-espino I did some test today and saw this:
backend
is created; andNextjs
site (ie. buckets, functions, etc) are created after the backend
is created
Can u confirm this is what u saw as well?The follow up question is, is it a requirement for you that building the site also happens after the backend
is created?
That's right, that is what I saw;
In this case yes, since while the nextjs site builds, it queries some backend endpoints. Since it fails to query the backend, it fails to build, so it fails fails to deploy.
If I do a deploy afterwards, it builds and deploys just fine (since the backend is deployed), so its not really a huge issue, just maybe something that could be optional
I want to have my nextjs site build after creating a pulumi EC2 Instance, the following doesn't work:
It still tries to build the site before deploying the backend