Deploy app with circleci to AWS

circle.yml

#1

I’m trying to deploy my app and generate the .war file in my bucket on AWS S3.

I tried using this:

       deploy:
         docker:
             - image: circleci/node:6.14.1-browsers
         working_directory: ~/${project_name}
         steps:
           - attach_workspace:
              at: ~/${project_name}
           - run:
               name: Deploy
               command: 'aws s3 sync ${build_folder}/ s3://${bucket}'

// Tried using this:

 deployment:
   prod:
     branch: master
     commands:
       - aws s3 sync jekyll/_site/docs s3://circle-production-static-site/docs/ --delete
 
  but also didn't work:
 
 I have my permissions set for my project and my last config.yml configuration is this:
 
 --- 
 jobs: 
   build: 
     docker: 
       - 
         image: "circleci/openjdk:8-jdk"
     environment: 
       JVM_OPTS: "-Xmx3200m"
       TERM: dumb
     steps: 
       - checkout
       - 
         restore_cache: 
           keys: 
             - "v1-dependencies-{{ checksum \"build.gradle\" }}"
             - v1-dependencies-
       - 
         run: "gradle dependencies"
       - 
         save_cache: 
           key: "v1-dependencies-{{ checksum \"build.gradle\" }}"
           paths: 
             - ~/.gradle
       - 
         run: "gradle test"
     working_directory: ~/circle-tmp-folder
   deploy: 
     machine: 
       enabled: true
     steps: 
       - 
         run: 
           command: "aws s3 sync ${wstest}/ s3://${circleciwar} --region us-west-2"
           name: Deploy
     working_directory: ~/circle-tmp-folder
 version: 2

It shows me any error, and the operation is showing me successfully, but no .war file on my bucket.
What am I doing wrong?

Cheers


#3

Thanks for your reply.

Now what is happening to me is that it’s running correctly according to Circleci interface, but I can’t see my deploy on my AWS bucket.

here’s the message regarding from Circleci interface:

Here’s my config.yml:

jobs: 
  build-job: 
    docker: 
      - 
        image: "circleci/openjdk:8-jdk"
      - 
        environment: 
          POSTGRES_DB: stack_core_user
          POSTGRES_PASSWORD: "StackCore!@#"
          POSTGRES_USER: stack
        image: "postgres:9.6"
    steps: 
      - checkout
      - 
        restore_cache: 
          keys: 
            - "v1-dependencies-{{ checksum \"StackCore/build.gradle\" }}"
            - v1-dependencies-
      - 
        run: "gradle dependencies"
      - 
        save_cache: 
          key: "v1-dependencies-{{ checksum \"StackCore/build.gradle\" }}"
          paths: 
            - ~/.gradle
      - 
        run: "gradle build"
    working_directory: /tmp/app
  deploy-job: 
    docker: 
      - 
        image: "circleci/openjdk:8-jdk"
      - 
        environment: 
          POSTGRES_DB: stack_core_user
          POSTGRES_PASSWORD: "StackCore!@#"
          POSTGRES_USER: stack
        image: "postgres:9.6"
    steps: 
      - 
        run: 
          command: "sudo apt-get -y -qq install awscli"
          name: "Install awscli"
      - 
        run: 
          command: "aws configure list"
          name: "show credentials"
      -
       run:
         command: "aws s3 ls"
         name: "List all buckets"
      -
       run:
         command: "aws s3 ls s3://circleciwar"
         name: "Return bucket path"
      - 
        run: 
          command: "aws s3 sync /tmp/app/ s3://circleciwar"
          #command: "aws s3 sync s3://circleciwar"
          name: "Deploy to S3 circleciwar bucket"
    working_directory: /tmp/app
version: 2
workflows: 
  build-deploy: 
    jobs: 
      - build-job
      - 
        deploy-job: 
          filters: 
            branches: 
              only: master
          requires: 
            - build-job
  version: 2

#4

@halfer did what you asked me for, what about my last question. Can you help?


#5

You say that your YAML configuration contains these statements:

 but also didn't work:

I have my permissions set for my project and my last config.yml configuration is this:

I doubt the YAML parser will be able to read such a file at all, since this is probably not valid YAML.

(If this is just malformed formatting, please repair - remember that others in the future will read your posts, so we might as well make them readable.)


#6

@halfer Hey mate, I asked you “CAN YOU HELP ME WITH MY LAST QUESTION?”. I already mentioned that I was able to fixed the first problem. Posted below my entire config.yml file all the way you asked me for. Asked you a question and you supposed to help me, as I’m a customer, but instead you are bitching about the first post that already is out of the picture. What a terrible customer service you guys have. Bitching about irrelevant things instead of helping the curstomers


#7

@rrafaelpaz - I am not an employee. I am merely a happy CircleCI user and I do not get paid to help people. I have helped many people fix their problems here, and they have been suitably grateful each time.

I suggest you owe me an apology, and that deleting your last post would be appropriate.


#8

@halfer So if you come here to bitching about other peoples post, please don’t! I asked a question, I’m extremely busy and forgot to format the posting (which was my fault), but then I fixed, let it clear I fixed the error and was asking for any tips to take me to the right direction and you came along bitching about the formatting of my file instead of help. If you’re not here to help man, please don’t get into other people’s business. Thank you very much!


#9

I am actually helping you. Granted, not in the way you want, but you’re struggling to ask a clear set of questions. As a software engineer you need to be able to ask clear questions.

You actually did not. What you said was “Now what is happening to me”, which if one pretends hard enough, could be taken to mean that the original problem is solved. But, perhaps you could have said “the above problem is solved”. I am not taking you to task for being unclear, we all do it accidentally - merely I am pointing out that your view that you have been clear is incorrect.

You did not. The formatting is still broken, even after you have been asked twice to fix it. It’ll take you much less longer to repair it than post to explain why you won’t.

Sure, so are a lot of people. However, you’re posting on a board where other busy people post, and you might as well respect their time by posting clearly. That includes repairing the formatting, which takes about five seconds to do.

It's Markdown, which is easy to learn.
It's used on GitHub, Reddit and Stack Overflow and a
  bunch of other places,
and software engineers cannot avoid it

I appreciate you are unlikely to welcome my intervention, since it is not germane to your immediate problem. Getting unexpected replies on the internet is an exercise in patience, for all of us - since we can be exposed to criticism, and sometimes that criticism is justified. Don’t take it to heart. It isn’t personal.

What would be best now (in my opinion) is for you to delete the entire thread, since:

  • The first post is no longer relevant
  • There is some distracting meta-conversation
  • Your shouting and intemperate language do not reflect well on you

If you can repost the new problem, consider adding some verbose flags to the AWS command to examine any warning/error output - there is not really anything to look at presently. Or maybe it generates some logs - if so, readers would need to see those.

Genuinely, I believe the above will help you. Good luck.


#10

@halfer cool mate, you took probably half an hour to write down a bunch of useless stuff, criticising the format of my post instead of looking for the content of it.
Cheers mate, you want a medal?


#11

Well, perhaps you’ll read my advice secretly :male_detective:, and maybe the assistance it provides will gently seep into your brain :brain: , and your next question will be crystal clear :crystal_ball: .

Thanks for the offer, but got these already! :medal_sports: :medal_military:


#12

The formating of the config you posted makes it very hard to read. YAML is very specific so sometimes the formatting can be hard to read and sometimes it can cause unknowing errors.

From what I can see, the command aws s3 sync in the deploy-job isn’t deploying anything because that job does not have any files from your project. You’ll want to take advantage of CircleCI Workspaces in order to move the file(s) created from gradle build in thebuild-job so that they are available to the AWS CLI in deploy-job.


#13

@FelicianoTech

Thanks mate for your feedback! I found this website http://www.yamllint.com/ that test my .yml files and tell me if the structure is correct or not, very useful!

And the reason Circleci wasn’t sending my files to aws wasn’t because my .yml was incorrect. The reason was because after building the app I was trying to send the build files to AWS in the deployment job, but somehow the building files disappeared from the building folder in the deployment job. I believe that was happening because Circleci was running two different jobs (Paralles). What I did, was to make the deployment inside the building job. That fixed the problem, as the building files didn’t disappear from that folder when I was doing the deployment.