Failed to build cardano-node-1.34.1 on AWS

I’m new at this and following the Stake Pool Course to learn. I set up the AWS as per the tutorial with 30G and t2.medium. I’m at the ‘cabal build all’ and got the following error:

cabal: Failed to build cardano-node-1.34.1 (which is required by
exe:tx-generator from tx-generator-2.0, test:cardano-testnet-tests from
cardano-testnet-1.34.1 and others). The build process was killed (i.e.
SIGKILL). The typical reason for this is that there is not enough memory
available (e.g. the OS killed a process using lots of memory).

How do I fix this? I appreciate any help you can offer. Thank you!

upgrade your server or create swap ‘memmory’